brakeman 7.1.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +11 -0
  3. data/README.md +1 -1
  4. data/bundle/load.rb +2 -2
  5. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  6. data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
  7. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
  8. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
  9. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
  10. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
  11. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/asciidoc.rb +12 -5
  12. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/babel.rb +5 -0
  13. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/builder.rb +4 -0
  14. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/coffee.rb +14 -4
  15. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/commonmarker.rb +41 -0
  16. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/csv.rb +63 -0
  17. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/erb.rb +130 -0
  18. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/erubi.rb +41 -8
  19. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/etanni.rb +7 -0
  20. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/haml.rb +67 -1
  21. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/kramdown.rb +59 -0
  22. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/liquid.rb +93 -0
  23. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/livescript.rb +11 -4
  24. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/mapping.rb +8 -8
  25. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/markaby.rb +11 -2
  26. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/nokogiri.rb +13 -2
  27. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/pandoc.rb +81 -0
  28. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/pipeline.rb +6 -1
  29. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/plain.rb +5 -1
  30. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/prawn.rb +17 -6
  31. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/radius.rb +96 -0
  32. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdiscount.rb +82 -0
  33. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdoc.rb +33 -0
  34. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcarpet.rb +73 -0
  35. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcloth.rb +40 -0
  36. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rst-pandoc.rb +33 -0
  37. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/sass.rb +16 -3
  38. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/slim.rb +18 -0
  39. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/string.rb +10 -2
  40. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/template.rb +5 -5
  41. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/typescript.rb +5 -0
  42. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/yajl.rb +91 -0
  43. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt.rb +1 -2
  44. data/lib/brakeman/app_tree.rb +7 -2
  45. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  46. data/lib/brakeman/checks/check_render.rb +1 -27
  47. data/lib/brakeman/checks/check_render_rce.rb +43 -0
  48. data/lib/brakeman/checks/check_session_settings.rb +1 -1
  49. data/lib/brakeman/checks.rb +31 -25
  50. data/lib/brakeman/commandline.rb +6 -1
  51. data/lib/brakeman/file_parser.rb +3 -2
  52. data/lib/brakeman/logger.rb +264 -0
  53. data/lib/brakeman/options.rb +0 -9
  54. data/lib/brakeman/parsers/rails_erubi.rb +82 -0
  55. data/lib/brakeman/parsers/template_parser.rb +7 -15
  56. data/lib/brakeman/processor.rb +2 -2
  57. data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
  58. data/lib/brakeman/processors/controller_processor.rb +3 -3
  59. data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
  60. data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
  61. data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
  62. data/lib/brakeman/processors/lib/render_helper.rb +1 -1
  63. data/lib/brakeman/processors/lib/render_path.rb +1 -1
  64. data/lib/brakeman/processors/model_processor.rb +1 -1
  65. data/lib/brakeman/report/ignore/config.rb +1 -1
  66. data/lib/brakeman/scanner.rb +25 -49
  67. data/lib/brakeman/tracker/collection.rb +12 -2
  68. data/lib/brakeman/tracker/config.rb +17 -13
  69. data/lib/brakeman/tracker/constants.rb +17 -2
  70. data/lib/brakeman/tracker/controller.rb +1 -1
  71. data/lib/brakeman/tracker.rb +7 -15
  72. data/lib/brakeman/version.rb +1 -1
  73. data/lib/brakeman.rb +89 -49
  74. metadata +51 -80
  75. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
  76. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
  77. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
  78. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
  79. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
  80. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
  81. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
  82. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
  83. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
  84. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
  85. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
  86. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
  87. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
  88. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
  89. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
  90. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
  91. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
  92. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
  93. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
  94. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
  95. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
  96. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
  97. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
  98. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
  99. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
  100. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
  101. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
  102. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
  103. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
  104. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
  105. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
  106. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
  107. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
  108. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
  109. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
  110. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
  111. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
  112. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
  113. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
  114. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
  115. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
  116. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
  117. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
  118. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
  119. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
  120. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
  121. data/lib/brakeman/parsers/erubis_patch.rb +0 -11
  122. data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
  123. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
  124. data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
  125. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/COPYING +0 -0
  126. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_emacs_org.rb +0 -0
  127. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_handlebars.rb +0 -0
  128. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_jbuilder.rb +0 -0
  129. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_org.rb +0 -0
  130. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/cli.rb +0 -0
