actionview 6.0.0.beta3 → 6.0.2.rc2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -4
- data/README.rdoc +3 -1
- data/lib/action_view.rb +2 -1
- data/lib/action_view/base.rb +5 -5
- data/lib/action_view/cache_expiry.rb +54 -0
- data/lib/action_view/digestor.rb +5 -10
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/form_helper.rb +2 -2
- data/lib/action_view/helpers/form_options_helper.rb +4 -3
- data/lib/action_view/helpers/form_tag_helper.rb +5 -2
- data/lib/action_view/helpers/output_safety_helper.rb +1 -1
- data/lib/action_view/helpers/sanitize_helper.rb +10 -16
- data/lib/action_view/helpers/tag_helper.rb +1 -1
- data/lib/action_view/helpers/tags/base.rb +1 -1
- data/lib/action_view/helpers/translation_helper.rb +3 -3
- data/lib/action_view/helpers/url_helper.rb +2 -2
- data/lib/action_view/lookup_context.rb +11 -4
- data/lib/action_view/path_set.rb +5 -10
- data/lib/action_view/railtie.rb +1 -1
- data/lib/action_view/renderer/partial_renderer.rb +0 -3
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +20 -13
- data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
- data/lib/action_view/renderer/template_renderer.rb +9 -3
- data/lib/action_view/rendering.rb +3 -2
- data/lib/action_view/template.rb +43 -50
- data/lib/action_view/template/error.rb +21 -1
- data/lib/action_view/template/handlers.rb +3 -3
- data/lib/action_view/template/handlers/erb/erubi.rb +2 -2
- data/lib/action_view/template/raw_file.rb +28 -0
- data/lib/action_view/template/resolver.rb +73 -117
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/testing/resolvers.rb +32 -21
- data/lib/action_view/unbound_template.rb +32 -0
- data/lib/assets/compiled/rails-ujs.js +21 -12
- metadata +24 -17
- data/lib/action_view/file_template.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b9e2b2b5d1a868a3593ebc60878571965ad1f411290b005d3c3ac6c90510ac2
|
4
|
+
data.tar.gz: ac73ea080508fcc81c506f24a8fa18750483e47979e36c6f02d4b1287b6c4164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f2ae1fe3ed14903520edc86af2ae1ec91e3362412286031e2a6c2ca3a308d3da3501b95533087583e1a84648c20a4d1fc120c9a49bccb0af1a2a0c79b76a2f
|
7
|
+
data.tar.gz: 3625682c2d0a51783db023a6a06302d2d41403c43452092d26686c04c6cc882efd516de7c4e371bce8a88eb19b113677ef5eef8ea7f6396db75eda6e0e884aa8
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,97 @@
|
|
1
|
-
## Rails 6.0.
|
1
|
+
## Rails 6.0.2.rc2 (December 09, 2019) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
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
|
+
|
6
72
|
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
7
73
|
|
8
|
-
* ActionView::Template.finalize_compiled_template_methods is deprecated with
|
74
|
+
* `ActionView::Template.finalize_compiled_template_methods` is deprecated with
|
9
75
|
no replacement.
|
10
76
|
|
11
77
|
*tenderlove*
|
12
78
|
|
13
|
-
* config.action_view.finalize_compiled_template_methods is deprecated with
|
79
|
+
* `config.action_view.finalize_compiled_template_methods` is deprecated with
|
14
80
|
no replacement.
|
15
81
|
|
16
82
|
*tenderlove*
|
17
83
|
|
18
84
|
* Ensure unique DOM IDs for collection inputs with float values.
|
19
|
-
|
85
|
+
|
86
|
+
Fixes #34974.
|
20
87
|
|
21
88
|
*Mark Edmondson*
|
22
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
|
+
|
23
95
|
|
24
96
|
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
25
97
|
|
data/README.rdoc
CHANGED
@@ -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
|
-
*
|
32
|
+
* https://api.rubyonrails.org
|
31
33
|
|
32
34
|
Bug reports for the Ruby on Rails project can be filed here:
|
33
35
|
|
data/lib/action_view.rb
CHANGED
@@ -44,7 +44,7 @@ module ActionView
|
|
44
44
|
autoload :Rendering
|
45
45
|
autoload :RoutingUrlFor
|
46
46
|
autoload :Template
|
47
|
-
autoload :
|
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!
|
data/lib/action_view/base.rb
CHANGED
@@ -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
|
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
|
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
|
data/lib/action_view/digestor.rb
CHANGED
@@ -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>
|
19
|
-
# * <tt>
|
20
|
-
# * <tt>
|
21
|
-
|
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
|
@@ -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, &
|
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
|
570
|
-
#
|
571
|
-
#
|
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
|
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
|
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}[
|
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::
|
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.
|
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.
|
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, :
|
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
|
-
|
132
|
+
safe_list_sanitizer.allowed_tags
|
136
133
|
end
|
137
134
|
|
138
135
|
def sanitized_allowed_attributes
|
139
|
-
|
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::
|
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.
|
163
|
+
# config.action_view.safe_list_sanitizer = MySpecialSanitizer.new
|
169
164
|
# end
|
170
|
-
|
171
|
-
|
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!('"', """)
|
94
94
|
%(#{key}="#{value}")
|