actionview 6.1.4.6 → 6.1.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe53fe4c85e73a08f9dcadefd08ce267e0617f6336ee0bf758757e35ac11224c
4
- data.tar.gz: 9f82b0e20785f3775159cf270571c612321402ac935aedb228b948c13177a1a5
3
+ metadata.gz: 347465d701c1688d4e91d033d1f29b16f6f284005f9aaeefc71a36ef0ff439a8
4
+ data.tar.gz: de5710a75c9b8aa8bcf02e34bb62efc0818f9069c71600a8b50cedf31c0ed94f
5
5
  SHA512:
6
- metadata.gz: 2084fd88f1356420e4a4fef1725ff780c5db3e916c473079cf52ea775b7f8891928e03878b8a1881cc0ea901429712b86934217e85b486b4d51ee2a0046bedd2
7
- data.tar.gz: 7ad9a864dd2dc237229a0f23f4f45951c215e13d0d35b4bdfe662635132861c37a91728f60578048f5d778fad5ff044fc31f10bac73962447d4992efa7e584a7
6
+ metadata.gz: cbe1e77c8db14198627aafa50b6e8438446828ddf6ecfed37732fb2cc72db2ff03a344a8bee860677a98eb2d6d85875b626b7119e92ac20884631547e7957309
7
+ data.tar.gz: 890f5eb3fa70152816e5397b39745836ad36efe145eeff80df744dfc09878abbaa3707472eeb53025049dc3ab4e02e0766668ea56cd658f001f9a3f4a3b8514b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## Rails 6.1.5.1 (April 26, 2022) ##
2
+
3
+ * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
4
+
5
+ Escape dangerous characters in names of tags and names of attributes in the
6
+ tag helpers, following the XML specification. Rename the option
7
+ `:escape_attributes` to `:escape`, to simplify by applying the option to the
8
+ whole tag.
9
+
10
+ *Álvaro Martín Fraguas*
11
+
12
+ ## Rails 6.1.5 (March 09, 2022) ##
13
+
14
+ * `preload_link_tag` properly inserts `as` attributes for files with `image` MIME
15
+ types, such as JPG or SVG.
16
+
17
+ *Nate Berkopec*
18
+
19
+ * Add `autocomplete="off"` to all generated hidden fields.
20
+
21
+ Fixes #42610.
22
+
23
+ *Ryan Baumann*
24
+
25
+ * Fix `current_page?` when URL has trailing slash.
26
+
27
+ This fixes the `current_page?` helper when the given URL has a trailing slash,
28
+ and is an absolute URL or also has query params.
29
+
30
+ Fixes #33956.
31
+
32
+ *Jonathan Hefner*
33
+
34
+
35
+ ## Rails 6.1.4.7 (March 08, 2022) ##
36
+
37
+ * No changes.
38
+
39
+
1
40
  ## Rails 6.1.4.6 (February 11, 2022) ##
2
41
 
3
42
  * No changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2020 David Heinemeier Hansson
1
+ Copyright (c) 2004-2022 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -18,4 +18,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
@@ -9,8 +9,8 @@ module ActionView
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 4
13
- PRE = "6"
12
+ TINY = 5
13
+ PRE = "1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -509,7 +509,7 @@ module ActionView
509
509
  "style"
510
510
  elsif extname == "vtt"
511
511
  "track"
512
- elsif (type = mime_type.to_s.split("/")[0]) && type.in?(%w(audio video font))
512
+ elsif (type = mime_type.to_s.split("/")[0]) && type.in?(%w(audio video font image))
513
513
  type
514
514
  end
515
515
  end
@@ -1101,7 +1101,8 @@ module ActionView
1101
1101
  type: "hidden",
1102
1102
  id: input_id_from_type(type),
1103
1103
  name: input_name_from_type(type),
1104
- value: value
1104
+ value: value,
1105
+ autocomplete: "off"
1105
1106
  }.merge!(@html_options.slice(:disabled))
