Skip to content

Commit 6e4ebc6

Browse files
authored
update and correct ruby CVE-2024035176.patch (#9280)
Co-authored-by: minghe <rmhsawyer>
1 parent db8f013 commit 6e4ebc6

1 file changed

Lines changed: 53 additions & 16 deletions

File tree

SPECS/ruby/CVE-2024-35176.patch

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Patch taken from https://github.com/ruby/rexml/pull/126/files#diff-93b40740603234e79b1d9be5ff2b3af80f3964a146183cbd698f14d7336726e9
22
diff -ruN a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
3-
--- a/.bundle/gems/rexml-3.2.5/lib/parsers/baseparser.rb 2021-04-05 04:43:38.000000000 -0700
4-
+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb 2024-05-28 18:53:32.656078157 -0700
5-
@@ -589,60 +589,41 @@
3+
--- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb 2021-04-05 04:43:38.000000000 -0700
4+
+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb 2024-05-31 14:22:29.683378525 -0700
5+
@@ -589,85 +589,58 @@
66
def parse_attributes(prefixes, curr_ns)
77
attributes = {}
88
closed = false
@@ -48,15 +48,6 @@ diff -ruN a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb b/.bundle/g
4848
end
4949
- quote = scanner.scan(/['"]/)
5050
- unless quote
51-
+ unless match = @source.match(/(['"])(.*?)\1\s*/um, true)
52-
+ if match = @source.match(/(['"])/, true)
53-
+ message =
54-
+ "Missing attribute value end quote: <#{name}>: <#{match[1]}>"
55-
+ raise REXML::ParseException.new(message, @source)
56-
+ else
57-
+ message = "Missing attribute value start quote: <#{name}>"
58-
+ raise REXML::ParseException.new(message, @source)
59-
+ end
6051
+ unless match = @source.match(/(['"])/, true)
6152
message = "Missing attribute value start quote: <#{name}>"
6253
raise REXML::ParseException.new(message, @source)
@@ -85,11 +76,57 @@ diff -ruN a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb b/.bundle/g
8576
- local_part = scanner[3]
8677
- # quote = scanner[4]
8778
- value = scanner[5]
88-
+ value = match[2]
79+
- if prefix == "xmlns"
80+
- if local_part == "xml"
81+
- if value != "http://www.w3.org/XML/1998/namespace"
82+
- msg = "The 'xml' prefix must not be bound to any other namespace "+
8983
+ @source.match(/\s*/um, true)
90-
if prefix == "xmlns"
91-
if local_part == "xml"
92-
if value != "http://www.w3.org/XML/1998/namespace"
84+
+ if prefix == "xmlns"
85+
+ if local_part == "xml"
86+
+ if value != "http://www.w3.org/XML/1998/namespace"
87+
+ msg = "The 'xml' prefix must not be bound to any other namespace "+
88+
+ "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
89+
+ raise REXML::ParseException.new( msg, @source, self)
90+
+ end
91+
+ elsif local_part == "xmlns"
92+
+ msg = "The 'xmlns' prefix must not be declared "+
93+
"(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
94+
- raise REXML::ParseException.new( msg, @source, self )
95+
+ raise REXML::ParseException.new( msg, @source, self)
96+
end
97+
- elsif local_part == "xmlns"
98+
- msg = "The 'xmlns' prefix must not be declared "+
99+
- "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
100+
- raise REXML::ParseException.new( msg, @source, self)
101+
+ curr_ns << local_part
102+
+ elsif prefix
103+
+ prefixes << prefix unless prefix == "xml"
104+
end
105+
- curr_ns << local_part
106+
- elsif prefix
107+
- prefixes << prefix unless prefix == "xml"
108+
- end
109+
-
110+
- if attributes.has_key?(name)
111+
- msg = "Duplicate attribute #{name.inspect}"
112+
- raise REXML::ParseException.new(msg, @source, self)
113+
+ if attributes[name]
114+
+ msg = "Duplicate attribute #{name.inspect}"
115+
+ raise REXML::ParseException.new(msg, @source, self)
116+
+ end
117+
+
118+
+ attributes[name] = value
119+
+ else
120+
+ message = "Invalid attribute name: <#{@source.buffer.split(%r{[/>\s]}).first}>"
121+
+ raise REXML::ParseException.new(message, @source)
122+
end
123+
-
124+
- attributes[name] = value
125+
end
126+
- return attributes, closed
127+
end
128+
end
129+
end
93130
diff -ruN a/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb
94131
--- a/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb 2021-04-05 04:43:38.000000000 -0700
95132
+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb 2024-05-28 17:10:36.356913505 -0700

0 commit comments

Comments
 (0)