@@ -1,23 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- module Erubis
7
-
8
-
9
- ##
10
- ## base error class
11
- ##
12
- class ErubisError < StandardError
13
- end
14
-
15
-
16
- ##
17
- ## raised when method or function is not supported
18
- ##
19
- class NotSupportedError < ErubisError
20
- end
21
-
22
-
23
- end
@@ -1,88 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/error'
7
- require 'erubis/context'
8
-
9
-
10
- module Erubis
11
-
12
- EMPTY_BINDING = binding()
13
-
14
-
15
- ##
16
- ## evaluate code
17
- ##
18
- module Evaluator
19
-
20
- def self.supported_properties # :nodoc:
21
- return []
22
- end
23
-
24
- attr_accessor :src, :filename
25
-
26
- def init_evaluator(properties)
27
- @filename = properties[:filename]
28
- end
29
-
30
- def result(*args)
31
- raise NotSupportedError.new("evaluation of code except Ruby is not supported.")
32
- end
33
-
34
- def evaluate(*args)
35
- raise NotSupportedError.new("evaluation of code except Ruby is not supported.")
36
- end
37
-
38
- end
39
-
40
-
41
- ##
42
- ## evaluator for Ruby
43
- ##
44
- module RubyEvaluator
45
- include Evaluator
46
-
47
- def self.supported_properties # :nodoc:
48
- list = Evaluator.supported_properties
49
- return list
50
- end
51
-
52
- ## eval(@src) with binding object
53
- def result(_binding_or_hash=TOPLEVEL_BINDING)
54
- _arg = _binding_or_hash
55
- if _arg.is_a?(Hash)
56
- _b = binding()
57
- eval _arg.collect{|k,v| "#{k} = _arg[#{k.inspect}]; "}.join, _b
58
- elsif _arg.is_a?(Binding)
59
- _b = _arg
60
- elsif _arg.nil?
61
- _b = binding()
62
- else
63
- raise ArgumentError.new("#{self.class.name}#result(): argument should be Binding or Hash but passed #{_arg.class.name} object.")
64
- end
65
- return eval(@src, _b, (@filename || '(erubis'))
66
- end
67
-
68
- ## invoke context.instance_eval(@src)
69
- def evaluate(_context=Context.new)
70
- _context = Context.new(_context) if _context.is_a?(Hash)
71
- #return _context.instance_eval(@src, @filename || '(erubis)')
72
- #@_proc ||= eval("proc { #{@src} }", Erubis::EMPTY_BINDING, @filename || '(erubis)')
73
- @_proc ||= eval("proc { #{@src} }", binding(), @filename || '(erubis)')
74
- return _context.instance_eval(&@_proc)
75
- end
76
-
77
- ## if object is an Class or Module then define instance method to it,
78
- ## else define singleton method to it.
79
- def def_method(object, method_name, filename=nil)
80
- m = object.is_a?(Module) ? :module_eval : :instance_eval
81
- object.__send__(m, "def #{method_name}; #{@src}; end", filename || @filename || '(erubis)')
82
- end
83
-
84
-
85
- end
86
-
87
-
88
- end
@@ -1,85 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/util'
7
-
8
- module Erubis
9
-
10
-
11
- ##
12
- ## code generator, called by Converter module
13
- ##
14
- module Generator
15
-
16
- def self.supported_properties() # :nodoc:
17
- return [
18
- [:escapefunc, nil, "escape function name"],
19
- ]
20
- end
21
-
22
- attr_accessor :escapefunc
23
-
24
- def init_generator(properties={})
25
- @escapefunc = properties[:escapefunc]
26
- end
27
-
28
-
29
- ## (abstract) escape text string
30
- ##
31
- ## ex.
32
- ## def escape_text(text)
33
- ## return text.dump
34
- ## # or return "'" + text.gsub(/['\\]/, '\\\\\&') + "'"
35
- ## end
36
- def escape_text(text)
37
- not_implemented
38
- end
39
-
40
- ## return escaped expression code (ex. 'h(...)' or 'htmlspecialchars(...)')
41
- def escaped_expr(code)
42
- code.strip!
43
- return "#{@escapefunc}(#{code})"
44
- end
45
-
46
- ## (abstract) add @preamble to src
47
- def add_preamble(src)
48
- not_implemented
49
- end
50
-
51
- ## (abstract) add text string to src
52
- def add_text(src, text)
53
- not_implemented
54
- end
55
-
56
- ## (abstract) add statement code to src
57
- def add_stmt(src, code)
58
- not_implemented
59
- end
60
-
61
- ## (abstract) add expression literal code to src. this is called by add_expr().
62
- def add_expr_literal(src, code)
63
- not_implemented
64
- end
65
-
66
- ## (abstract) add escaped expression code to src. this is called by add_expr().
67
- def add_expr_escaped(src, code)
68
- not_implemented
69
- end
70
-
71
- ## (abstract) add expression code to src for debug. this is called by add_expr().
72
- def add_expr_debug(src, code)
73
- not_implemented
74
- end
75
-
76
- ## (abstract) add @postamble to src
77
- def add_postamble(src)
78
- not_implemented
79
- end
80
-
81
-
82
- end
83
-
84
-
85
- end
@@ -1,47 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
-
7
- module Erubis
8
-
9
- ##
10
- ## helper for xml
11
- ##
12
- module XmlHelper
13
-
14
- module_function
15
-
16
- ESCAPE_TABLE = {
17
- '&' => '&amp;',
18
- '<' => '&lt;',
19
- '>' => '&gt;',
20
- '"' => '&quot;',
21
- "'" => '&#039;',
22
- }
23
-
24
- def escape_xml(value)
25
- value.to_s.gsub(/[&<>"]/) { |s| ESCAPE_TABLE[s] } # or /[&<>"']/
26
- #value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }
27
- end
28
-
29
- def escape_xml2(value)
30
- return value.to_s.gsub(/\&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;').gsub(/"/,'&quot;')
31
- end
32
-
33
- alias h escape_xml
34
- alias html_escape escape_xml
35
-
36
- def url_encode(str)
37
- return str.gsub(/[^-_.a-zA-Z0-9]+/) { |s|
38
- s.unpack('C*').collect { |i| "%%%02X" % i }.join
39
- }
40
- end
41
-
42
- alias u url_encode
43
-
44
- end
45
-
46
-
47
- end
@@ -1,197 +0,0 @@
1
- ###
2
- ### $Release: 2.7.0 $
3
- ### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ###
5
-
6
-
7
- module Erubis
8
- module Helpers
9
- module RailsFormHelper
10
- end
11
- end
12
- end
13
-
14
-
15
- module Erubis::Helpers::RailsFormHelper
16
-
17
-
18
- if ActionPack::VERSION::MAJOR == 1 ### Rails 1.X
19
- def pp_template_filename(basename)
20
- return "#{RAILS_ROOT}/app/views/#{controller.controller_name}/#{basename}.rhtml"
21
- end
22
- else ### Rails 2.X
23
- def pp_template_filename(basename)
24
- fname = "#{RAILS_ROOT}/app/views/#{controller.controller_name}/#{basename}.html.erb"
25
- return fname if test(?f, fname)
26
- return "#{RAILS_ROOT}/app/views/#{controller.controller_name}/#{basename}.rhtml"
27
- end
28
- end
29
-
30
- def pp_render_partial(basename)
31
- basename = "_#{basename}" unless basename[0] == ?_
32
- filename = pp_template_filename(basename)
33
- preprocessor = _create_preprocessor(File.read(filename))
34
- return preprocessor.evaluate(_preprocessing_context_object())
35
- end
36
-
37
- def pp_error_on(object_name, method)
38
- s = ''
39
- s << "<% _stag, _etag = _pp_error_tags(@#{object_name}.errors.on('#{method}')) %>"
40
- s << "<%= _stag %>"
41
- s << yield(object_name, method)
42
- s << "<%= _etag %>"
43
- return s
44
- end
45
-
46
- def _pp_error_tags(value)
47
- return value ? ['<div class="fieldWithErrors">', '</div>'] : ['', '']
48
- end
49
-
50
- def _pp_remove_error_div(s)
51
- s.sub!(/\A<div class="fieldWithErrors">(.*)<\/div>\z/, '\1')
52
- return s
53
- end
54
-
55
- def pp_tag_helper(helper, object_name, method, options={})
56
- if object_name.is_a?(ActionView::Helpers::FormHelper)
57
- object_name = object_name.object_name
58
- end
59
- unless options.key?(:value) || options.key?('value')
60
- options['value'] = _?("h @#{object_name}.#{method}")
61
- end
62
- #$stderr.puts "*** debug: pp_tag_helper(): options=#{options.inspect}"
63
- return pp_error_on(object_name, method) {
64
- s = __send__(helper, object_name, method, options)
65
- _pp_remove_error_div(s)
66
- }
67
- end
68
-
69
- def pp_form_tag(url_for_options={}, options={}, *parameters_for_url, &block)
70
- return form_tag(url_for_options, options, *parameters_for_url, &block)
71
- end
72
-
73
- #--
74
- #def pp_form_for(object_name, *args, &block)
75
- # return form_for(object_name, *args, &block)
76
- #end
77
- #++
78
-
79
- def pp_text_field(object_name, method, options={})
80
- return pp_tag_helper(:text_field, object_name, method, options)
81
- end
82
-
83
- def pp_password_field(object_name, method, options={})
84
- return pp_tag_helper(:password_field, object_name, method, options)
85
- end
86
-
87
- def pp_hidden_field(object_name, method, options={})
88
- return pp_tag_helper(:hidden_field, object_name, method, options)
89
- end
90
-
91
- def pp_file_field(object_name, method, options={})
92
- return pp_tag_helper(:file_field, object_name, method, options)
93
- end
94
-
95
- def pp_text_area(object_name, method, options={})
96
- return pp_tag_helper(:text_area, object_name, method, options)
97
- end
98
-
99
- def pp_check_box(object_name, method, options={}, checked_value="1", unchecked_value="0")
100
- s = check_box(object_name, method, options, checked_value, unchecked_value)
101
- s.sub!(/\schecked=\"checked\"/, '')
102
- s.sub!(/type="checkbox"/, "\\&<%= _pp_check_box_checked?(@#{object_name}.#{method}, #{checked_value.inspect}) ? ' checked=\"checked\"' : '' %>")
103
- return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
104
- end
105
-
106
- def _pp_check_box_checked?(value, checked_value)
107
- return ActionView::Helpers::InstanceTag::check_box_checked?(value, checked_value)
108
- end
109
-
110
- def pp_radio_button(object_name, method, tag_value, options={})
111
- s = radio_button(object_name, method, tag_value, options)
112
- s.sub!(/\schecked=\"checked\"/, '')
113
- s.sub!(/type="radio"/, "\\&<%= _pp_radio_button_checked?(@#{object_name}.#{method}, #{tag_value.inspect}) ? ' checked=\"checked\"' : '' %>")
114
- return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
115
- end
116
-
117
- def _pp_radio_button_checked?(value, tag_value)
118
- return ActionView::Helpers::InstanceTag::radio_button_checked?(value, tag_value)
119
- end
120
-
121
- def _pp_select(object, method, collection, priority_collection, options={}, html_options={})
122
- return pp_error_on(object, method) do
123
- s = ""
124
- ## start tag
125
- s << "<select id=\"#{object}_#{method}\" name=\"#{object}[#{method}]\""
126
- for key, val in html_options:
127
- s << " #{key}=\"#{val}\""
128
- end
129
- s << ">\n"
130
- ## selected table
131
- key = options.key?(:value) ? :value : (options.key?('value') ? 'value' : nil)
132
- if key.nil? ; selected = "@#{object}.#{method}"
133
- elsif (val=options[key]).nil? ; selected = nil
134
- elsif val =~ /\A<%=(.*)%>\z/ ; selected = $1
135
- else ; selected = val.inspect
136
- end
137
- s << "<% _table = {#{selected}=>' selected=\"selected\"'} %>\n" if selected
138
- ## <option> tags
139
- if options[:include_blank] || options['include_blank']
140
- s << "<option value=\"\"></option>\n"
141
- end
142
- unless priority_collection.blank?
143
- _pp_select_options(s, priority_collection, selected, 'delete')
144
- s << "<option value=\"\">-------------</option>\n"
145
- end
146
- _pp_select_options(s, collection, selected, '[]')
147
- ## end tag
148
- s << "</select>"
149
- s
150
- end
151
- end
152
-
153
- def _pp_select_options(s, collection, selected, operator)
154
- for item in collection
155
- value, text = item.is_a?(Array) ? item : [item, item]
156
- if !selected
157
- t = ''
158
- elsif operator == 'delete'
159
- t = "<%= _table.delete(#{value.inspect}) %>"
160
- else
161
- t = "<%= _table[#{value.inspect}] %>"
162
- end
163
- s << "<option value=\"#{h value}\"#{t}>#{h text}</option>\n"
164
- end
165
- end
166
-
167
- def pp_select(object, method, collection, options={}, html_options={})
168
- return _pp_select(object, method, collection, nil, options, html_options)
169
- end
170
-
171
- def pp_collection_select(object, method, collection, value_method, text_method, options={}, html_options={})
172
- collection2 = collection.collect { |e|
173
- [e.__send__(value_method), e.__send__(text_method)]
174
- }
175
- return _pp_select(object, method, collection2, nil, options, html_options)
176
- end
177
-
178
- def pp_country_select(object, method, priority_countries=nil, options={}, html_options={})
179
- collection = ActionView::Helpers::FormOptionsHelper::COUNTRIES
180
- return _pp_select(object, method, collection, priority_countries, options, html_options)
181
- end
182
-
183
- def pp_time_zone_select(object, method, priority_zones=nil, options={}, html_options={})
184
- model = options[:model] || options['model'] || TimeZone
185
- collection = model.all.collect { |e| [e.name, e.to_s] }
186
- return _pp_select(object, method, collection, priority_zones, options, html_options)
187
- end
188
-
189
- def pp_submit_tag(value="Save changes", options={})
190
- return submit_tag(value, options)
191
- end
192
-
193
- def pp_image_submit_tag(source, options={})
194
- return image_submit_tag(source, options)
195
- end
196
-
197
- end