actionview 6.0.0.rc1 → 6.0.3.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -0
  3. data/README.rdoc +1 -1
  4. data/lib/action_view.rb +1 -0
  5. data/lib/action_view/base.rb +1 -1
  6. data/lib/action_view/cache_expiry.rb +13 -9
  7. data/lib/action_view/digestor.rb +5 -4
  8. data/lib/action_view/flows.rb +0 -1
  9. data/lib/action_view/gem_version.rb +1 -1
  10. data/lib/action_view/helpers/active_model_helper.rb +0 -1
  11. data/lib/action_view/helpers/asset_tag_helper.rb +1 -1
  12. data/lib/action_view/helpers/cache_helper.rb +1 -2
  13. data/lib/action_view/helpers/date_helper.rb +1 -2
  14. data/lib/action_view/helpers/form_helper.rb +2 -2
  15. data/lib/action_view/helpers/form_options_helper.rb +4 -3
  16. data/lib/action_view/helpers/form_tag_helper.rb +4 -1
  17. data/lib/action_view/helpers/javascript_helper.rb +4 -2
  18. data/lib/action_view/helpers/number_helper.rb +3 -2
  19. data/lib/action_view/helpers/sanitize_helper.rb +10 -16
  20. data/lib/action_view/helpers/tag_helper.rb +3 -3
  21. data/lib/action_view/helpers/tags/base.rb +0 -1
  22. data/lib/action_view/helpers/tags/check_box.rb +0 -1
  23. data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -1
  24. data/lib/action_view/helpers/tags/collection_helpers.rb +0 -1
  25. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -1
  26. data/lib/action_view/helpers/tags/color_field.rb +0 -1
  27. data/lib/action_view/helpers/tags/date_field.rb +0 -1
  28. data/lib/action_view/helpers/tags/date_select.rb +0 -1
  29. data/lib/action_view/helpers/tags/datetime_field.rb +0 -1
  30. data/lib/action_view/helpers/tags/datetime_local_field.rb +0 -1
  31. data/lib/action_view/helpers/tags/label.rb +0 -1
  32. data/lib/action_view/helpers/tags/month_field.rb +0 -1
  33. data/lib/action_view/helpers/tags/radio_button.rb +0 -1
  34. data/lib/action_view/helpers/tags/select.rb +0 -1
  35. data/lib/action_view/helpers/tags/text_field.rb +0 -1
  36. data/lib/action_view/helpers/tags/time_field.rb +0 -1
  37. data/lib/action_view/helpers/tags/week_field.rb +0 -1
  38. data/lib/action_view/helpers/text_helper.rb +0 -1
  39. data/lib/action_view/helpers/translation_helper.rb +7 -8
  40. data/lib/action_view/helpers/url_helper.rb +1 -1
  41. data/lib/action_view/layouts.rb +0 -3
  42. data/lib/action_view/log_subscriber.rb +0 -1
  43. data/lib/action_view/lookup_context.rb +4 -3
  44. data/lib/action_view/path_set.rb +0 -1
  45. data/lib/action_view/record_identifier.rb +0 -1
  46. data/lib/action_view/renderer/abstract_renderer.rb +0 -1
  47. data/lib/action_view/renderer/partial_renderer.rb +0 -4
  48. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +1 -1
  49. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -2
  50. data/lib/action_view/renderer/template_renderer.rb +1 -2
  51. data/lib/action_view/rendering.rb +0 -1
  52. data/lib/action_view/template.rb +0 -1
  53. data/lib/action_view/template/error.rb +9 -14
  54. data/lib/action_view/template/handlers/erb.rb +0 -1
  55. data/lib/action_view/template/resolver.rb +1 -5
  56. data/lib/action_view/test_case.rb +2 -3
  57. data/lib/action_view/testing/resolvers.rb +25 -14
  58. data/lib/action_view/unbound_template.rb +1 -2
  59. data/lib/action_view/view_paths.rb +0 -1
  60. data/lib/assets/compiled/rails-ujs.js +7 -4
  61. metadata +18 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d46b0e667c524b53bbcfd7291119c3078c1bcef2f379077610f11efa75cb7bcd
4
- data.tar.gz: 3952ce8b418d28245b3ba4a0126435958facc728363abd50deb0e6b110556b65
3
+ metadata.gz: 8eafe5ec8eee9ac7ae7c2a412a01e25ecf75d6895cb3a0719b00585e5d9415f3
4
+ data.tar.gz: c643fd1d07cea723cb3d19e999b27d5946ec4b4eb278f15e1b952b7de120453d
5
5
  SHA512:
6
- metadata.gz: dfc23eddf6eeb31093fa017f53ebc46c5a115d1d0edbc3ab40747eb243d4516e99c74d5c6d497bcb9731a62ab224ecde5f62352b50f57ab384a9595ac6d2ae53
7
- data.tar.gz: d8abfa6ea6c991820b67fb389c629f6b49d09610c1d0821e009084e475649b6aef7a861c620960ef58b9efa0d4a0709b9606690f6b19557910c0fd3946130f5f
6
+ metadata.gz: 642b3a371281cae6d3d1d88f1761cf74b9ad562d7a8bbe0764aa5b1dd2d4c367bfb229cbc6ee9ebb60d235e44670b68451a72fd8563efe9c640faced6f8d9f5d
7
+ data.tar.gz: 82f51fe028a6ab597daa5ba942efabc3d23690c5479740a72f7cc21167e11c4de5463450a9030897c0c743fc9d29feeae8b46c9b0a359d2686f59ff2c9fe7482
@@ -1,3 +1,55 @@
1
+ ## Rails 6.0.3.rc1 (April 30, 2020) ##
2
+
3
+ * annotated_source_code returns an empty array so TemplateErrors without a
4
+ template in the backtrace are surfaced properly by DebugExceptions.
5
+
6
+ *Guilherme Mansur*, *Kasper Timm Hansen*
7
+
8
+ * Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
9
+
10
+ *Guilherme Mansur*, *Gannon McGibbon*
11
+
12
+
13
+ ## Rails 6.0.2.2 (March 19, 2020) ##
14
+
15
+ * Fix possible XSS vector in escape_javascript helper
16
+
17
+ CVE-2020-5267
18
+
19
+ *Aaron Patterson*
20
+
21
+
22
+ ## Rails 6.0.2.1 (December 18, 2019) ##
23
+
24
+ * No changes.
25
+
26
+
27
+ ## Rails 6.0.2 (December 13, 2019) ##
28
+
29
+ * No changes.
30
+
31
+
32
+ ## Rails 6.0.1 (November 5, 2019) ##
33
+
34
+ * UJS avoids `Element.closest()` for IE 9 compatibility.
35
+
36
+ *George Claghorn*
37
+
38
+
39
+ ## Rails 6.0.0 (August 16, 2019) ##
40
+
41
+ * ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
42
+
43
+ *Juanito Fatas*
44
+
45
+
46
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
47
+
48
+ * Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
49
+
50
+ *Younes SERRAJ*
51
+
52
+
1
53
  ## Rails 6.0.0.rc1 (April 24, 2019) ##
2
54
 
3
55
  * Fix partial caching skips same item issue
@@ -23,6 +75,11 @@
23
75
 
24
76
  *Edward Rudd*
25
77
 
78
+ * `ActionView::TemplateRender.render(file: )` now renders the file directly,
79
+ without using any handlers, using the new `Template::RawFile` class.
80
+
81
+ *John Hawthorn*, *Cliff Pruitt*
82
+
26
83
 
27
84
  ## Rails 6.0.0.beta3 (March 11, 2019) ##
28
85
 
@@ -56,6 +113,11 @@
56
113
 
57
114
  *Mark Edmondson*
58
115
 
116
+ * Single arity template handlers are deprecated. Template handlers must
117
+ now accept two parameters, the view object and the source for the view object.
118
+
119
+ *tenderlove*
120
+
59
121
 
60
122
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
61
123
 
@@ -37,4 +37,4 @@ Bug reports for the Ruby on Rails project can be filed here:
37
37
 
38
38
  Feature requests should be discussed on the rails-core mailing list here:
39
39
 
40
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
40
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -77,6 +77,7 @@ module ActionView
77
77
  autoload :ActionViewError
78
78
  autoload :EncodingError
79
79
  autoload :TemplateError
80
+ autoload :SyntaxErrorInTemplate
80
81
  autoload :WrongEncodingError
81
82
  end
82
83
  end
@@ -281,7 +281,7 @@ module ActionView #:nodoc:
281
281
  ActiveSupport::Deprecation.warn <<~eowarn.squish
282
282
  ActionView::Base instances must implement `compiled_method_container`
283
283
  or use the class method `with_empty_template_cache` for constructing
284
- an ActionView::Base instances that has an empty cache.
284
+ an ActionView::Base instance that has an empty cache.
285
285
  eowarn
286
286
  end
287
287
 
@@ -16,18 +16,23 @@ module ActionView
16
16
  @watched_dirs = nil
17
17
  @watcher_class = watcher
18
18
  @watcher = nil
19
+ @mutex = Mutex.new
19
20
  end
