@@ -115,6 +115,7 @@ class BaseParser
115
115
def initialize ( source )
116
116
self . stream = source
117
117
@listeners = [ ]
118
+ @attributes_scanner = StringScanner . new ( '' )
118
119
end
119
120
120
121
def add_listener ( listener )
@@ -601,36 +602,36 @@ def parse_attributes(prefixes, curr_ns)
601
602
return attributes , closed if raw_attributes . nil?
602
603
return attributes , closed if raw_attributes . empty?
603
604
604
- scanner = StringScanner . new ( raw_attributes )
605
- until scanner . eos?
606
- if scanner . scan ( /\s +/ )
607
- break if scanner . eos?
605
+ @attributes_scanner . string = raw_attributes
606
+ until @attributes_scanner . eos?
607
+ if @attributes_scanner . scan ( /\s +/ )
608
+ break if @attributes_scanner . eos?
608
609
end
609
610
610
- pos = scanner . pos
611
+ pos = @attributes_scanner . pos
611
612
loop do
612
- break if scanner . scan ( ATTRIBUTE_PATTERN )
613
- unless scanner . scan ( QNAME )
614
- message = "Invalid attribute name: <#{ scanner . rest } >"
613
+ break if @attributes_scanner . scan ( ATTRIBUTE_PATTERN )
614
+ unless @attributes_scanner . scan ( QNAME )
615
+ message = "Invalid attribute name: <#{ @attributes_scanner . rest } >"
615
616
raise REXML ::ParseException . new ( message , @source )
616
617
end
617
- name = scanner [ 0 ]
618
- unless scanner . scan ( /\s *=\s */um )
618
+ name = @attributes_scanner [ 0 ]
619
+ unless @attributes_scanner . scan ( /\s *=\s */um )
619
620
message = "Missing attribute equal: <#{ name } >"
620
621
raise REXML ::ParseException . new ( message , @source )
621
622
end
622
- quote = scanner . scan ( /['"]/ )
623
+ quote = @attributes_scanner . scan ( /['"]/ )
623
624
unless quote
624
625
message = "Missing attribute value start quote: <#{ name } >"
625
626
raise REXML ::ParseException . new ( message , @source )
626
627
end
627
- unless scanner . scan ( /.*#{ Regexp . escape ( quote ) } /um )
628
+ unless @attributes_scanner . scan ( /.*#{ Regexp . escape ( quote ) } /um )
628
629
match_data = @source . match ( /^(.*?)(\/ )?>/um , true )
629
630
if match_data
630
- scanner << "/" if closed
631
- scanner << ">"
632
- scanner << match_data [ 1 ]
633
- scanner . pos = pos
631
+ @attributes_scanner << "/" if closed
632
+ @attributes_scanner << ">"
633
+ @attributes_scanner << match_data [ 1 ]
634
+ @attributes_scanner . pos = pos
634
635
closed = !match_data [ 2 ] . nil?
635
636
next
636
637
end
@@ -639,11 +640,11 @@ def parse_attributes(prefixes, curr_ns)
639
640
raise REXML ::ParseException . new ( message , @source )
640
641
end
641
642
end
642
- name = scanner [ 1 ]
643
- prefix = scanner [ 2 ]
644
- local_part = scanner [ 3 ]
645
- # quote = scanner [4]
646
- value = scanner [ 5 ]
643
+ name = @attributes_scanner [ 1 ]
644
+ prefix = @attributes_scanner [ 2 ]
645
+ local_part = @attributes_scanner [ 3 ]
646
+ # quote = @attributes_scanner [4]
647
+ value = @attributes_scanner [ 5 ]
647
648
if prefix == "xmlns"
648
649
if local_part == "xml"
649
650
if value != "http://www.w3.org/XML/1998/namespace"
0 commit comments