actionview 6.0.0.beta3 → 6.0.0.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -4
  3. data/README.rdoc +3 -1
  4. data/lib/action_view.rb +2 -1
  5. data/lib/action_view/base.rb +4 -4
  6. data/lib/action_view/cache_expiry.rb +49 -0
  7. data/lib/action_view/digestor.rb +0 -6
  8. data/lib/action_view/gem_version.rb +1 -1
  9. data/lib/action_view/helpers/form_helper.rb +2 -2
  10. data/lib/action_view/helpers/form_tag_helper.rb +1 -1
  11. data/lib/action_view/helpers/output_safety_helper.rb +1 -1
  12. data/lib/action_view/helpers/tags/base.rb +1 -1
  13. data/lib/action_view/helpers/translation_helper.rb +2 -2
  14. data/lib/action_view/helpers/url_helper.rb +1 -1
  15. data/lib/action_view/lookup_context.rb +11 -4
  16. data/lib/action_view/path_set.rb +5 -10
  17. data/lib/action_view/railtie.rb +1 -1
  18. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +20 -13
  19. data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
  20. data/lib/action_view/renderer/template_renderer.rb +9 -3
  21. data/lib/action_view/rendering.rb +3 -2
  22. data/lib/action_view/template.rb +43 -50
  23. data/lib/action_view/template/error.rb +21 -1
  24. data/lib/action_view/template/handlers.rb +3 -3
  25. data/lib/action_view/template/handlers/erb/erubi.rb +2 -2
  26. data/lib/action_view/template/raw_file.rb +28 -0
  27. data/lib/action_view/template/resolver.rb +73 -117
  28. data/lib/action_view/template/sources.rb +13 -0
  29. data/lib/action_view/template/sources/file.rb +17 -0
  30. data/lib/action_view/testing/resolvers.rb +9 -10
  31. data/lib/action_view/unbound_template.rb +32 -0
  32. data/lib/assets/compiled/rails-ujs.js +14 -8
  33. metadata +16 -12
  34. data/lib/action_view/file_template.rb +0 -33
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ extend ActiveSupport::Autoload
7
+
8
+ eager_autoload do
9
+ autoload :File
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ class File
7
+ def initialize(filename)
8
+ @filename = filename
9
+ end
10
+
11
+ def to_s
12
+ ::File.binread @filename
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -23,23 +23,22 @@ module ActionView #:nodoc:
23
23
 
24
24
  private
25
25
 
26
- def query(path, exts, _, _)
26
+ def query(path, exts, _, locals, cache:)
27
27
  query = +""
28
- EXTENSIONS.each_key do |ext|
29
- query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)"
28
+ EXTENSIONS.each do |ext, prefix|
29
+ query << "(" << exts[ext].map { |e| e && Regexp.escape("#{prefix}#{e}") }.join("|") << "|)"
30
30
  end