20
21
 
21
22
  def clear_cache_if_necessary
22
- watched_dirs = dirs_to_watch
23
- if watched_dirs != @watched_dirs
24
- @watched_dirs = watched_dirs
25
- @watcher = @watcher_class.new([], watched_dirs) do
26
- clear_cache
23
+ @mutex.synchronize do
24
+ watched_dirs = dirs_to_watch
25
+ return if watched_dirs.empty?
26
+
27
+ if watched_dirs != @watched_dirs
28
+ @watched_dirs = watched_dirs
29
+ @watcher = @watcher_class.new([], watched_dirs) do
30
+ clear_cache
31
+ end
32
+ @watcher.execute
33
+ else
34
+ @watcher.execute_if_updated
27
35
  end
28
- @watcher.execute
29
- else
30
- @watcher.execute_if_updated
31
36
  end
32
37
  end
33
38
 
@@ -36,7 +41,6 @@ module ActionView
36
41
  end
37
42
 
38
43
  private
39
-
40
44
  def dirs_to_watch
41
45
  fs_paths = all_view_paths.grep(FileSystemResolver)
42
46
  fs_paths.map(&:path).sort.uniq
@@ -9,10 +9,11 @@ module ActionView
9
9
  class << self
10
10
  # Supported options:
11
11
  #
12
- # * <tt>name</tt> - Template name
13
- # * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt>
14
- # * <tt>dependencies</tt> - An array of dependent views
15
- def digest(name:, format:, finder:, dependencies: nil)
12
+ # * <tt>name</tt> - Template name
13
+ # * <tt>format</tt> - Template format
14
+ # * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt>
15
+ # * <tt>dependencies</tt> - An array of dependent views
16
+ def digest(name:, format: nil, finder:, dependencies: nil)
16
17
  if dependencies.nil? || dependencies.empty?
17
18
  cache_key = "#{name}.#{format}"
18
19
  else
@@ -68,7 +68,6 @@ module ActionView
68
68
  end
69
69
 
70
70
  private
71
-
72
71
  def inside_fiber?
73
72
  Fiber.current.object_id != @root
74
73
  end
@@ -9,7 +9,7 @@ module ActionView
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 0
12
+ TINY = 3
13
13
  PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -38,7 +38,6 @@ module ActionView
38
38
  end
39
39
 
40
40
  private
41
-
42
41
  def object_has_errors?
43
42
  object.respond_to?(:errors) && object.errors.respond_to?(:[]) && error_message.present?
44
43
  end
@@ -274,7 +274,7 @@ module ActionView
274
274
  crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
275
275
  nopush = options.delete(:nopush) || false
276
276
 
