actionview 6.0.0.beta2 → 6.0.2.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -3
  3. data/README.rdoc +3 -1
  4. data/lib/action_view.rb +2 -1
  5. data/lib/action_view/base.rb +5 -5
  6. data/lib/action_view/cache_expiry.rb +54 -0
  7. data/lib/action_view/digestor.rb +5 -10
  8. data/lib/action_view/gem_version.rb +2 -2
  9. data/lib/action_view/helpers/form_helper.rb +2 -2
  10. data/lib/action_view/helpers/form_options_helper.rb +4 -3
  11. data/lib/action_view/helpers/form_tag_helper.rb +5 -2
  12. data/lib/action_view/helpers/output_safety_helper.rb +1 -1
  13. data/lib/action_view/helpers/sanitize_helper.rb +10 -16
  14. data/lib/action_view/helpers/tag_helper.rb +1 -1
  15. data/lib/action_view/helpers/tags/base.rb +1 -1
  16. data/lib/action_view/helpers/translation_helper.rb +3 -3
  17. data/lib/action_view/helpers/url_helper.rb +2 -2
  18. data/lib/action_view/layouts.rb +5 -1
  19. data/lib/action_view/lookup_context.rb +11 -4
  20. data/lib/action_view/path_set.rb +5 -10
  21. data/lib/action_view/railtie.rb +1 -1
  22. data/lib/action_view/renderer/partial_renderer.rb +0 -3
  23. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +20 -13
  24. data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
  25. data/lib/action_view/renderer/template_renderer.rb +9 -3
  26. data/lib/action_view/rendering.rb +3 -2
  27. data/lib/action_view/template.rb +43 -50
  28. data/lib/action_view/template/error.rb +21 -1
  29. data/lib/action_view/template/handlers.rb +3 -3
  30. data/lib/action_view/template/handlers/erb/erubi.rb +2 -2
  31. data/lib/action_view/template/raw_file.rb +28 -0
  32. data/lib/action_view/template/resolver.rb +73 -117
  33. data/lib/action_view/template/sources.rb +13 -0
  34. data/lib/action_view/template/sources/file.rb +17 -0
  35. data/lib/action_view/testing/resolvers.rb +32 -21
  36. data/lib/action_view/unbound_template.rb +32 -0
  37. data/lib/assets/compiled/rails-ujs.js +21 -12
  38. metadata +24 -17
  39. data/lib/action_view/file_template.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec7748334d455691ff0946d9ffffa3e6265a87b7fb0e9f070ed7b938f9764750
4
- data.tar.gz: 73d7bdba0ec98f9dd8224c2887d603c8860667981d96b0ef054d66c136374bf1
3
+ metadata.gz: 9ff46d348119a77c1e6947936002ff0724bb3349dd1dad21967d8f3419ed5818
4
+ data.tar.gz: 4c8f57531360eada7dad82431a53d07848c35b553fb36906ae29d3d73bc869f6
5
5
  SHA512:
6
- metadata.gz: '0282f9151c08198bb8e1e3cf3d2e2d6eccf17813c4069c0468003e2abf417ebba04cc6a6fb94ddf490900663561759adbfb74b83a7144641a274caeec33e66ec'
7
- data.tar.gz: 499a7436942dc63ad515def9e709524fd1d87b26d0e3078ec97abf625134ccd43466dbb22501b079d4383b94bdb1dd997301582e426d179cd872266cec5a2730
6
+ metadata.gz: 74621a379a56ca0787af8f83d539fa827b3e7fdf61e4c69d7c7b0830e2e0985f55bbe82e3aaa3c126a50975487e556dd6b5df0c92a4d32d0ccb494195a67658d
7
+ data.tar.gz: e7d826c10a594aa9c5b107f6de93a52969081ba5e7b6ab99815c9241de0b27251df69a2d8d96bd49246cc3929d6468aea8c4d99f7b6447172886f2f77d6653d1
@@ -1,20 +1,97 @@
1
+ ## Rails 6.0.2.rc1 (November 27, 2019) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.0.1 (November 5, 2019) ##
7
+
8
+ * UJS avoids `Element.closest()` for IE 9 compatibility.
9
+
10
+ *George Claghorn*
11
+
12
+
13
+ ## Rails 6.0.0 (August 16, 2019) ##
14
+
15
+ * ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.
16
+
17
+ *Juanito Fatas*
18
+
19
+
20
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
21
+
22
+ * Fix `select_tag` so that it doesn't change `options` when `include_blank` is present.
23
+
24
+ *Younes SERRAJ*
25
+
26
+
27
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
28
+
29
+ * Fix partial caching skips same item issue
30
+
31
+ If we render cached collection partials with repeated items, those repeated items
32
+ will get skipped. For example, if you have 5 identical items in your collection, Rails
33
+ only renders the first one when `cached` is set to true. But it should render all
34
+ 5 items instead.
35
+
36
+ Fixes #35114.
37
+
38
+ *Stan Lo*
39
+
40
+ * Only clear ActionView cache in development on file changes
41
+
42
+ To speed up development mode, view caches are only cleared when files in
43
+ the view paths have changed. Applications which have implemented custom
44
+ `ActionView::Resolver` subclasses may need to add their own cache clearing.
45
+
46
+ *John Hawthorn*
47
+
48
+ * Fix `ActionView::FixtureResolver` so that it handles template variants correctly.
49
+
50
+ *Edward Rudd*
51
+
52
+ * `ActionView::TemplateRender.render(file: )` now renders the file directly,
53
+ without using any handlers, using the new `Template::RawFile` class.
54
+
55
+ *John Hawthorn*, *Cliff Pruitt*
56
+
57
+
58
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
59
+
60
+ * Only accept formats from registered mime types
61
+
62
+ A lack of filtering on mime types could allow an attacker to read
63
+ arbitrary files on the target server or to perform a denial of service
64
+ attack.
65
+
66
+ Fixes CVE-2019-5418
67
+ Fixes CVE-2019-5419
68
+
69
+ *John Hawthorn*, *Eileen M. Uchitelle*, *Aaron Patterson*
70
+
71
+
1
72
  ## Rails 6.0.0.beta2 (February 25, 2019) ##