31
31
  query = /^(#{Regexp.escape(path)})#{query}$/
32
32
 
33
33
  templates = []
34
- @hash.each do |_path, array|
35
- source, updated_at = array
34
+ @hash.each do |_path, source|
36
35
  next unless query.match?(_path)
37
- handler, format, variant = extract_handler_and_format_and_variant(_path, :html)
36
+ handler, format, variant = extract_handler_and_format_and_variant(_path)
38
37
  templates << Template.new(source, _path, handler,
39
38
  virtual_path: path.virtual,
40
39
  format: format,
41
40
  variant: variant,
42
- updated_at: updated_at
41
+ locals: locals
43
42
  )
44
43
  end
45
44
 
@@ -48,9 +47,9 @@ module ActionView #:nodoc:
48
47
  end
49
48
 
50
49
  class NullResolver < PathResolver
51
- def query(path, exts, _, _)
52
- handler, format, variant = extract_handler_and_format_and_variant(path, :html)
53
- [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)]
50
+ def query(path, exts, _, locals, cache:)
51
+ handler, format, variant = extract_handler_and_format_and_variant(path)
52
+ [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
54
53
  end
55
54
  end
56
55
  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
@@ -32,12 +32,17 @@ Released under the MIT license
32
32
 
33
33
  (function() {
34
34
  (function() {
35
- var cspNonce;
35
+ var nonce;
36
36
 
37
- cspNonce = Rails.cspNonce = function() {
38
- var meta;
39
- meta = document.querySelector('meta[name=csp-nonce]');
40
- return meta && meta.content;
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(/\bxml\b/)) {
273
+ } else if (type.match(/\b(xml|html|svg)\b/)) {
269
274
  parser = new DOMParser();
270
275
  type = type.replace(/;.+/, '');
271
276
  try {
@@ -654,9 +659,9 @@ Released under the MIT license
654
659
 
655
660
  }).call(this);
656
661
  (function() {
657
- var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, preventInsignificantClick, refreshCSRFTokens;
662
+ var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
658
663
 
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;
664
+ 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
665
 
661
666
  if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null)) {
662
667
  if (jQuery.rails) {
@@ -719,6 +724,7 @@ Released under the MIT license
719
724
  delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
720
725
  delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
721
726
  document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
727
+ document.addEventListener('DOMContentLoaded', loadCSPNonce);
722
728
  return window._rails_loaded = true;
723
729
  };
724
730
 
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.0.beta3
4
+ version: 6.0.0.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-03-13 00:00:00.000000000 Z
11
+ date: 2019-04-24 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.0.beta3
19
+ version: 6.0.0.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.0.beta3
26
+ version: 6.0.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  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.0.beta3
95
+ version: 6.0.0.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.0.beta3
102
+ version: 6.0.0.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.0.beta3
109
+ version: 6.0.0.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.0.beta3
116
+ version: 6.0.0.rc1
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -126,10 +126,10 @@ 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
132
- - lib/action_view/file_template.rb
133
133
  - lib/action_view/flows.rb
134
134
  - lib/action_view/gem_version.rb
135
135
  - lib/action_view/helpers.rb
@@ -219,20 +219,24 @@ files:
219
219
  - lib/action_view/template/handlers/raw.rb
220
220
  - lib/action_view/template/html.rb
221
221
  - lib/action_view/template/inline.rb
222
+ - lib/action_view/template/raw_file.rb
222
223
  - lib/action_view/template/resolver.rb
224
+ - lib/action_view/template/sources.rb
225
+ - lib/action_view/template/sources/file.rb
223
226
  - lib/action_view/template/text.rb
224
227
  - lib/action_view/template/types.rb
225
228
  - lib/action_view/test_case.rb
226
229
  - lib/action_view/testing/resolvers.rb
230
+ - lib/action_view/unbound_template.rb
227
231
  - lib/action_view/version.rb
228
232
  - lib/action_view/view_paths.rb
229
233
  - lib/assets/compiled/rails-ujs.js
230
- homepage: http://rubyonrails.org
234
+ homepage: https://rubyonrails.org
231
235
  licenses:
232
236
  - MIT
233
237
  metadata:
234
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta3/actionview
235
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta3/actionview/CHANGELOG.md
238
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.rc1/actionview
239
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.rc1/actionview/CHANGELOG.md
236
240
  post_install_message:
237
241
  rdoc_options: []
238
242
  require_paths:
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "action_view/template"
4
-
5
- module ActionView
6
- class FileTemplate < Template
7
- def initialize(filename, handler, details)
8
- @filename = filename
9
-
10
- super(nil, filename, handler, details)
11
- end
12
-
13
- def source
14
- File.binread @filename
15
- end
16
-
17
- def refresh(_)
18
- self
19
- end
20
-
21
- # Exceptions are marshalled when using the parallel test runner with DRb, so we need
22
- # to ensure that references to the template object can be marshalled as well. This means forgoing
23
- # the marshalling of the compiler mutex and instantiating that again on unmarshalling.
24
- def marshal_dump # :nodoc:
25
- [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants ]
26
- end
27
-
28
- def marshal_load(array) # :nodoc:
29
- @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants = *array
30
- @compile_mutex = Mutex.new
31
- end
32
- end
33
- end