|
| 1 | +Patch taken from https://github.com/ruby/rexml/pull/126/files#diff-93b40740603234e79b1d9be5ff2b3af80f3964a146183cbd698f14d7336726e9 |
| 2 | +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 @@ |
| 6 | + def parse_attributes(prefixes, curr_ns) |
| 7 | + attributes = {} |
| 8 | + closed = false |
| 9 | +- match_data = @source.match(/^(.*?)(\/)?>/um, true) |
| 10 | +- if match_data.nil? |
| 11 | +- message = "Start tag isn't ended" |
| 12 | +- raise REXML::ParseException.new(message, @source) |
| 13 | +- end |
| 14 | +- |
| 15 | +- raw_attributes = match_data[1] |
| 16 | +- closed = !match_data[2].nil? |
| 17 | +- return attributes, closed if raw_attributes.nil? |
| 18 | +- return attributes, closed if raw_attributes.empty? |
| 19 | +- |
| 20 | +- scanner = StringScanner.new(raw_attributes) |
| 21 | +- until scanner.eos? |
| 22 | +- if scanner.scan(/\s+/) |
| 23 | +- break if scanner.eos? |
| 24 | +- end |
| 25 | +- |
| 26 | +- pos = scanner.pos |
| 27 | +- loop do |
| 28 | +- break if scanner.scan(ATTRIBUTE_PATTERN) |
| 29 | +- unless scanner.scan(QNAME) |
| 30 | +- message = "Invalid attribute name: <#{scanner.rest}>" |
| 31 | +- raise REXML::ParseException.new(message, @source) |
| 32 | +- end |
| 33 | +- name = scanner[0] |
| 34 | +- unless scanner.scan(/\s*=\s*/um) |
| 35 | ++ while true |
| 36 | ++ if @source.match(">", true) |
| 37 | ++ return attributes, closed |
| 38 | ++ elsif @source.match("/>", true) |
| 39 | ++ closed = true |
| 40 | ++ return attributes, closed |
| 41 | ++ elsif match = @source.match(QNAME, true) |
| 42 | ++ name = match[1] |
| 43 | ++ prefix = match[2] |
| 44 | ++ local_part = match[3] |
| 45 | ++ unless @source.match(/\s*=\s*/um, true) |
| 46 | + message = "Missing attribute equal: <#{name}>" |
| 47 | + raise REXML::ParseException.new(message, @source) |
| 48 | + end |
| 49 | +- quote = scanner.scan(/['"]/) |
| 50 | +- 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 |
| 60 | ++ unless match = @source.match(/(['"])/, true) |
| 61 | + message = "Missing attribute value start quote: <#{name}>" |
| 62 | + raise REXML::ParseException.new(message, @source) |
| 63 | + end |
| 64 | +- unless scanner.scan(/.*#{Regexp.escape(quote)}/um) |
| 65 | +- match_data = @source.match(/^(.*?)(\/)?>/um, true) |
| 66 | +- if match_data |
| 67 | +- scanner << "/" if closed |
| 68 | +- scanner << ">" |
| 69 | +- scanner << match_data[1] |
| 70 | +- scanner.pos = pos |
| 71 | +- closed = !match_data[2].nil? |
| 72 | +- next |
| 73 | +- end |
| 74 | +- message = |
| 75 | +- "Missing attribute value end quote: <#{name}>: <#{quote}>" |
| 76 | ++ quote = match[1] |
| 77 | ++ value = @source.read_until(quote) |
| 78 | ++ unless value.chomp!(quote) |
| 79 | ++ message = "Missing attribute value end quote: <#{name}>: <#{quote}>" |
| 80 | + raise REXML::ParseException.new(message, @source) |
| 81 | + end |
| 82 | +- end |
| 83 | +- name = scanner[1] |
| 84 | +- prefix = scanner[2] |
| 85 | +- local_part = scanner[3] |
| 86 | +- # quote = scanner[4] |
| 87 | +- value = scanner[5] |
| 88 | ++ value = match[2] |
| 89 | ++ @source.match(/\s*/um, true) |
| 90 | + if prefix == "xmlns" |
| 91 | + if local_part == "xml" |
| 92 | + if value != "http://www.w3.org/XML/1998/namespace" |
| 93 | +diff -ruN a/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb |
| 94 | +--- a/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb 2021-04-05 04:43:38.000000000 -0700 |
| 95 | ++++ b/.bundle/gems/rexml-3.2.5/lib/rexml/source.rb 2024-05-28 17:10:36.356913505 -0700 |
| 96 | +@@ -81,7 +81,11 @@ |
| 97 | + rv |
| 98 | + end |
| 99 | + |
| 100 | +- def read |
| 101 | ++ def read(term = nil) |
| 102 | ++ end |
| 103 | ++ |
| 104 | ++ def read_until(term) |
| 105 | ++ @scanner.scan_until(Regexp.union(term)) or @scanner.rest |
| 106 | + end |
| 107 | + |
| 108 | + def consume( pattern ) |
| 109 | +@@ -204,11 +208,28 @@ |
| 110 | + rv |
| 111 | + end |
| 112 | + |
| 113 | +- def read |
| 114 | ++ def read(term = nil) |
| 115 | + begin |
| 116 | +- @buffer << readline |
| 117 | ++ @scanner << readline(term) |
| 118 | ++ true |
| 119 | + rescue Exception, NameError |
| 120 | + @source = nil |
| 121 | ++ false |
| 122 | ++ end |
| 123 | ++ end |
| 124 | ++ |
| 125 | ++ def read_until(term) |
| 126 | ++ pattern = Regexp.union(term) |
| 127 | ++ data = [] |
| 128 | ++ begin |
| 129 | ++ until str = @scanner.scan_until(pattern) |
| 130 | ++ @scanner << readline(term) |
| 131 | ++ end |
| 132 | ++ rescue EOFError |
| 133 | ++ @scanner.rest |
| 134 | ++ else |
| 135 | ++ read if @scanner.eos? and !@source.eof? |
| 136 | ++ str |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | +@@ -263,8 +284,8 @@ |
| 141 | + end |
| 142 | + |
| 143 | + private |
| 144 | +- def readline |
| 145 | +- str = @source.readline(@line_break) |
| 146 | ++ def readline(term = nil) |
| 147 | ++ str = @source.readline(term || @line_break) |
| 148 | + if @pending_buffer |
| 149 | + if str.nil? |
| 150 | + str = @pending_buffer |
0 commit comments