2
73
 
3
- * ActionView::Template.finalize_compiled_template_methods is deprecated with
74
+ * `ActionView::Template.finalize_compiled_template_methods` is deprecated with
4
75
  no replacement.
5
76
 
6
77
  *tenderlove*
7
78
 
8
- * config.action_view.finalize_compiled_template_methods is deprecated with
79
+ * `config.action_view.finalize_compiled_template_methods` is deprecated with
9
80
  no replacement.
10
81
 
11
82
  *tenderlove*
12
83
 
13
84
  * Ensure unique DOM IDs for collection inputs with float values.
14
- Fixes #34974
85
+
86
+ Fixes #34974.
15
87
 
16
88
  *Mark Edmondson*
17
89
 
90
+ * Single arity template handlers are deprecated. Template handlers must
91
+ now accept two parameters, the view object and the source for the view object.
92
+
93
+ *tenderlove*
94
+
18
95
 
19
96
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
20
97
 
@@ -5,6 +5,8 @@ view helpers that assist when building HTML forms, Atom feeds and more.
5
5
  Template formats that Action View handles are ERB (embedded Ruby, typically
6
6
  used to inline short Ruby snippets inside HTML), and XML Builder.
7
7
 
8
+ You can read more about Action View in the {Action View Overview}[https://edgeguides.rubyonrails.org/action_view_overview.html] guide.
9
+
8
10
  == Download and installation
9
11
 
10
12
  The latest version of Action View can be installed with RubyGems:
@@ -27,7 +29,7 @@ Action View is released under the MIT license:
27
29
 
28
30
  API documentation is at
29
31
 
30
- * http://api.rubyonrails.org
32
+ * https://api.rubyonrails.org
31
33
 
32
34
  Bug reports for the Ruby on Rails project can be filed here:
33
35
 
@@ -44,7 +44,7 @@ module ActionView
44
44
  autoload :Rendering
45
45
  autoload :RoutingUrlFor
46
46
  autoload :Template
47
- autoload :FileTemplate
47
+ autoload :UnboundTemplate
48
48
  autoload :ViewPaths
49
49
 
50
50
  autoload_under "renderer" do
@@ -81,6 +81,7 @@ module ActionView
81
81
  end
82
82
  end
83
83
 
84
+ autoload :CacheExpiry
84
85
  autoload :TestCase
85
86
 
86
87
  def self.eager_load!
@@ -242,7 +242,7 @@ module ActionView #:nodoc:
242
242
  @_config = ActiveSupport::InheritableOptions.new
243
243
 
244
244
  unless formats == NULL
245
- ActiveSupport::Deprecation.warn <<~eowarn
245
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
246
246
  Passing formats to ActionView::Base.new is deprecated
247
247
  eowarn
248
248
  end
@@ -251,7 +251,7 @@ module ActionView #:nodoc:
251
251
  when ActionView::LookupContext
252
252
  @lookup_context = lookup_context
253
253
  else
254
- ActiveSupport::Deprecation.warn <<~eowarn
254
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
255
255
  ActionView::Base instances should be constructed with a lookup context,
256
256
  assignments, and a controller.
257
257
  eowarn
@@ -267,7 +267,7 @@ module ActionView #:nodoc:
267
267
  _prepare_context
268
268
  end
269
269
 
270
- def run(method, template, locals, buffer, &block)
270
+ def _run(method, template, locals, buffer, &block)
271
271
  _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
272
272
  @current_template = template
273
273
  @output_buffer = buffer
@@ -278,10 +278,10 @@ module ActionView #:nodoc:
278
278
 
279
279
  def compiled_method_container
280
280
  if self.class == ActionView::Base
281
- ActiveSupport::Deprecation.warn <<~eowarn
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
 
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class CacheExpiry
5
+ class Executor
6
+ def initialize(watcher:)
7
+ @cache_expiry = CacheExpiry.new(watcher: watcher)
8
+ end
9
+
10
+ def before(target)
11
+ @cache_expiry.clear_cache_if_necessary
12
+ end
13
+ end
14
+
15
+ def initialize(watcher:)
16
+ @watched_dirs = nil
17
+ @watcher_class = watcher
18
+ @watcher = nil
19
+ @mutex = Mutex.new
20
+ end
21
+
22
+ def clear_cache_if_necessary
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
35
+ end
36
+ end
37
+ end
38
+
39
+ def clear_cache
40
+ ActionView::LookupContext::DetailsKey.clear
41
+ end
42
+
43
+ private
44
+
45
+ def dirs_to_watch
46
+ fs_paths = all_view_paths.grep(FileSystemResolver)
47
+ fs_paths.map(&:path).sort.uniq
48
+ end
49
+
50
+ def all_view_paths
51
+ ActionView::ViewPaths.all_view_paths.flat_map(&:paths)
52
+ end
53
+ end
54
+ end
@@ -6,19 +6,14 @@ module ActionView
6
6
  class Digestor
7
7
  @@digest_mutex = Mutex.new
8
8
 
9
- module PerExecutionDigestCacheExpiry
10
- def self.before(target)
11
- ActionView::LookupContext::DetailsKey.clear
12
- end
13
- end
14
-
15
9
  class << self
16
10
  # Supported options:
17
11
  #
18
- # * <tt>name</tt> - Template name
19
- # * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt>
20
- # * <tt>dependencies</tt> - An array of dependent views
21
- 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)
22
17
  if dependencies.nil? || dependencies.empty?