1106
1107
  select_options[:disabled] = "disabled" if @options[:disabled]
1107
1108
 
@@ -241,7 +241,7 @@ module ActionView
241
241
  # # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')"
242
242
  # # type="hidden" value="" />
243
243
  def hidden_field_tag(name, value = nil, options = {})
244
- text_field_tag(name, value, options.merge(type: :hidden))
244
+ text_field_tag(name, value, options.merge(type: :hidden, autocomplete: "off"))
245
245
  end
246
246
 
247
247
  # Creates a file upload field. If you are using file uploads then you will also need
@@ -823,7 +823,7 @@ module ActionView
823
823
  # Use raw HTML to ensure the value is written as an HTML entity; it
824
824
  # needs to be the right character regardless of which encoding the
825
825
  # browser infers.
826
- '<input name="utf8" type="hidden" value="&#x2713;" />'.html_safe
826
+ '<input name="utf8" type="hidden" value="&#x2713;" autocomplete="off" />'.html_safe
827
827
  end
828
828
 
829
829
  private
@@ -53,18 +53,25 @@ module ActionView
53
53
  tag_string(:p, *arguments, **options, &block)
54
54
  end
55
55
 
56
- def tag_string(name, content = nil, escape_attributes: true, **options, &block)
56
+ def tag_string(name, content = nil, **options, &block)
57
+ escape = handle_deprecated_escape_options(options)
58
+
57
59
  content = @view_context.capture(self, &block) if block_given?
58
60
  if VOID_ELEMENTS.include?(name) && content.nil?
59
- "<#{name.to_s.dasherize}#{tag_options(options, escape_attributes)}>".html_safe
61
+ "<#{name.to_s.dasherize}#{tag_options(options, escape)}>".html_safe
60
62
  else
61
- content_tag_string(name.to_s.dasherize, content || "", options, escape_attributes)
63
+ content_tag_string(name.to_s.dasherize, content || "", options, escape)
62
64
  end
63
65
  end
64
66
 
65
67
  def content_tag_string(name, content, options, escape = true)
66
68
  tag_options = tag_options(options, escape) if options
67
- content = ERB::Util.unwrapped_html_escape(content) if escape
69
+
70
+ if escape
71
+ name = ERB::Util.xml_name_escape(name)
72
+ content = ERB::Util.unwrapped_html_escape(content)
73
+ end
74
+
68
75
  "<#{name}#{tag_options}>#{PRE_CONTENT_STRINGS[name]}#{content}</#{name}>".html_safe
69
76
  end
70
77
 
@@ -115,6 +122,8 @@ module ActionView
115
122
  end
116
123
 
117
124
  def tag_option(key, value, escape)
125
+ key = ERB::Util.xml_name_escape(key) if escape
126
+
118
127
  case value
119
128
  when Array, Hash
120
129
  value = TagHelper.build_tag_values(value) if key.to_s == "class"
@@ -123,6 +132,7 @@ module ActionView
123
132
  value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s
124
133
  end
125
134
  value = value.gsub('"', "&quot;") if value.include?('"')
