actionview 6.0.4.7 → 6.0.4.8

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: 6a02c1e3b3bb79351d1ff2d6ff4e18ac281f735e3c3e9688a0ee980e59467881
4
- data.tar.gz: b01d9a6277d2cbc47f4ceeea6c31d4e4b867a44225ac1c28701c9ae1e2996e6d
3
+ metadata.gz: 7d4524ccde8ccdd97c429c6fb86a446f168cd38a2fb7cb613eae1a12a856ab7b
4
+ data.tar.gz: af9127d2426172fd15893a0677cd47693a8b756834b75b9eba9e4d597af02129
5
5
  SHA512:
6
- metadata.gz: b1eb31601a70f6b6f70266e61f8279e354f746a62062ac03de88fb995ace71a8dc615bd10b2da0438758672a9efffd82d9d09ef2bfde54f546e21c977a5ce0fc
7
- data.tar.gz: a9be61ff408fcb1ed270af84aca45707017800b8a3ec9ff8b1e19e73c6d4d16e632c10749b9475f06ed410bac1c57c0c7a00f033a5a16c134c1cf028461d3aee
6
+ metadata.gz: f05445155e060f21a2bb32165685270986019c49eb9b39c830e1acc99e6962f0f258fc3183b5cbaebfa1f69bbe10a176a4b9b653d5e53d5e0fbbbc80827a72a1
7
+ data.tar.gz: 216d174d5aac9ae24c91e79f1d4d7d3e9c8aec6af7ebd27d239147fd23e702827dc7730e32ee86bf8d0ec12aca358f84e1b8987406bbcfdb8100eba3970143ba
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## Rails 6.0.4.8 (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
+
1
13
  ## Rails 6.0.4.7 (March 08, 2022) ##
2
14
 
3
15
  * No changes.
@@ -10,7 +10,7 @@ module ActionView
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
12
  TINY = 4
13
- PRE = "7"
13
+ PRE = "8"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -41,18 +41,25 @@ module ActionView
41
41
  @view_context = view_context
42
42
  end
43
43
 
44
- def tag_string(name, content = nil, escape_attributes: true, **options, &block)
44
+ def tag_string(name, content = nil, **options, &block)
45
+ escape = handle_deprecated_escape_options(options)
45
46
  content = @view_context.capture(self, &block) if block_given?
47
+
46
48
  if VOID_ELEMENTS.include?(name) && content.nil?
47
- "<#{name.to_s.dasherize}#{tag_options(options, escape_attributes)}>".html_safe
49
+ "<#{name.to_s.dasherize}#{tag_options(options, escape)}>".html_safe
48
50
  else
49
- content_tag_string(name.to_s.dasherize, content || "", options, escape_attributes)
51
+ content_tag_string(name.to_s.dasherize, content || "", options, escape)
50
52
  end
51
53
  end
52
54
 
53
55
  def content_tag_string(name, content, options, escape = true)
54
56
  tag_options = tag_options(options, escape) if options
55
- content = ERB::Util.unwrapped_html_escape(content) if escape
57
+
58
+ if escape
59
+ name = ERB::Util.xml_name_escape(name)
60
+ content = ERB::Util.unwrapped_html_escape(content)
61
+ end
62
+
56
63
  "<#{name}#{tag_options}>#{PRE_CONTENT_STRINGS[name]}#{content}</#{name}>".html_safe
57
64
  end
58
65
 
@@ -85,6 +92,8 @@ module ActionView
85
92
  end
86
93
 
87
94
  def tag_option(key, value, escape)
95
+ key = ERB::Util.xml_name_escape(key) if escape
96
+
88
97
  if value.is_a?(Array)
89
98
  value = escape ? safe_join(value, " ") : value.join(" ")
90
99
  else
@@ -107,6 +116,27 @@ module ActionView
107
116
  true
108
117
  end
109
118
 
119
+ def handle_deprecated_escape_options(options)
120
+ # The option :escape_attributes has been merged into the options hash to be
121
+ # able to warn when it is used, so we need to handle default values here.
122
+ escape_option_provided = options.has_key?(:escape)
123
+ escape_attributes_option_provided = options.has_key?(:escape_attributes)
124
+
125
+ if escape_attributes_option_provided
126
+ ActiveSupport::Deprecation.warn(<<~MSG)
127
+ Use of the option :escape_attributes is deprecated. It currently \
128
+ escapes both names and values of tags and attributes and it is \
129
+ equivalent to :escape. If any of them are enabled, the escaping \
130
+ is fully enabled.
131
+ MSG
132
+ end
133
+
134
+ return true unless escape_option_provided || escape_attributes_option_provided
135
+ escape_option = options.delete(:escape)
136
+ escape_attributes_option = options.delete(:escape_attributes)
137
+ escape_option || escape_attributes_option
138
+ end
139
+
110
140
  def method_missing(called, *args, **options, &block)
111
141
  tag_string(called, *args, **options, &block)
112
142
  end
@@ -237,6 +267,7 @@ module ActionView
237
267
  if name.nil?
238
268
  tag_builder
239
269
  else
270
+ name = ERB::Util.xml_name_escape(name) if escape
240
271
  "<#{name}#{tag_builder.tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
241
272
  end
242
273
  end
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.7
4
+ version: 6.0.4.8
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-03-08 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.0.4.7
19
+ version: 6.0.4.8
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.4.7
26
+ version: 6.0.4.8
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.4.7
95
+ version: 6.0.4.8
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.4.7
102
+ version: 6.0.4.8
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.4.7
109
+ version: 6.0.4.8
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.4.7
116
+ version: 6.0.4.8
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -236,10 +236,10 @@ licenses:
236
236
  - MIT
237
237
  metadata:
238
238
  bug_tracker_uri: https://github.com/rails/rails/issues
239
- changelog_uri: https://github.com/rails/rails/blob/v6.0.4.7/actionview/CHANGELOG.md
240
- documentation_uri: https://api.rubyonrails.org/v6.0.4.7/
239
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.4.8/actionview/CHANGELOG.md
240
+ documentation_uri: https://api.rubyonrails.org/v6.0.4.8/
241
241
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
242
- source_code_uri: https://github.com/rails/rails/tree/v6.0.4.7/actionview
242
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.4.8/actionview
243
243
  post_install_message:
244
244
  rdoc_options: []
245
245
  require_paths: