actionview 7.1.3.3 → 7.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -417
  3. data/lib/action_view/base.rb +20 -3
  4. data/lib/action_view/cache_expiry.rb +9 -3
  5. data/lib/action_view/dependency_tracker/{ripper_tracker.rb → ruby_tracker.rb} +4 -3
  6. data/lib/action_view/dependency_tracker.rb +1 -1
  7. data/lib/action_view/gem_version.rb +3 -3
  8. data/lib/action_view/helpers/asset_tag_helper.rb +15 -3
  9. data/lib/action_view/helpers/cache_helper.rb +4 -4
  10. data/lib/action_view/helpers/csrf_helper.rb +1 -1
  11. data/lib/action_view/helpers/form_helper.rb +197 -192
  12. data/lib/action_view/helpers/form_tag_helper.rb +76 -43
  13. data/lib/action_view/helpers/output_safety_helper.rb +4 -4
  14. data/lib/action_view/helpers/tag_helper.rb +208 -18
  15. data/lib/action_view/helpers/url_helper.rb +4 -78
  16. data/lib/action_view/layouts.rb +2 -4
  17. data/lib/action_view/log_subscriber.rb +8 -4
  18. data/lib/action_view/railtie.rb +0 -1
  19. data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
  20. data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +152 -9
  21. data/lib/action_view/render_parser.rb +21 -169
  22. data/lib/action_view/renderer/abstract_renderer.rb +1 -1
  23. data/lib/action_view/renderer/renderer.rb +32 -38
  24. data/lib/action_view/rendering.rb +4 -4
  25. data/lib/action_view/template/renderable.rb +7 -1
  26. data/lib/action_view/template/resolver.rb +0 -2
  27. data/lib/action_view/template.rb +28 -4
  28. data/lib/action_view/test_case.rb +12 -14
  29. data/lib/action_view/unbound_template.rb +4 -4
  30. data/lib/action_view.rb +1 -1
  31. metadata +15 -14
@@ -68,6 +68,8 @@ module ActionView
68
68
  # attribute, which indicates to the browser that the script is meant to
69
69
  # be executed after the document has been parsed. Additionally, prevents
70
70
  # sending the Preload Links header.
71
+ # * <tt>:nopush</tt> - Specify if the use of server push is not desired
72
+ # for the script. Defaults to +true+.
71
73
  #
72
74
  # Any other specified options will be treated as HTML attributes for the
73
75
  # +script+ tag.
@@ -166,6 +168,10 @@ module ActionView
166
168
  # that path.
167
169
  # * <tt>:skip_pipeline</tt> - This option is used to bypass the asset pipeline
168
170
  # when it is set to true.
171
+ # * <tt>:nonce</tt> - When set to true, adds an automatic nonce value if
172
+ # you have Content Security Policy enabled.
173
+ # * <tt>:nopush</tt> - Specify if the use of server push is not desired
174
+ # for the stylesheet. Defaults to +true+.
169
175
  #
170
176
  # ==== Examples
171
177
  #
@@ -190,6 +196,9 @@ module ActionView
190
196
  # stylesheet_link_tag "random.styles", "/css/stylish"
191
197
  # # => <link href="/assets/random.styles" rel="stylesheet" />
192
198
  # # <link href="/css/stylish.css" rel="stylesheet" />
199
+ #
200
+ # stylesheet_link_tag "style", nonce: true
201
+ # # => <link href="/assets/style.css" rel="stylesheet" nonce="..." />
193
202
  def stylesheet_link_tag(*sources)
194
203
  options = sources.extract_options!.stringify_keys
195
204
  path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys
@@ -214,6 +223,9 @@ module ActionView
214
223
  "crossorigin" => crossorigin,
215
224
  "href" => href
216
225
  }.merge!(options)
226
+ if tag_options["nonce"] == true
227
+ tag_options["nonce"] = content_security_policy_nonce
228
+ end
217
229
 
218
230
  if apply_stylesheet_media_default && tag_options["media"].blank?
219
231
  tag_options["media"] = "screen"
@@ -351,13 +363,13 @@ module ActionView
351
363
  nopush = options.delete(:nopush) || false
352
364
  rel = mime_type == "module" ? "modulepreload" : "preload"
353
365
 
354
- link_tag = tag.link(**{
366
+ link_tag = tag.link(
355
367
  rel: rel,
356
368
  href: href,
357
369
  as: as_type,
358
370
  type: mime_type,
359
- crossorigin: crossorigin
360
- }.merge!(options.symbolize_keys))
371
+ crossorigin: crossorigin,
372
+ **options.symbolize_keys)
361
373
 
362
374
  preload_link = "<#{href}>; rel=#{rel}; as=#{as_type}"
363
375
  preload_link += "; type=#{mime_type}" if mime_type
@@ -76,11 +76,11 @@ module ActionView
76
76
  # render 'comments/comments'
77
77
  # render('comments/comments')
78
78
  #
79
- # render "header" translates to render("comments/header")
79
+ # render "header" # translates to render("comments/header")
80
80
  #
81
- # render(@topic) translates to render("topics/topic")
82
- # render(topics) translates to render("topics/topic")
83
- # render(message.topics) translates to render("topics/topic")
81
+ # render(@topic) # translates to render("topics/topic")
82
+ # render(topics) # translates to render("topics/topic")
83
+ # render(message.topics) # translates to render("topics/topic")
84
84
  #
85
85
  # It's not possible to derive all render calls like that, though.
86
86
  # Here are a few examples of things that can't be derived:
@@ -17,7 +17,7 @@ module ActionView
17
17
  # You don't need to use these tags for regular forms as they generate their own hidden fields.
18
18
  #
19
19
  # For Ajax requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
20
- # +X-CSRF-Token+ HTTP header. If you are using rails-ujs, this happens automatically.
20
+ # +X-CSRF-Token+ HTTP header.
21
21
  #
22
22
  def csrf_meta_tags
23
23
  if defined?(protect_against_forgery?) && protect_against_forgery?