135
+
126
136
  %(#{key}="#{value}")
127
137
  end
128
138
 
@@ -139,6 +149,27 @@ module ActionView
139
149
  true
140
150
  end
141
151
 
152
+ def handle_deprecated_escape_options(options)
153
+ # The option :escape_attributes has been merged into the options hash to be
154
+ # able to warn when it is used, so we need to handle default values here.
155
+ escape_option_provided = options.has_key?(:escape)
156
+ escape_attributes_option_provided = options.has_key?(:escape_attributes)
157
+
158
+ if escape_attributes_option_provided
159
+ ActiveSupport::Deprecation.warn(<<~MSG)
160
+ Use of the option :escape_attributes is deprecated. It currently \
161
+ escapes both names and values of tags and attributes and it is \
162
+ equivalent to :escape. If any of them are enabled, the escaping \
163
+ is fully enabled.
164
+ MSG
165
+ end
166
+
167
+ return true unless escape_option_provided || escape_attributes_option_provided
168
+ escape_option = options.delete(:escape)
169
+ escape_attributes_option = options.delete(:escape_attributes)
170
+ escape_option || escape_attributes_option
171
+ end
172
+
142
173
  def method_missing(called, *args, **options, &block)
143
174
  tag_string(called, *args, **options, &block)
144
175
  end
@@ -202,13 +233,13 @@ module ActionView
202
233
  # tag.div data: { city_state: %w( Chicago IL ) }
203
234
  # # => <div data-city-state="[&quot;Chicago&quot;,&quot;IL&quot;]"></div>
204
235
  #
205
- # The generated attributes are escaped by default. This can be disabled using
206
- # +escape_attributes+.
236
+ # The generated tag names and attributes are escaped by default. This can be disabled using
237
+ # +escape+.
207
238
  #
208
239
  # tag.img src: 'open & shut.png'
209
240
  # # => <img src="open &amp; shut.png">
210
241
  #
211
- # tag.img src: 'open & shut.png', escape_attributes: false
242
+ # tag.img src: 'open & shut.png', escape: false
212
243
  # # => <img src="open & shut.png">
213
244
  #
214
245
  # The tag builder respects
@@ -272,6 +303,7 @@ module ActionView
272
303
  if name.nil?
273
304
  tag_builder
274
305
  else
306
+ name = ERB::Util.xml_name_escape(name) if escape
275
307
  "<#{name}#{tag_builder.tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
276
308
  end
277
309
  end
@@ -280,7 +312,7 @@ module ActionView
280
312
  # HTML attributes by passing an attributes hash to +options+.
281
313
  # Instead of passing the content as an argument, you can also use a block
282
314
  # in which case, you pass your +options+ as the second parameter.
283
- # Set escape to false to disable attribute value escaping.
315
+ # Set escape to false to disable escaping.
284
316
  # Note: this is legacy syntax, see +tag+ method description for details.
285
317
  #
286
318
  # ==== Options
@@ -153,7 +153,7 @@ module ActionView
153
153
  select = content_tag("select", add_options(option_tags, options, value), html_options)
154
154
 
155
155
  if html_options["multiple"] && options.fetch(:include_hidden, true)
156
- tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select
156
+ tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "", autocomplete: "off") + select
157
157
  else
158
158
  select
159
159
  end
@@ -57,7 +57,7 @@ module ActionView
57
57
  end
58
58
 
59
59
  def hidden_field_for_checkbox(options)
60
- @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
60
+ @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value, "autocomplete" => "off")) : "".html_safe
61
61
  end
62
62
  end
63
63
  end
@@ -4,6 +4,10 @@ module ActionView
4
4
  module Helpers
5
5
  module Tags # :nodoc:
6
6
  class HiddenField < TextField # :nodoc:
7
+ def render
8
+ @options[:autocomplete] = "off"
9
+ super
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -337,7 +337,8 @@ module ActionView
337
337
  inner_tags = method_tag.safe_concat(button).safe_concat(request_token_tag)
338
338
  if params
339
339
  to_form_params(params).each do |param|
340
- inner_tags.safe_concat tag(:input, type: "hidden", name: param[:name], value: param[:value])
340
+ inner_tags.safe_concat tag(:input, type: "hidden", name: param[:name], value: param[:value],
341
+ autocomplete: "off")
341
342
  end
342
343
  end
343
344
  content_tag("form", inner_tags, form_options)
@@ -559,16 +560,14 @@ module ActionView
559
560
  request_uri = url_string.index("?") || check_parameters ? request.fullpath : request.path
560
561
  request_uri = URI::DEFAULT_PARSER.unescape(request_uri).force_encoding(Encoding::BINARY)
561
562
 
