actionview 8.0.2 → 8.0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +129 -1
- data/README.rdoc +1 -1
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +4 -4
- data/lib/action_view/helpers/atom_feed_helper.rb +1 -1
- data/lib/action_view/helpers/date_helper.rb +8 -1
- data/lib/action_view/helpers/form_helper.rb +2 -1
- data/lib/action_view/helpers/form_options_helper.rb +8 -4
- data/lib/action_view/helpers/form_tag_helper.rb +2 -1
- data/lib/action_view/helpers/sanitize_helper.rb +6 -1
- data/lib/action_view/helpers/tag_helper.rb +18 -6
- data/lib/action_view/helpers/tags/base.rb +11 -9
- data/lib/action_view/helpers/tags/check_box.rb +2 -2
- data/lib/action_view/helpers/tags/file_field.rb +4 -1
- data/lib/action_view/helpers/tags/label.rb +3 -10
- data/lib/action_view/helpers/tags/radio_button.rb +1 -1
- data/lib/action_view/helpers/tags/select_renderer.rb +1 -1
- data/lib/action_view/helpers/tags/text_area.rb +1 -1
- data/lib/action_view/helpers/tags/text_field.rb +1 -1
- data/lib/action_view/helpers/text_helper.rb +33 -10
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +5 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +8 -1
- data/lib/action_view/template/handlers/erb/erubi.rb +1 -1
- data/lib/action_view/template/raw_file.rb +4 -0
- data/lib/action_view/template.rb +8 -2
- data/lib/action_view/test_case.rb +0 -1
- data/lib/action_view.rb +1 -0
- metadata +18 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e3471ef52672292ca9950c0497300061713104fb75abdef2eaa69c392dce1e3
|
|
4
|
+
data.tar.gz: 1d2084723d63c509f943eb60763e877fa0f3a0ef4926142ffdda8f40fae7b05a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ba7329d06db4fc19fbd97773acbe78a9355a8d6977067d7a4d08c088eaa39d35c8574ebedce3b83955583fd82d6694b503b2383ab870dfd3504506ea2b88bfb
|
|
7
|
+
data.tar.gz: 27c64c7e736a6ce282011a1e61230856d40a191fb7cce7f6a3095570ad9c309c6b25dbfc5241156ea9214f063f5d5da16eeae2e8e62f1f673365df6db5af7683
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,132 @@
|
|
|
1
|
-
## Rails 8.0.2 (
|
|
1
|
+
## Rails 8.0.5.2 (November 03, 2026) ##
|
|
2
|
+
|
|
3
|
+
* Skip attribute names in tag helpers that are blank once converted to a
|
|
4
|
+
string.
|
|
5
|
+
|
|
6
|
+
A Symbol such as `:" "` is not blank, because `Symbol#blank?` is
|
|
7
|
+
`Symbol#empty?`, so it reached the escaping step and produced an attribute
|
|
8
|
+
with no name. The asset helpers symbolize their keys, so an ordinary String
|
|
9
|
+
key reached the same place.
|
|
10
|
+
|
|
11
|
+
[GHSA-68p9-83h6-5wpj]
|
|
12
|
+
|
|
13
|
+
*Mike Dalessio*
|
|
14
|
+
|
|
15
|
+
* Fix `strip_tags` to encode `"` and `'` in its output.
|
|
16
|
+
|
|
17
|
+
`strip_tags` returns an `html_safe` string, but was not encoding quotation
|
|
18
|
+
marks. The method now encodes all five HTML-significant characters (`&`,
|
|
19
|
+
`<`, `>`, `"`, `'`), consistent with the existing `html_safe` convention.
|
|
20
|
+
|
|
21
|
+
Output used outside HTML, such as in a text template or JSON, now contains
|
|
22
|
+
`"` and `'` where it contained `"` and `'`. `CGI.unescapeHTML`
|
|
23
|
+
decodes them.
|
|
24
|
+
|
|
25
|
+
[GHSA-rq8q-p985-fjq7]
|
|
26
|
+
|
|
27
|
+
*Mike Dalessio*
|
|
28
|
+
|
|
29
|
+
* Escape the matched phrase before substituting it into `highlight`'s
|
|
30
|
+
`:highlighter`.
|
|
31
|
+
|
|
32
|
+
A match was copied into each `\1` of the highlighter as it appeared in
|
|
33
|
+
the sanitized text, which keeps `"` and `'` as they are, so a match
|
|
34
|
+
containing a quote ended a quoted attribute value such as the
|
|
35
|
+
documented `'<a href="search?q=\1">\1</a>'` and added attributes of
|
|
36
|
+
its own. Each substituted group now goes through
|
|
37
|
+
`ERB::Util.html_escape_once`, so quotes in a match render as `"`
|
|
38
|
+
and `'`. Only the numbered placeholders `\0` to `\9` are expanded,
|
|
39
|
+
and a match never replaces the `>` that closes a tag.
|
|
40
|
+
|
|
41
|
+
[GHSA-v6rj-xm57-3p59]
|
|
42
|
+
|
|
43
|
+
*Jeremy Daer*
|
|
44
|
+
|
|
45
|
+
* Require rails-html-sanitizer 1.7.2 or later.
|
|
46
|
+
|
|
47
|
+
With the HTML5 sanitizer, Nokogiri before 1.19.5 left `<` and `>`
|
|
48
|
+
unescaped in attribute values. `highlight` and `simple_format`, which
|
|
49
|
+
edit the sanitized HTML as a string, could then turn markup inside an
|
|
50
|
+
attribute value into live elements. rails-html-sanitizer 1.7.2 requires
|
|
51
|
+
Loofah 2.25.3, which requires Nokogiri 1.19.5.
|
|
52
|
+
|
|
53
|
+
[GHSA-2p2f-4rq4-gjwc]
|
|
54
|
+
|
|
55
|
+
*Mike Dalessio*
|
|
56
|
+
|
|
57
|
+
## Rails 8.0.5.1 (July 29, 2026) ##
|
|
58
|
+
|
|
59
|
+
* No changes.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Rails 8.0.5 (March 24, 2026) ##
|
|
63
|
+
|
|
64
|
+
* Fix encoding errors for string locals containing non-ASCII characters.
|
|
65
|
+
|
|
66
|
+
*Kataoka Katsuki*
|
|
67
|
+
|
|
68
|
+
* Fix collection caching to only forward `expires_in` argument if explicitly set.
|
|
69
|
+
|
|
70
|
+
*Pieter Visser*
|
|
71
|
+
|
|
72
|
+
* Fix `file_field` to join mime types with a comma when provided as Array
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
file_field(:article, :image, accept: ['image/png', 'image/gif', 'image/jpeg'])
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Now behaves likes:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
file_field(:article, :image, accept: 'image/png,image/gif,image/jpeg')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
*Bogdan Gusiev*
|
|
85
|
+
|
|
86
|
+
* Fix strict locals parsing to handle multiline definitions.
|
|
87
|
+
|
|
88
|
+
*Said Kaldybaev*
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Rails 8.0.4.1 (March 23, 2026) ##
|
|
92
|
+
|
|
93
|
+
* Skip blank attribute names in tag helpers to avoid generating invalid HTML.
|
|
94
|
+
|
|
95
|
+
[CVE-2026-33168]
|
|
96
|
+
|
|
97
|
+
*Mike Dalessio*
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Rails 8.0.4 (October 28, 2025) ##
|
|
101
|
+
|
|
102
|
+
* Restore `add_default_name_and_id` method.
|
|
103
|
+
|
|
104
|
+
*Hartley McGuire*
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Rails 8.0.3 (September 22, 2025) ##
|
|
108
|
+
|
|
109
|
+
* Fix label with `for` option not getting prefixed by form `namespace` value
|
|
110
|
+
|
|
111
|
+
*Abeid Ahmed*, *Hartley McGuire*
|
|
112
|
+
|
|
113
|
+
* Fix `javascript_include_tag` `type` option to accept either strings and symbols.
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
javascript_include_tag "application", type: :module
|
|
117
|
+
javascript_include_tag "application", type: "module"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Previously, only the string value was recognized.
|
|
121
|
+
|
|
122
|
+
*Jean Boussier*
|
|
123
|
+
|
|
124
|
+
* Fix `excerpt` helper with non-whitespace separator.
|
|
125
|
+
|
|
126
|
+
*Jonathan Hefner*
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## Rails 8.0.2.1 (August 13, 2025) ##
|
|
2
130
|
|
|
3
131
|
* No changes.
|
|
4
132
|
|
data/README.rdoc
CHANGED
|
@@ -35,6 +35,6 @@ Bug reports for the Ruby on \Rails project can be filed here:
|
|
|
35
35
|
|
|
36
36
|
* https://github.com/rails/rails/issues
|
|
37
37
|
|
|
38
|
-
Feature requests should be discussed on the
|
|
38
|
+
Feature requests should be discussed on the rubyonrails-core forum here:
|
|
39
39
|
|
|
40
40
|
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
|
@@ -115,11 +115,11 @@ module ActionView
|
|
|
115
115
|
path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys
|
|
116
116
|
preload_links = []
|
|
117
117
|
use_preload_links_header = options["preload_links_header"].nil? ? preload_links_header : options.delete("preload_links_header")
|
|
118
|
-
nopush = options["nopush"].nil?
|
|
118
|
+
nopush = options["nopush"].nil? || options.delete("nopush")
|
|
119
119
|
crossorigin = options.delete("crossorigin")
|
|
120
120
|
crossorigin = "anonymous" if crossorigin == true
|
|
121
121
|
integrity = options["integrity"]
|
|
122
|
-
rel = options["type"] == "module" ? "modulepreload" : "preload"
|
|
122
|
+
rel = options["type"] == "module" || options["type"] == :module ? "modulepreload" : "preload"
|
|
123
123
|
|
|
124
124
|
sources_tags = sources.uniq.map { |source|
|
|
125
125
|
href = path_to_javascript(source, path_options)
|
|
@@ -206,7 +206,7 @@ module ActionView
|
|
|
206
206
|
preload_links = []
|
|
207
207
|
crossorigin = options.delete("crossorigin")
|
|
208
208
|
crossorigin = "anonymous" if crossorigin == true
|
|
209
|
-
nopush = options["nopush"].nil?
|
|
209
|
+
nopush = options["nopush"].nil? || options.delete("nopush")
|
|
210
210
|
integrity = options["integrity"]
|
|
211
211
|
|
|
212
212
|
sources_tags = sources.uniq.map { |source|
|
|
@@ -361,7 +361,7 @@ module ActionView
|
|
|
361
361
|
crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
|
|
362
362
|
integrity = options[:integrity]
|
|
363
363
|
nopush = options.delete(:nopush) || false
|
|
364
|
-
rel = mime_type == "module" ? "modulepreload" : "preload"
|
|
364
|
+
rel = mime_type == "module" || mime_type == :module ? "modulepreload" : "preload"
|
|
365
365
|
|
|
366
366
|
link_tag = tag.link(
|
|
367
367
|
rel: rel,
|
|
@@ -170,7 +170,7 @@ module ActionView
|
|
|
170
170
|
|
|
171
171
|
# Creates an entry tag for a specific record and prefills the id using class and id.
|
|
172
172
|
#
|
|
173
|
-
# Options
|
|
173
|
+
# ==== Options
|
|
174
174
|
#
|
|
175
175
|
# * <tt>:published</tt>: Time first published. Defaults to the created_at attribute on the record if one such exists.
|
|
176
176
|
# * <tt>:updated</tt>: Time of update. Defaults to the updated_at attribute on the record if one such exists.
|
|
@@ -136,8 +136,15 @@ module ActionView
|
|
|
136
136
|
from_year += 1 if from_time.month >= 3
|
|
137
137
|
to_year = to_time.year
|
|
138
138
|
to_year -= 1 if to_time.month < 3
|
|
139
|
-
|
|
139
|
+
|
|
140
|
+
leap_years = if from_year > to_year
|
|
141
|
+
0
|
|
142
|
+
else
|
|
143
|
+
fyear = from_year - 1
|
|
144
|
+
(to_year / 4 - to_year / 100 + to_year / 400) - (fyear / 4 - fyear / 100 + fyear / 400)
|
|
145
|
+
end
|
|
140
146
|
minute_offset_for_leap_year = leap_years * 1440
|
|
147
|
+
|
|
141
148
|
# Discount the leap year days when calculating year distance.
|
|
142
149
|
# e.g. if there are 20 leap year days between 2 dates having the same day
|
|
143
150
|
# and month then based on 365 days calculation
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "cgi"
|
|
3
|
+
require "cgi/escape"
|
|
4
|
+
require "cgi/util" if RUBY_VERSION < "3.5"
|
|
4
5
|
require "erb"
|
|
5
6
|
require "active_support/core_ext/string/output_safety"
|
|
6
7
|
require "active_support/core_ext/array/extract_options"
|
|
@@ -496,7 +497,8 @@ module ActionView
|
|
|
496
497
|
# <option value="France">France</option>
|
|
497
498
|
# </optgroup>
|
|
498
499
|
#
|
|
499
|
-
# Parameters
|
|
500
|
+
# ==== Parameters
|
|
501
|
+
#
|
|
500
502
|
# * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the
|
|
501
503
|
# <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
|
|
502
504
|
# nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
|
|
@@ -507,7 +509,8 @@ module ActionView
|
|
|
507
509
|
# which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options
|
|
508
510
|
# as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
|
|
509
511
|
#
|
|
510
|
-
# Options
|
|
512
|
+
# ==== Options
|
|
513
|
+
#
|
|
511
514
|
# * <tt>:prompt</tt> - set to true or a prompt string. When the select element doesn't have a value yet, this
|
|
512
515
|
# prepends an option with a generic prompt - "Please select" - or the given prompt string.
|
|
513
516
|
# * <tt>:divider</tt> - the divider for the options groups.
|
|
@@ -599,7 +602,8 @@ module ActionView
|
|
|
599
602
|
|
|
600
603
|
# Returns a string of option tags for the days of the week.
|
|
601
604
|
#
|
|
602
|
-
# Options
|
|
605
|
+
# ====Options
|
|
606
|
+
#
|
|
603
607
|
# * <tt>:index_as_value</tt> - Defaults to false, set to true to use the indexes from
|
|
604
608
|
# <tt>I18n.translate("date.day_names")</tt> as the values. By default, Sunday is always 0.
|
|
605
609
|
# * <tt>:day_format</tt> - The I18n key of the array to use for the weekday options.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "cgi"
|
|
3
|
+
require "cgi/escape"
|
|
4
|
+
require "cgi/util" if RUBY_VERSION < "3.5"
|
|
4
5
|
require "action_view/helpers/content_exfiltration_prevention_helper"
|
|
5
6
|
require "action_view/helpers/url_helper"
|
|
6
7
|
require "action_view/helpers/text_helper"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support/core_ext/string/output_safety"
|
|
3
4
|
require "rails-html-sanitizer"
|
|
4
5
|
|
|
5
6
|
module ActionView
|
|
@@ -33,6 +34,9 @@ module ActionView
|
|
|
33
34
|
# Please note that sanitizing user-provided text does not guarantee that the
|
|
34
35
|
# resulting markup is valid or even well-formed.
|
|
35
36
|
#
|
|
37
|
+
# The output is markup, which is safe only as element content. Do not use it in an attribute
|
|
38
|
+
# value; use +strip_tags+ or a tag helper such as <tt>tag.a(title: ...)</tt> instead.
|
|
39
|
+
#
|
|
36
40
|
# ==== Options
|
|
37
41
|
#
|
|
38
42
|
# [+:tags+]
|
|
@@ -137,7 +141,8 @@ module ActionView
|
|
|
137
141
|
# strip_tags("> A quote from Smith & Wesson")
|
|
138
142
|
# # => > A quote from Smith & Wesson
|
|
139
143
|
def strip_tags(html)
|
|
140
|
-
self.class.full_sanitizer.sanitize(html)
|
|
144
|
+
stripped = self.class.full_sanitizer.sanitize(html)
|
|
145
|
+
ERB::Util.html_escape_once(stripped) if stripped
|
|
141
146
|
end
|
|
142
147
|
|
|
143
148
|
# Strips all link tags from +html+ leaving just the link text.
|
|
@@ -250,16 +250,28 @@ module ActionView
|
|
|
250
250
|
output = +""
|
|
251
251
|
sep = " "
|
|
252
252
|
options.each_pair do |key, value|
|
|
253
|
+
next if key.blank?
|
|
254
|
+
|
|
255
|
+
name = Symbol === key ? key.name : key.to_s
|
|
256
|
+
next if name.blank?
|
|
257
|
+
|
|
253
258
|
type = TAG_TYPES[key]
|
|
254
259
|
if type == :data && value.is_a?(Hash)
|
|
255
260
|
value.each_pair do |k, v|
|
|
256
|
-
next if v.nil?
|
|
261
|
+
next if k.blank? || v.nil?
|
|
262
|
+
|
|
263
|
+
nested_name = Symbol === k ? k.name : k.to_s
|
|
264
|
+
next if nested_name.blank?
|
|
265
|
+
|
|
257
266
|
output << sep
|
|
258
|
-
output << prefix_tag_option(
|
|
267
|
+
output << prefix_tag_option(name, nested_name, v, escape)
|
|
259
268
|
end
|
|
260
269
|
elsif type == :aria && value.is_a?(Hash)
|
|
261
270
|
value.each_pair do |k, v|
|
|
262
|
-
next if v.nil?
|
|
271
|
+
next if k.blank? || v.nil?
|
|
272
|
+
|
|
273
|
+
nested_name = Symbol === k ? k.name : k.to_s
|
|
274
|
+
next if nested_name.blank?
|
|
263
275
|
|
|
264
276
|
case v
|
|
265
277
|
when Array, Hash
|
|
@@ -272,16 +284,16 @@ module ActionView
|
|
|
272
284
|
end
|
|
273
285
|
|
|
274
286
|
output << sep
|
|
275
|
-
output << prefix_tag_option(
|
|
287
|
+
output << prefix_tag_option(name, nested_name, v, escape)
|
|
276
288
|
end
|
|
277
289
|
elsif type == :boolean
|
|
278
290
|
if value
|
|
279
291
|
output << sep
|
|
280
|
-
output << boolean_tag_option(
|
|
292
|
+
output << boolean_tag_option(name)
|
|
281
293
|
end
|
|
282
294
|
elsif !value.nil?
|
|
283
295
|
output << sep
|
|
284
|
-
output << tag_option(
|
|
296
|
+
output << tag_option(name, value, escape)
|
|
285
297
|
end
|
|
286
298
|
end
|
|
287
299
|
output unless output.empty?
|
|
@@ -80,30 +80,32 @@ module ActionView
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
def
|
|
83
|
+
def add_default_name_and_field_for_value(tag_value, options, field = "id")
|
|
84
84
|
if tag_value.nil?
|
|
85
|
-
|
|
85
|
+
add_default_name_and_field(options, field)
|
|
86
86
|
else
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
specified_field = options[field]
|
|
88
|
+
add_default_name_and_field(options, field)
|
|
89
89
|
|
|
90
|
-
if
|
|
91
|
-
options[
|
|
90
|
+
if specified_field.blank? && options[field].present?
|
|
91
|
+
options[field] += "_#{sanitized_value(tag_value)}"
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
|
+
alias_method :add_default_name_and_id_for_value, :add_default_name_and_field_for_value
|
|
95
96
|
|
|
96
|
-
def
|
|
97
|
+
def add_default_name_and_field(options, field = "id")
|
|
97
98
|
index = name_and_id_index(options)
|
|
98
99
|
options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
|
|
99
100
|
|
|
100
101
|
if generate_ids?
|
|
101
|
-
options[
|
|
102
|
+
options[field] = options.fetch(field) { tag_id(index, options.delete("namespace")) }
|
|
102
103
|
if namespace = options.delete("namespace")
|
|
103
|
-
options[
|
|
104
|
+
options[field] = options[field] ? "#{namespace}_#{options[field]}" : namespace
|
|
104
105
|
end
|
|
105
106
|
end
|
|
106
107
|
end
|
|
108
|
+
alias_method :add_default_name_and_id, :add_default_name_and_field
|
|
107
109
|
|
|
108
110
|
def tag_name(multiple = false, index = nil)
|
|
109
111
|
@template_object.field_name(@object_name, sanitized_method_name, multiple: multiple, index: index)
|
|
@@ -21,10 +21,10 @@ module ActionView
|
|
|
21
21
|
options["checked"] = "checked" if input_checked?(options)
|
|
22
22
|
|
|
23
23
|
if options["multiple"]
|
|
24
|
-
|
|
24
|
+
add_default_name_and_field_for_value(@checked_value, options)
|
|
25
25
|
options.delete("multiple")
|
|
26
26
|
else
|
|
27
|
-
|
|
27
|
+
add_default_name_and_field(options)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
include_hidden = options.delete("include_hidden") { true }
|
|
@@ -6,8 +6,11 @@ module ActionView
|
|
|
6
6
|
class FileField < TextField # :nodoc:
|
|
7
7
|
def render
|
|
8
8
|
include_hidden = @options.delete(:include_hidden)
|
|
9
|
+
if @options[:accept].is_a?(Array)
|
|
10
|
+
@options[:accept] = @options[:accept].join(",")
|
|
11
|
+
end
|
|
9
12
|
options = @options.stringify_keys
|
|
10
|
-
|
|
13
|
+
add_default_name_and_field(options)
|
|
11
14
|
|
|
12
15
|
if options["multiple"] && include_hidden
|
|
13
16
|
hidden_field_for_multiple_file(options) + super
|
|
@@ -48,18 +48,11 @@ module ActionView
|
|
|
48
48
|
def render(&block)
|
|
49
49
|
options = @options.stringify_keys
|
|
50
50
|
tag_value = options.delete("value")
|
|
51
|
-
name_and_id = options.dup
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
name_and_id["id"] = name_and_id["for"]
|
|
55
|
-
else
|
|
56
|
-
name_and_id.delete("id")
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
add_default_name_and_id_for_value(tag_value, name_and_id)
|
|
52
|
+
add_default_name_and_field_for_value(tag_value, options, "for")
|
|
60
53
|
options.delete("index")
|
|
54
|
+
options.delete("name")
|
|
61
55
|
options.delete("namespace")
|
|
62
|
-
options["for"] = name_and_id["id"] unless options.key?("for")
|
|
63
56
|
|
|
64
57
|
builder = LabelBuilder.new(@template_object, @object_name, @method_name, @object, tag_value)
|
|
65
58
|
|
|
@@ -71,7 +64,7 @@ module ActionView
|
|
|
71
64
|
render_component(builder)
|
|
72
65
|
end
|
|
73
66
|
|
|
74
|
-
label_tag(
|
|
67
|
+
label_tag(options["for"], content, options)
|
|
75
68
|
end
|
|
76
69
|
|
|
77
70
|
private
|
|
@@ -18,7 +18,7 @@ module ActionView
|
|
|
18
18
|
options["type"] = "radio"
|
|
19
19
|
options["value"] = @tag_value
|
|
20
20
|
options["checked"] = "checked" if input_checked?(options)
|
|
21
|
-
|
|
21
|
+
add_default_name_and_field_for_value(@tag_value, options)
|
|
22
22
|
tag("input", options)
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -11,7 +11,7 @@ module ActionView
|
|
|
11
11
|
html_options[prop.to_s] = options.delete(prop) if options.key?(prop) && !html_options.key?(prop.to_s)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
add_default_name_and_field(html_options)
|
|
15
15
|
|
|
16
16
|
if placeholder_required?(html_options)
|
|
17
17
|
raise ArgumentError, "include_blank cannot be false for a required field." if options[:include_blank] == false
|
|
@@ -10,7 +10,7 @@ module ActionView
|
|
|
10
10
|
|
|
11
11
|
def render
|
|
12
12
|
options = @options.stringify_keys
|
|
13
|
-
|
|
13
|
+
add_default_name_and_field(options)
|
|
14
14
|
|
|
15
15
|
if size = options.delete("size")
|
|
16
16
|
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
|
|
@@ -13,7 +13,7 @@ module ActionView
|
|
|
13
13
|
options["size"] = options["maxlength"] unless options.key?("size")
|
|
14
14
|
options["type"] ||= field_type
|
|
15
15
|
options["value"] = options.fetch("value") { value_before_type_cast } unless field_type == "file"
|
|
16
|
-
|
|
16
|
+
add_default_name_and_field(options)
|
|
17
17
|
tag("input", options)
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -143,8 +143,15 @@ module ActionView
|
|
|
143
143
|
#
|
|
144
144
|
# [+:highlighter+]
|
|
145
145
|
# The highlighter string. Uses <tt>\1</tt> as the placeholder for a
|
|
146
|
-
# phrase
|
|
147
|
-
#
|
|
146
|
+
# phrase. Defaults to <tt>"<mark>\1</mark>"</tt>. The numbered placeholders
|
|
147
|
+
# <tt>\0</tt> to <tt>\9</tt> are expanded; other +String#sub+ replacement escapes
|
|
148
|
+
# are not. The phrase is HTML escaped, quotes included. This option
|
|
149
|
+
# is ignored if a block is specified.
|
|
150
|
+
#
|
|
151
|
+
# WARNING: Put a placeholder only in element content or inside a
|
|
152
|
+
# quoted attribute value. HTML escaping does not make the phrase safe
|
|
153
|
+
# in an unquoted attribute value, in a URL, JavaScript or CSS
|
|
154
|
+
# context, or in an attribute whose value is HTML, such as +srcdoc+.
|
|
148
155
|
#
|
|
149
156
|
# [+:sanitize+]
|
|
150
157
|
# Whether to sanitize +text+ before highlighting. Defaults to true.
|
|
@@ -163,8 +170,8 @@ module ActionView
|
|
|
163
170
|
# highlight('You searched for: rails', ['for', 'rails'], highlighter: '<em>\1</em>')
|
|
164
171
|
# # => "You searched <em>for</em>: <em>rails</em>"
|
|
165
172
|
#
|
|
166
|
-
# highlight('You searched for: rails', 'rails', highlighter: '<
|
|
167
|
-
# # => "You searched for: <
|
|
173
|
+
# highlight('You searched for: rails', 'rails', highlighter: '<mark title="\1">\1</mark>')
|
|
174
|
+
# # => "You searched for: <mark title=\"rails\">rails</mark>"
|
|
168
175
|
#
|
|
169
176
|
# highlight('You searched for: rails', 'rails') { |match| link_to(search_path(q: match)) }
|
|
170
177
|
# # => "You searched for: <a href=\"search?q=rails\">rails</a>"
|
|
@@ -179,14 +186,23 @@ module ActionView
|
|
|
179
186
|
else
|
|
180
187
|
patterns = Array(phrases).map { |phrase| Regexp === phrase ? phrase : Regexp.escape(phrase) }
|
|
181
188
|
pattern = /(#{patterns.join("|")})/i
|
|
189
|
+
# The text after a tag begins with the ">" that closes it. Leave it
|
|
190
|
+
# in the segment so phrases can see it as context, but keep it out
|
|
191
|
+
# of the match so the highlighter can't take the place of the ">".
|
|
192
|
+
pattern_after_tag = /(?!\A)#{pattern}/
|
|
182
193
|
highlighter = options.fetch(:highlighter, '<mark>\1</mark>') unless block
|
|
183
194
|
|
|
184
|
-
text.scan(/<[^>]*|[^<]+/).
|
|
195
|
+
text.scan(/<[^>]*|[^<]+/).each_with_index do |segment, index|
|
|
185
196
|
if !segment.start_with?("<")
|
|
197
|
+
segment_pattern = index > 0 ? pattern_after_tag : pattern
|
|
198
|
+
|
|
186
199
|
if block
|
|
187
|
-
segment.gsub!(
|
|
200
|
+
segment.gsub!(segment_pattern, &block)
|
|
188
201
|
else
|
|
189
|
-
segment.gsub!(
|
|
202
|
+
segment.gsub!(segment_pattern) do
|
|
203
|
+
match = Regexp.last_match
|
|
204
|
+
highlighter.gsub(/\\(\d)/) { ERB::Util.html_escape_once(match[$1.to_i]) }
|
|
205
|
+
end
|
|
190
206
|
end
|
|
191
207
|
end
|
|
192
208
|
end.join
|
|
@@ -260,7 +276,14 @@ module ActionView
|
|
|
260
276
|
prefix, first_part = cut_excerpt_part(:first, first_part, separator, options)
|
|
261
277
|
postfix, second_part = cut_excerpt_part(:second, second_part, separator, options)
|
|
262
278
|
|
|
263
|
-
affix = [
|
|
279
|
+
affix = [
|
|
280
|
+
first_part,
|
|
281
|
+
!first_part.empty? ? separator : "",
|
|
282
|
+
phrase,
|
|
283
|
+
!second_part.empty? ? separator : "",
|
|
284
|
+
second_part
|
|
285
|
+
].join.strip
|
|
286
|
+
|
|
264
287
|
[prefix, affix, postfix].join
|
|
265
288
|
end
|
|
266
289
|
|
|
@@ -271,7 +294,7 @@ module ActionView
|
|
|
271
294
|
#
|
|
272
295
|
# The word will be pluralized using rules defined for the locale
|
|
273
296
|
# (you must define your own inflection rules for languages other than English).
|
|
274
|
-
# See ActiveSupport::Inflector.pluralize
|
|
297
|
+
# See ActiveSupport::Inflector.pluralize.
|
|
275
298
|
#
|
|
276
299
|
# pluralize(1, 'person')
|
|
277
300
|
# # => "1 person"
|
|
@@ -346,7 +369,7 @@ module ActionView
|
|
|
346
369
|
# ==== Options
|
|
347
370
|
# * <tt>:sanitize</tt> - If +false+, does not sanitize +text+.
|
|
348
371
|
# * <tt>:sanitize_options</tt> - Any extra options you want appended to the sanitize.
|
|
349
|
-
# * <tt>:wrapper_tag</tt> - String representing the wrapper tag, defaults to <tt>"p"</tt
|
|
372
|
+
# * <tt>:wrapper_tag</tt> - String representing the wrapper tag, defaults to <tt>"p"</tt>.
|
|
350
373
|
#
|
|
351
374
|
# ==== Examples
|
|
352
375
|
# my_text = "Here is some basic text...\n...with a line break."
|
|
@@ -111,7 +111,11 @@ module ActionView
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
unless entries_to_write.empty?
|
|
114
|
-
|
|
114
|
+
if @options[:cached].is_a?(Hash) && @options[:cached].key?(:expires_in)
|
|
115
|
+
collection_cache.write_multi(entries_to_write, expires_in: @options[:cached][:expires_in])
|
|
116
|
+
else
|
|
117
|
+
collection_cache.write_multi(entries_to_write)
|
|
118
|
+
end
|
|
115
119
|
end
|
|
116
120
|
|
|
117
121
|
keyed_partials
|
|
@@ -25,6 +25,13 @@ module ActionView
|
|
|
25
25
|
self
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Returns the complete body as a string.
|
|
29
|
+
def body
|
|
30
|
+
buffer = String.new
|
|
31
|
+
each { |part| buffer << part }
|
|
32
|
+
buffer
|
|
33
|
+
end
|
|
34
|
+
|
|
28
35
|
private
|
|
29
36
|
# This is the same logging logic as in ShowExceptions middleware.
|
|
30
37
|
def log_error(exception)
|
|
@@ -42,7 +49,7 @@ module ActionView
|
|
|
42
49
|
# object that responds to each. This object is initialized with a block
|
|
43
50
|
# that knows how to render the template.
|
|
44
51
|
def render_template(view, template, layout_name = nil, locals = {}) # :nodoc:
|
|
45
|
-
return [super.body] unless
|
|
52
|
+
return [super.body] unless template.supports_streaming?
|
|
46
53
|
|
|
47
54
|
locals ||= {}
|
|
48
55
|
layout = find_layout(layout_name, locals.keys, [formats.first])
|
|
@@ -18,7 +18,7 @@ module ActionView
|
|
|
18
18
|
properties[:preamble] ||= ""
|
|
19
19
|
properties[:postamble] ||= "#{properties[:bufvar]}"
|
|
20
20
|
|
|
21
|
-
# Tell
|
|
21
|
+
# Tell Erubi whether the template will be compiled with `frozen_string_literal: true`
|
|
22
22
|
properties[:freeze_template_literals] = !Template.frozen_string_literal
|
|
23
23
|
|
|
24
24
|
properties[:escapefunc] = ""
|
data/lib/action_view/template.rb
CHANGED
|
@@ -7,7 +7,7 @@ module ActionView
|
|
|
7
7
|
class Template
|
|
8
8
|
extend ActiveSupport::Autoload
|
|
9
9
|
|
|
10
|
-
STRICT_LOCALS_REGEX = /\#\s+locals:\s+\((
|
|
10
|
+
STRICT_LOCALS_REGEX = /\#\s+locals:\s+\((.*?)\)(?=\s*-?%>|\s*$)/m
|
|
11
11
|
|
|
12
12
|
# === Encodings in ActionView::Template
|
|
13
13
|
#
|
|
@@ -366,10 +366,16 @@ module ActionView
|
|
|
366
366
|
def strict_locals!
|
|
367
367
|
if @strict_locals == NONE
|
|
368
368
|
self.source.sub!(STRICT_LOCALS_REGEX, "")
|
|
369
|
-
@strict_locals = $1
|
|
369
|
+
@strict_locals = $1&.rstrip
|
|
370
370
|
|
|
371
371
|
return if @strict_locals.nil? # Magic comment not found
|
|
372
372
|
|
|
373
|
+
# Tag with the assumed encoding before encode! runs, same as
|
|
374
|
+
# encode! does for the source itself (see above).
|
|
375
|
+
if @strict_locals.encoding == Encoding::BINARY
|
|
376
|
+
@strict_locals.force_encoding(Encoding.default_external)
|
|
377
|
+
end
|
|
378
|
+
|
|
373
379
|
@strict_locals = "**nil" if @strict_locals.blank?
|
|
374
380
|
end
|
|
375
381
|
|
|
@@ -301,7 +301,6 @@ module ActionView
|
|
|
301
301
|
class RenderedViewContent < String # :nodoc:
|
|
302
302
|
end
|
|
303
303
|
|
|
304
|
-
# Need to experiment if this priority is the best one: rendered => output_buffer
|
|
305
304
|
class RenderedViewsCollection
|
|
306
305
|
def initialize
|
|
307
306
|
@rendered_views ||= Hash.new { |hash, key| hash[key] = [] }
|
data/lib/action_view.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: actionview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.0.2
|
|
4
|
+
version: 8.0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 8.0.2
|
|
18
|
+
version: 8.0.5.2
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 8.0.2
|
|
25
|
+
version: 8.0.5.2
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: builder
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,6 +58,9 @@ dependencies:
|
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: '1.6'
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 1.7.2
|
|
61
64
|
type: :runtime
|
|
62
65
|
prerelease: false
|
|
63
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -65,6 +68,9 @@ dependencies:
|
|
|
65
68
|
- - "~>"
|
|
66
69
|
- !ruby/object:Gem::Version
|
|
67
70
|
version: '1.6'
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: 1.7.2
|
|
68
74
|
- !ruby/object:Gem::Dependency
|
|
69
75
|
name: rails-dom-testing
|
|
70
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,28 +91,28 @@ dependencies:
|
|
|
85
91
|
requirements:
|
|
86
92
|
- - '='
|
|
87
93
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 8.0.2
|
|
94
|
+
version: 8.0.5.2
|
|
89
95
|
type: :development
|
|
90
96
|
prerelease: false
|
|
91
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
98
|
requirements:
|
|
93
99
|
- - '='
|
|
94
100
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 8.0.2
|
|
101
|
+
version: 8.0.5.2
|
|
96
102
|
- !ruby/object:Gem::Dependency
|
|
97
103
|
name: activemodel
|
|
98
104
|
requirement: !ruby/object:Gem::Requirement
|
|
99
105
|
requirements:
|
|
100
106
|
- - '='
|
|
101
107
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 8.0.2
|
|
108
|
+
version: 8.0.5.2
|
|
103
109
|
type: :development
|
|
104
110
|
prerelease: false
|
|
105
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
112
|
requirements:
|
|
107
113
|
- - '='
|
|
108
114
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 8.0.2
|
|
115
|
+
version: 8.0.5.2
|
|
110
116
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
|
111
117
|
email: david@loudthinking.com
|
|
112
118
|
executables: []
|
|
@@ -246,10 +252,10 @@ licenses:
|
|
|
246
252
|
- MIT
|
|
247
253
|
metadata:
|
|
248
254
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
249
|
-
changelog_uri: https://github.com/rails/rails/blob/v8.0.2/actionview/CHANGELOG.md
|
|
250
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.2/
|
|
255
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.5.2/actionview/CHANGELOG.md
|
|
256
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.5.2/
|
|
251
257
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
252
|
-
source_code_uri: https://github.com/rails/rails/tree/v8.0.2/actionview
|
|
258
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.5.2/actionview
|
|
253
259
|
rubygems_mfa_required: 'true'
|
|
254
260
|
rdoc_options: []
|
|
255
261
|
require_paths:
|
|
@@ -266,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
266
272
|
version: '0'
|
|
267
273
|
requirements:
|
|
268
274
|
- none
|
|
269
|
-
rubygems_version:
|
|
275
|
+
rubygems_version: 4.0.20
|
|
270
276
|
specification_version: 4
|
|
271
277
|
summary: Rendering framework putting the V in MVC (part of Rails).
|
|
272
278
|
test_files: []
|