23
18
  cache_key = "#{name}.#{format}"
24
19
  else
@@ -9,8 +9,8 @@ module ActionView
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 0
13
- PRE = "beta2"
12
+ TINY = 2
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -739,7 +739,7 @@ module ActionView
739
739
  # def labelled_form_with(**options, &block)
740
740
  # form_with(**options.merge(builder: LabellingFormBuilder), &block)
741
741
  # end
742
- def form_with(model: nil, scope: nil, url: nil, format: nil, **options)
742
+ def form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block)
743
743
  options[:allow_method_names_outside_object] = true
744
744
  options[:skip_default_ids] = !form_with_generates_ids
745
745
 
@@ -752,7 +752,7 @@ module ActionView
752
752
 
753
753
  if block_given?
754
754
  builder = instantiate_builder(scope, model, options)
755
- output = capture(builder, &Proc.new)
755
+ output = capture(builder, &block)
756
756
  options[:multipart] ||= builder.multipart?
757
757
 
758
758
  html_options = html_options_for_form_with(url, model, options)
@@ -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.
@@ -24,7 +24,7 @@ module ActionView
24
24
 
25
25
  mattr_accessor :default_enforce_utf8, default: true
26
26
 
27
- # Starts a form tag that points the action to a url configured with <tt>url_for_options</tt> just like
27
+ # Starts a form tag that points the action to a URL configured with <tt>url_for_options</tt> just like
28
28
  # ActionController::Base#url_for. The method for the form defaults to POST.
29
29
  #
30
30
  # ==== Options
@@ -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
@@ -38,7 +38,7 @@ module ActionView #:nodoc:
38
38
 
39
39
  # Converts the array to a comma-separated sentence where the last element is
40
40
  # joined by the connector word. This is the html_safe-aware version of
41
- # ActiveSupport's {Array#to_sentence}[http://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
41
+ # ActiveSupport's {Array#to_sentence}[https://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
42
42
  #
43
43
  def to_sentence(array, options = {})
44
44
  options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
@@ -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}")
@@ -138,7 +138,7 @@ module ActionView
138
138
  end
139
139
 
140
140
  def sanitized_value(value)
141
- value.to_s.gsub(/[\s\.]/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase.to_s
141
+ value.to_s.gsub(/[\s\.]/, "_").gsub(/[^-[[:word:]]]/, "").downcase
142
142
  end
143
143
 
144
144
  def select_content_tag(option_tags, options, html_options)