actionview 6.0.0.beta1 → 6.0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -3
- data/README.rdoc +3 -1
- data/lib/action_view.rb +2 -1
- data/lib/action_view/base.rb +107 -10
- data/lib/action_view/cache_expiry.rb +54 -0
- data/lib/action_view/context.rb +0 -5
- data/lib/action_view/digestor.rb +8 -17
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +5 -5
- data/lib/action_view/helpers/cache_helper.rb +5 -5
- data/lib/action_view/helpers/csp_helper.rb +4 -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/rendering_helper.rb +6 -4
- 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/layouts.rb +5 -5
- data/lib/action_view/lookup_context.rb +69 -27
- data/lib/action_view/path_set.rb +5 -10
- data/lib/action_view/railtie.rb +9 -4
- data/lib/action_view/renderer/abstract_renderer.rb +56 -3
- data/lib/action_view/renderer/partial_renderer.rb +66 -55
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +27 -20
- data/lib/action_view/renderer/renderer.rb +16 -4
- data/lib/action_view/renderer/streaming_template_renderer.rb +4 -4
- data/lib/action_view/renderer/template_renderer.rb +24 -18
- data/lib/action_view/rendering.rb +46 -27
- data/lib/action_view/template.rb +84 -69
- data/lib/action_view/template/error.rb +21 -1
- data/lib/action_view/template/handlers.rb +27 -1
- data/lib/action_view/template/handlers/builder.rb +2 -2
- data/lib/action_view/template/handlers/erb.rb +5 -5
- data/lib/action_view/template/handlers/erb/erubi.rb +7 -3
- data/lib/action_view/template/handlers/html.rb +1 -1
- data/lib/action_view/template/handlers/raw.rb +2 -2
- data/lib/action_view/template/html.rb +14 -5
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +28 -0
- data/lib/action_view/template/resolver.rb +80 -117
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/text.rb +5 -3
- data/lib/action_view/testing/resolvers.rb +33 -20
- data/lib/action_view/unbound_template.rb +32 -0
- data/lib/action_view/view_paths.rb +25 -1
- data/lib/assets/compiled/rails-ujs.js +21 -12
- metadata +25 -16
@@ -8,7 +8,6 @@ module ActionView #:nodoc:
|
|
8
8
|
|
9
9
|
def initialize(string)
|
10
10
|
@string = string.to_s
|
11
|
-
@type = Types[:text]
|
12
11
|
end
|
13
12
|
|
14
13
|
def identifier
|
@@ -25,9 +24,12 @@ module ActionView #:nodoc:
|
|
25
24
|
to_str
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
29
|
-
|
27
|
+
def format
|
28
|
+
:text
|
30
29
|
end
|
30
|
+
|
31
|
+
def formats; Array(format); end
|
32
|
+
deprecate :formats
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -7,12 +7,19 @@ module ActionView #:nodoc:
|
|
7
7
|
# file system. This is used internally by Rails' own test suite, and is
|
8
8
|
# useful for testing extensions that have no way of knowing what the file
|
9
9
|
# system will look like at runtime.
|
10
|
-
class FixtureResolver <
|
11
|
-
attr_reader :hash
|
12
|
-
|
10
|
+
class FixtureResolver < OptimizedFileSystemResolver
|
13
11
|
def initialize(hash = {}, pattern = nil)
|
14
|
-
super(
|
12
|
+
super("")
|
13
|
+
if pattern
|
14
|
+
ActiveSupport::Deprecation.warn "Specifying a custom path for #{self.class} is deprecated. Implement a custom Resolver subclass instead."
|
15
|
+
@pattern = pattern
|
16
|
+
end
|
15
17
|
@hash = hash
|
18
|
+
@path = ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def data
|
22
|
+
@hash
|
16
23
|
end
|
17
24
|
|
18
25
|
def to_s
|
@@ -21,34 +28,40 @@ module ActionView #:nodoc:
|
|
21
28
|
|
22
29
|
private
|
23
30
|
|
24
|
-
def query(path, exts, _,
|
25
|
-
|
26
|
-
EXTENSIONS.each_key do |ext|
|
27
|
-
query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)"
|
28
|
-
end
|
29
|
-
query = /^(#{Regexp.escape(path)})#{query}$/
|
31
|
+
def query(path, exts, _, locals, cache:)
|
32
|
+
regex = build_regex(path, exts)
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
next unless query.match?(_path)
|
34
|
+
@hash.select do |_path, _|
|
35
|
+
("/" + _path).match?(regex)
|
36
|
+
end.map do |_path, source|
|
35
37
|
handler, format, variant = extract_handler_and_format_and_variant(_path)
|
36
|
-
|
38
|
+
|
39
|
+
Template.new(source, _path, handler,
|
37
40
|
virtual_path: path.virtual,
|
38
41
|
format: format,
|
39
42
|
variant: variant,
|
40
|
-
|
43
|
+
locals: locals
|
41
44
|
)
|
45
|
+
end.sort_by do |t|
|
46
|
+
match = ("/" + t.identifier).match(regex)
|
47
|
+
EXTENSIONS.keys.reverse.map do |ext|
|
48
|
+
if ext == :variants && exts[ext] == :any
|
49
|
+
match[ext].nil? ? 0 : 1
|
50
|
+
elsif match[ext].nil?
|
51
|
+
exts[ext].length
|
52
|
+
else
|
53
|
+
found = match[ext].to_sym
|
54
|
+
exts[ext].index(found)
|
55
|
+
end
|
56
|
+
end
|
42
57
|
end
|
43
|
-
|
44
|
-
templates.sort_by { |t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
|
45
58
|
end
|
46
59
|
end
|
47
60
|
|
48
61
|
class NullResolver < PathResolver
|
49
|
-
def query(path, exts, _,
|
62
|
+
def query(path, exts, _, locals, cache:)
|
50
63
|
handler, format, variant = extract_handler_and_format_and_variant(path)
|
51
|
-
[ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)]
|
64
|
+
[ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
|
52
65
|
end
|
53
66
|
end
|
54
67
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "concurrent/map"
|
4
|
+
|
5
|
+
module ActionView
|
6
|
+
class UnboundTemplate
|
7
|
+
def initialize(source, identifer, handler, options)
|
8
|
+
@source = source
|
9
|
+
@identifer = identifer
|
10
|
+
@handler = handler
|
11
|
+
@options = options
|
12
|
+
|
13
|
+
@templates = Concurrent::Map.new(initial_capacity: 2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def bind_locals(locals)
|
17
|
+
@templates[locals] ||= build_template(locals)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def build_template(locals)
|
23
|
+
options = @options.merge(locals: locals)
|
24
|
+
Template.new(
|
25
|
+
@source,
|
26
|
+
@identifer,
|
27
|
+
@handler,
|
28
|
+
options
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -5,13 +5,21 @@ module ActionView
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
8
|
+
ViewPaths.set_view_paths(self, ActionView::PathSet.new.freeze)
|
9
9
|
end
|
10
10
|
|
11
11
|
delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=,
|
12
12
|
:locale, :locale=, to: :lookup_context
|
13
13
|
|
14
14
|
module ClassMethods
|
15
|
+
def _view_paths
|
16
|
+
ViewPaths.get_view_paths(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def _view_paths=(paths)
|
20
|
+
ViewPaths.set_view_paths(self, paths)
|
21
|
+
end
|
22
|
+
|
15
23
|
def _prefixes # :nodoc:
|
16
24
|
@_prefixes ||= begin
|
17
25
|
return local_prefixes if superclass.abstract?
|
@@ -29,6 +37,22 @@ module ActionView
|
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
40
|
+
# :stopdoc:
|
41
|
+
@all_view_paths = {}
|
42
|
+
|
43
|
+
def self.get_view_paths(klass)
|
44
|
+
@all_view_paths[klass] || get_view_paths(klass.superclass)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.set_view_paths(klass, paths)
|
48
|
+
@all_view_paths[klass] = paths
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.all_view_paths
|
52
|
+
@all_view_paths.values.uniq
|
53
|
+
end
|
54
|
+
# :startdoc:
|
55
|
+
|
32
56
|
# The prefixes used in render "foo" shortcuts.
|
33
57
|
def _prefixes # :nodoc:
|
34
58
|
self.class._prefixes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Unobtrusive JavaScript
|
3
3
|
https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts
|
4
4
|
Released under the MIT license
|
5
|
-
|
5
|
+
*/;
|
6
6
|
|
7
7
|
(function() {
|
8
8
|
var context = this;
|
@@ -32,12 +32,17 @@ Released under the MIT license
|
|
32
32
|
|
33
33
|
(function() {
|
34
34
|
(function() {
|
35
|
-
var
|
35
|
+
var nonce;
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
nonce = null;
|
38
|
+
|
39
|
+
Rails.loadCSPNonce = function() {
|
40
|
+
var ref;
|
41
|
+
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
|
42
|
+
};
|
43
|
+
|
44
|
+
Rails.cspNonce = function() {
|
45
|
+
return nonce != null ? nonce : Rails.loadCSPNonce();
|
41
46
|
};
|
42
47
|
|
43
48
|
}).call(this);
|
@@ -265,7 +270,7 @@ Released under the MIT license
|
|
265
270
|
script.setAttribute('nonce', cspNonce());
|
266
271
|
script.text = response;
|
267
272
|
document.head.appendChild(script).parentNode.removeChild(script);
|
268
|
-
} else if (type.match(/\
|
273
|
+
} else if (type.match(/\b(xml|html|svg)\b/)) {
|
269
274
|
parser = new DOMParser();
|
270
275
|
type = type.replace(/;.+/, '');
|
271
276
|
try {
|
@@ -315,6 +320,9 @@ Released under the MIT license
|
|
315
320
|
if (!input.name || input.disabled) {
|
316
321
|
return;
|
317
322
|
}
|
323
|
+
if (matches(input, 'fieldset[disabled] *')) {
|
324
|
+
return;
|
325
|
+
}
|
318
326
|
if (matches(input, 'select')) {
|
319
327
|
return toArray(input.options).forEach(function(option) {
|
320
328
|
if (option.selected) {
|
@@ -640,23 +648,23 @@ Released under the MIT license
|
|
640
648
|
};
|
641
649
|
|
642
650
|
Rails.preventInsignificantClick = function(e) {
|
643
|
-
var data, insignificantMetaClick, link, metaClick, method,
|
651
|
+
var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick;
|
644
652
|
link = this;
|
645
653
|
method = (link.getAttribute('data-method') || 'GET').toUpperCase();
|
646
654
|
data = link.getAttribute('data-params');
|
647
655
|
metaClick = e.metaKey || e.ctrlKey;
|
648
656
|
insignificantMetaClick = metaClick && method === 'GET' && !data;
|
649
|
-
|
650
|
-
if (
|
657
|
+
nonPrimaryMouseClick = (e.button != null) && e.button !== 0;
|
658
|
+
if (nonPrimaryMouseClick || insignificantMetaClick) {
|
651
659
|
return e.stopImmediatePropagation();
|
652
660
|
}
|
653
661
|
};
|
654
662
|
|
655
663
|
}).call(this);
|
656
664
|
(function() {
|
657
|
-
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, preventInsignificantClick, refreshCSRFTokens;
|
665
|
+
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
|
658
666
|
|
659
|
-
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, preventInsignificantClick = Rails.preventInsignificantClick, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMethod = Rails.handleMethod;
|
667
|
+
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, loadCSPNonce = Rails.loadCSPNonce, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, preventInsignificantClick = Rails.preventInsignificantClick, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMethod = Rails.handleMethod;
|
660
668
|
|
661
669
|
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null)) {
|
662
670
|
if (jQuery.rails) {
|
@@ -719,6 +727,7 @@ Released under the MIT license
|
|
719
727
|
delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
|
720
728
|
delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
|
721
729
|
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
|
730
|
+
document.addEventListener('DOMContentLoaded', loadCSPNonce);
|
722
731
|
return window._rails_loaded = true;
|
723
732
|
};
|
724
733
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.
|
19
|
+
version: 6.0.1.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.0.
|
26
|
+
version: 6.0.1.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,20 +58,20 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.1'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.0
|
64
|
+
version: 1.2.0
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '1.
|
71
|
+
version: '1.1'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.0
|
74
|
+
version: 1.2.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rails-dom-testing
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,28 +92,28 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - '='
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 6.0.
|
95
|
+
version: 6.0.1.rc1
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 6.0.
|
102
|
+
version: 6.0.1.rc1
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: activemodel
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 6.0.
|
109
|
+
version: 6.0.1.rc1
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 6.0.
|
116
|
+
version: 6.0.1.rc1
|
117
117
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
118
118
|
email: david@loudthinking.com
|
119
119
|
executables: []
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/action_view.rb
|
127
127
|
- lib/action_view/base.rb
|
128
128
|
- lib/action_view/buffers.rb
|
129
|
+
- lib/action_view/cache_expiry.rb
|
129
130
|
- lib/action_view/context.rb
|
130
131
|
- lib/action_view/dependency_tracker.rb
|
131
132
|
- lib/action_view/digestor.rb
|
@@ -217,20 +218,28 @@ files:
|
|
217
218
|
- lib/action_view/template/handlers/html.rb
|
218
219
|
- lib/action_view/template/handlers/raw.rb
|
219
220
|
- lib/action_view/template/html.rb
|
221
|
+
- lib/action_view/template/inline.rb
|
222
|
+
- lib/action_view/template/raw_file.rb
|
220
223
|
- lib/action_view/template/resolver.rb
|
224
|
+
- lib/action_view/template/sources.rb
|
225
|
+
- lib/action_view/template/sources/file.rb
|
221
226
|
- lib/action_view/template/text.rb
|
222
227
|
- lib/action_view/template/types.rb
|
223
228
|
- lib/action_view/test_case.rb
|
224
229
|
- lib/action_view/testing/resolvers.rb
|
230
|
+
- lib/action_view/unbound_template.rb
|
225
231
|
- lib/action_view/version.rb
|
226
232
|
- lib/action_view/view_paths.rb
|
227
233
|
- lib/assets/compiled/rails-ujs.js
|
228
|
-
homepage:
|
234
|
+
homepage: https://rubyonrails.org
|
229
235
|
licenses:
|
230
236
|
- MIT
|
231
237
|
metadata:
|
232
|
-
|
233
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
238
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
239
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/actionview/CHANGELOG.md
|
240
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
|
241
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
|
242
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/actionview
|
234
243
|
post_install_message:
|
235
244
|
rdoc_options: []
|
236
245
|
require_paths:
|
@@ -247,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
256
|
version: 1.3.1
|
248
257
|
requirements:
|
249
258
|
- none
|
250
|
-
rubygems_version: 3.0.
|
259
|
+
rubygems_version: 3.0.3
|
251
260
|
signing_key:
|
252
261
|
specification_version: 4
|
253
262
|
summary: Rendering framework putting the V in MVC (part of Rails).
|