@@ -524,7 +524,11 @@ impl<R: BufRead> NsReader<R> {
524524 pub fn read_to_end_into ( & mut self , end : QName , buf : & mut Vec < u8 > ) -> Result < Span > {
525525 // According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
526526 // 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)
528532 }
529533}
530534
@@ -760,7 +764,11 @@ impl<'i> NsReader<&'i [u8]> {
760764 pub fn read_to_end ( & mut self , end : QName ) -> Result < Span > {
761765 // According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
762766 // 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)
764772 }
765773
766774 /// Reads content between start and end tags, including any markup. This
@@ -830,7 +838,13 @@ impl<'i> NsReader<&'i [u8]> {
830838 /// [`decoder()`]: Reader::decoder()
831839 #[ inline]
832840 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)
834848 }
835849}
836850
0 commit comments