File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -766,6 +766,25 @@ def process_instruction
766
766
[ :processing_instruction , name , content ]
767
767
end
768
768
769
+ if StringScanner ::Version < "3.1.1"
770
+ def scan_quote
771
+ @source . match ( /(['"])/ , true ) &.[]( 1 )
772
+ end
773
+ else
774
+ def scan_quote
775
+ case @source . peek_byte
776
+ when 34 # '"'.ord
777
+ @source . scan_byte
778
+ '"'
779
+ when 39 # "'".ord
780
+ @source . scan_byte
781
+ "'"
782
+ else
783
+ nil
784
+ end
785
+ end
786
+ end
787
+
769
788
def parse_attributes ( prefixes )
770
789
attributes = { }
771
790
expanded_names = { }
@@ -785,11 +804,10 @@ def parse_attributes(prefixes)
785
804
message = "Missing attribute equal: <#{ name } >"
786
805
raise REXML ::ParseException . new ( message , @source )
787
806
end
788
- unless match = @source . match ( /(['"])/ , true )
807
+ unless quote = scan_quote
789
808
message = "Missing attribute value start quote: <#{ name } >"
790
809
raise REXML ::ParseException . new ( message , @source )
791
810
end
792
- quote = match [ 1 ]
793
811
start_position = @source . position
794
812
value = @source . read_until ( quote )
795
813
unless value . chomp! ( quote )
Original file line number Diff line number Diff line change @@ -158,6 +158,14 @@ def position=(pos)
158
158
@scanner . pos = pos
159
159
end
160
160
161
+ def peek_byte
162
+ @scanner . peek_byte
163
+ end
164
+
165
+ def scan_byte
166
+ @scanner . scan_byte
167
+ end
168
+
161
169
# @return true if the Source is exhausted
162
170
def empty?
163
171
@scanner . eos?
You can’t perform that action at this time.
0 commit comments