562
- if url_string.start_with?("/") && url_string != "/"
563
- url_string.chomp!("/")
564
- request_uri.chomp!("/")
565
- end
566
-
567
563
  if %r{^\w+://}.match?(url_string)
568
- url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
569
- else
570
- url_string == request_uri
564
+ request_uri = +"#{request.protocol}#{request.host_with_port}#{request_uri}"
571
565
  end
566
+
567
+ remove_trailing_slash!(url_string)
568
+ remove_trailing_slash!(request_uri)
569
+
570
+ url_string == request_uri
572
571
  end
573
572
 
574
573
  if RUBY_VERSION.start_with?("2.7")
@@ -728,14 +727,14 @@ module ActionView
728
727
  def token_tag(token = nil, form_options: {})
729
728
  if token != false && defined?(protect_against_forgery?) && protect_against_forgery?
730
729
  token ||= form_authenticity_token(form_options: form_options)
731
- tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token)
730
+ tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token, autocomplete: "off")
732
731
  else
733
732
  ""
734
733
  end
735
734
  end
736
735
 
737
736
  def method_tag(method)
738
- tag("input", type: "hidden", name: "_method", value: method.to_s)
737
+ tag("input", type: "hidden", name: "_method", value: method.to_s, autocomplete: "off")
739
738
  end
740
739
 
741
740
  # Returns an array of hashes each containing :name and :value keys
@@ -779,6 +778,11 @@ module ActionView
779
778
 
780
779
  params.sort_by { |pair| pair[:name] }
781
780
  end
781
+
782
+ def remove_trailing_slash!(url_string)
783
+ trailing_index = (url_string.index("?") || 0) - 1
784
+ url_string[trailing_index] = "" if url_string[trailing_index] == "/"
785
+ end
782
786
  end
783
787
  end
784
788
  end
@@ -46,7 +46,7 @@ module ActionView
46
46
  app.config.action_view.each do |k, v|
47
47
  if k == :raise_on_missing_translations
48
48
  ActiveSupport::Deprecation.warn \
49
- "action_view.raise_on_missing_translations is deprecated and will be removed in Rails 6.2. " \
49
+ "action_view.raise_on_missing_translations is deprecated and will be removed in Rails 7.0. " \
50
50
  "Set i18n.raise_on_missing_translations instead. " \
51
51
  "Note that this new setting also affects how missing translations are handled in controllers."
52
52
  end
data/lib/action_view.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2004-2020 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2022 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
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.1.4.6
4
+ version: 6.1.5.1
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: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-04-26 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.1.4.6
19
+ version: 6.1.5.1
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.1.4.6
26
+ version: 6.1.5.1
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.1.4.6
95
+ version: 6.1.5.1
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.1.4.6
102
+ version: 6.1.5.1
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.1.4.6
109
+ version: 6.1.5.1
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.1.4.6
116
+ version: 6.1.5.1
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -239,10 +239,11 @@ licenses:
239
239
  - MIT
240
240
  metadata:
241
241
  bug_tracker_uri: https://github.com/rails/rails/issues
242
- changelog_uri: https://github.com/rails/rails/blob/v6.1.4.6/actionview/CHANGELOG.md
243
- documentation_uri: https://api.rubyonrails.org/v6.1.4.6/
242
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.5.1/actionview/CHANGELOG.md
243
+ documentation_uri: https://api.rubyonrails.org/v6.1.5.1/
244
244
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
245
- source_code_uri: https://github.com/rails/rails/tree/v6.1.4.6/actionview
245
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.5.1/actionview
246
+ rubygems_mfa_required: 'true'
246
247
  post_install_message:
247
248
  rdoc_options: []
248
249
  require_paths:
@@ -259,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
260
  version: '0'
260
261
  requirements:
261
262
  - none
262
- rubygems_version: 3.2.22
263
+ rubygems_version: 3.1.6
263
264
  signing_key:
264
265
  specification_version: 4
265
266
  summary: Rendering framework putting the V in MVC (part of Rails).