@@ -524,7 +524,11 @@ impl<R: BufRead> NsReader<R> {
524
524
pub fn read_to_end_into ( & mut self , end : QName , buf : & mut Vec < u8 > ) -> Result < Span > {
525
525
// According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
526
526
// match literally the start name. See `Self::check_end_names` documentation
527
- self . reader . read_to_end_into ( end, buf)
527
+ let result = self . reader . read_to_end_into ( end, buf) ?;
528
+ // read_to_end_into will consume closing tag. Because nobody can access to its
529
+ // content anymore, we directly pop namespace of the opening tag
530
+ self . ns_resolver . pop ( & mut self . buffer ) ;
531
+ Ok ( result)
528
532
}
529
533
}
530
534
@@ -760,7 +764,11 @@ impl<'i> NsReader<&'i [u8]> {
760
764
pub fn read_to_end ( & mut self , end : QName ) -> Result < Span > {
761
765
// According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
762
766
// match literally the start name. See `Self::check_end_names` documentation
763
- self . reader . read_to_end ( end)
767
+ let result = self . reader . read_to_end ( end) ?;
768
+ // read_to_end will consume closing tag. Because nobody can access to its
769
+ // content anymore, we directly pop namespace of the opening tag
770
+ self . ns_resolver . pop ( & mut self . buffer ) ;
771
+ Ok ( result)
764
772
}
765
773
766
774
/// Reads content between start and end tags, including any markup. This
@@ -830,7 +838,13 @@ impl<'i> NsReader<&'i [u8]> {
830
838
/// [`decoder()`]: Reader::decoder()
831
839
#[ inline]
832
840
pub fn read_text ( & mut self , end : QName ) -> Result < Cow < ' i , str > > {
833
- self . reader . read_text ( end)
841
+ // According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
842
+ // match literally the start name. See `Self::check_end_names` documentation
843
+ let result = self . reader . read_text ( end) ?;
844
+ // read_text will consume closing tag. Because nobody can access to its
845
+ // content anymore, we directly pop namespace of the opening tag
846
+ self . ns_resolver . pop ( & mut self . buffer ) ;
847
+ Ok ( result)
834
848
}
835
849
}
836
850
0 commit comments