277
- link_tag = tag.link({
277
+ link_tag = tag.link(**{
278
278
  rel: "preload",
279
279
  href: href,
280
280
  as: as_type,
@@ -166,7 +166,7 @@ module ActionView
166
166
  def cache(name = {}, options = {}, &block)
167
167
  if controller.respond_to?(:perform_caching) && controller.perform_caching
168
168
  name_options = options.slice(:skip_digest, :virtual_path)
169
- safe_concat(fragment_for(cache_fragment_name(name, name_options), options, &block))
169
+ safe_concat(fragment_for(cache_fragment_name(name, **name_options), options, &block))
170
170
  else
171
171
  yield
172
172
  end
@@ -227,7 +227,6 @@ module ActionView
227
227
  end
228
228
 
229
229
  private
230
-
231
230
  def fragment_name_with_digest(name, virtual_path, digest_path)
232
231
  virtual_path ||= @virtual_path
233
232
 
@@ -688,7 +688,6 @@ module ActionView
688
688
  end
689
689
 
690
690
  private
691
-
692
691
  def normalize_distance_of_time_argument_to_time(value)
693
692
  if value.is_a?(Numeric)
694
693
  Time.at(value)
@@ -831,7 +830,7 @@ module ActionView
831
830
  end
832
831
 
833
832
  def select_year
834
- if !@datetime || @datetime == 0
833
+ if !year || @datetime == 0
835
834
  val = "1"
836
835
  middle_year = Date.today.year
837
836
  else
@@ -755,10 +755,10 @@ module ActionView
755
755
  output = capture(builder, &block)
756
756
  options[:multipart] ||= builder.multipart?
757
757
 
758
- html_options = html_options_for_form_with(url, model, options)
758
+ html_options = html_options_for_form_with(url, model, **options)
759
759
  form_tag_with_body(html_options, output)
760
760
  else
761
- html_options = html_options_for_form_with(url, model, options)
761
+ html_options = html_options_for_form_with(url, model, **options)
762
762
  form_tag_html(html_options)
763
763
  end
764
764
  end
@@ -566,9 +566,10 @@ module ActionView
566
566
  # an ActiveSupport::TimeZone.
567
567
  #
568
568
  # By default, +model+ is the ActiveSupport::TimeZone constant (which can
569
- # be obtained in Active Record as a value object). The only requirement
570
- # is that the +model+ parameter be an object that responds to +all+, and
571
- # returns an array of objects that represent time zones.
569
+ # be obtained in Active Record as a value object). The +model+ parameter
570
+ # must respond to +all+ and return an array of objects that represent time
571
+ # zones; each object must respond to +name+. If a Regexp is given it will
572
+ # attempt to match the zones using the <code>=~<code> operator.
572
573
  #
573
574
  # NOTE: Only the option tags are returned, you have to wrap this call in
574
575
  # a regular HTML select tag.
@@ -137,7 +137,8 @@ module ActionView
137
137
  html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
138
138
 
139
139
  if options.include?(:include_blank)
140
- include_blank = options.delete(:include_blank)
140
+ include_blank = options[:include_blank]
141
+ options = options.except(:include_blank)
141
142
  options_for_blank_options_tag = { value: "" }
142
143
 
143
144
  if include_blank == true
@@ -165,6 +166,8 @@ module ActionView
165
166
  # * <tt>:size</tt> - The number of visible characters that will fit in the input.
166
167
  # * <tt>:maxlength</tt> - The maximum number of characters that the browser will allow the user to enter.
167
168
  # * <tt>:placeholder</tt> - The text contained in the field by default which is removed when the field receives focus.
169
+ # If set to true, use a translation is found in the current I18n locale
170
+ # (through helpers.placeholders.<modelname>.<attribute>).
168
171
  # * Any other key creates standard HTML attributes for the tag.
169
172
  #
170
173
  # ==== Examples
@@ -12,7 +12,9 @@ module ActionView
12
12
  "\n" => '\n',
13
13
  "\r" => '\n',
14
14
  '"' => '\\"',
15
- "'" => "\\'"
15
+ "'" => "\\'",
16
+ "`" => "\\`",
17
+ "$" => "\\$"
16
18
  }
17
19
 
18
20
  JS_ESCAPE_MAP[(+"\342\200\250").force_encoding(Encoding::UTF_8).encode!] = "&#x2028;"
@@ -29,7 +31,7 @@ module ActionView
29
31
  if javascript.empty?
30
32
  result = ""
31
33
  else
32
- result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] }
34
+ result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
33
35
  end
34
36
  javascript.html_safe? ? result.html_safe : result
35
37
  end
@@ -57,7 +57,7 @@ module ActionView
57
57
  #
58
58
  # number_to_phone(75561234567, pattern: /(\d{1,4})(\d{4})(\d{4})$/, area_code: true)
59
59
  # # => "(755) 6123-4567"
60
- # number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/))
60
+ # number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/)
61
61
  # # => "133-1234-5678"
62
62
  def number_to_phone(number, options = {})
63
63
  return unless number
@@ -114,6 +114,8 @@ module ActionView
114
114
  #
115
115
  # number_to_currency("123a456", raise: true) # => InvalidNumberError
116
116
  #
117
+ # number_to_currency(-0.456789, precision: 0)
118
+ # # => "$0"
117
119
  # number_to_currency(-1234567890.50, negative_format: "(%u%n)")
118
120
  # # => ($1,234,567,890.50)
119
121
  # number_to_currency(1234567890.50, unit: "R$", separator: ",", delimiter: "")
@@ -403,7 +405,6 @@ module ActionView
403
405
  end
404
406
 
405
407
  private
406
-
407
408
  def delegate_number_helper_method(method, number, options)
408
409
  return unless number
409
410
  options = escape_unsafe_options(options.symbolize_keys)
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/object/try"
4
3
  require "rails-html-sanitizer"
5
4
 
6
5
  module ActionView
@@ -17,7 +16,7 @@ module ActionView
17
16
  # ASCII, and hex character references to work around these protocol filters.
18
17
  # All special characters will be escaped.
19
18
  #
20
- # The default sanitizer is Rails::Html::WhiteListSanitizer. See {Rails HTML
19
+ # The default sanitizer is Rails::Html::SafeListSanitizer. See {Rails HTML
21
20
  # Sanitizers}[https://github.com/rails/rails-html-sanitizer] for more information.
22
21
  #
23
22
  # Custom sanitization rules can also be provided.
@@ -80,12 +79,12 @@ module ActionView
80
79
  # config.action_view.sanitized_allowed_tags = ['strong', 'em', 'a']
81
80
  # config.action_view.sanitized_allowed_attributes = ['href', 'title']
82
81
  def sanitize(html, options = {})
83
- self.class.white_list_sanitizer.sanitize(html, options).try(:html_safe)
82
+ self.class.safe_list_sanitizer.sanitize(html, options)&.html_safe
84
83
  end
85
84
 
86
85
  # Sanitizes a block of CSS code. Used by +sanitize+ when it comes across a style attribute.
87
86
  def sanitize_css(style)
88
- self.class.white_list_sanitizer.sanitize_css(style)
87
+ self.class.safe_list_sanitizer.sanitize_css(style)
89
88
  end
90
89
 
91
90
  # Strips all HTML tags from +html+, including comments and special characters.
@@ -123,20 +122,18 @@ module ActionView
123
122
  end
124
123
 
125
124
  module ClassMethods #:nodoc:
126
- attr_writer :full_sanitizer, :link_sanitizer, :white_list_sanitizer
125
+ attr_writer :full_sanitizer, :link_sanitizer, :safe_list_sanitizer
127
126
 
128
- # Vendors the full, link and white list sanitizers.
129
- # Provided strictly for compatibility and can be removed in Rails 6.
130
127
  def sanitizer_vendor
131
128
  Rails::Html::Sanitizer
132
129
  end
133
130
 
134
131
  def sanitized_allowed_tags
135
- sanitizer_vendor.white_list_sanitizer.allowed_tags
132
+ safe_list_sanitizer.allowed_tags
136
133
  end
137
134
 
138
135
  def sanitized_allowed_attributes
139
- sanitizer_vendor.white_list_sanitizer.allowed_attributes
136
+ safe_list_sanitizer.allowed_attributes
140
137
  end
141
138
 
142
139
  # Gets the Rails::Html::FullSanitizer instance used by +strip_tags+. Replace with
@@ -145,7 +142,6 @@ module ActionView
145
142
  # class Application < Rails::Application
146
143
  # config.action_view.full_sanitizer = MySpecialSanitizer.new
147
144
  # end
148
- #
149
145
  def full_sanitizer
150
146
  @full_sanitizer ||= sanitizer_vendor.full_sanitizer.new
151
147
  end
@@ -156,20 +152,18 @@ module ActionView
156
152
  # class Application < Rails::Application
157
153
  # config.action_view.link_sanitizer = MySpecialSanitizer.new
158
154
  # end
159
- #
160
155
  def link_sanitizer
161
156
  @link_sanitizer ||= sanitizer_vendor.link_sanitizer.new
162
157
  end
163
158
 
164
- # Gets the Rails::Html::WhiteListSanitizer instance used by sanitize and +sanitize_css+.
159
+ # Gets the Rails::Html::SafeListSanitizer instance used by sanitize and +sanitize_css+.
165
160
  # Replace with any object that responds to +sanitize+.
166
161
  #
167
162
  # class Application < Rails::Application
168
- # config.action_view.white_list_sanitizer = MySpecialSanitizer.new
163
+ # config.action_view.safe_list_sanitizer = MySpecialSanitizer.new
169
164
  # end
170
- #
171
- def white_list_sanitizer
172
- @white_list_sanitizer ||= sanitizer_vendor.white_list_sanitizer.new
165
+ def safe_list_sanitizer
166
+ @safe_list_sanitizer ||= sanitizer_vendor.safe_list_sanitizer.new
173
167
  end
174
168
  end
175
169
  end
@@ -88,7 +88,7 @@ module ActionView
88
88
  if value.is_a?(Array)
89
89
  value = escape ? safe_join(value, " ") : value.join(" ")
90
90
  else
91
- value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s.dup
91
+ value = escape ? ERB::Util.unwrapped_html_escape(value).dup : value.to_s.dup
92
92
  end
93
93
  value.gsub!('"', "&quot;")
94
94
  %(#{key}="#{value}")
@@ -107,8 +107,8 @@ module ActionView
107
107
  true
108
108
  end
109
109
 
110
- def method_missing(called, *args, &block)
111
- tag_string(called, *args, &block)
110
+ def method_missing(called, *args, **options, &block)
111
+ tag_string(called, *args, **options, &block)
112
112
  end
113
113
  end
114
114
 
@@ -34,7 +34,6 @@ module ActionView
34
34
  end
35
35
 
36
36
  private
37
-
38
37
  def value
39
38
  if @allow_method_names_outside_object
40
39
  object.public_send @method_name if object && object.respond_to?(@method_name)