File tree 3 files changed +45
-3
lines changed
3 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 14
14
15
15
### Bug Fixes
16
16
17
+ - [ #597 ] : Fixed incorrect processing of namespace scopes in ` NsReader::read_to_end ` .
18
+ The scope started by a start element was not ended after that call.
19
+
17
20
### Misc Changes
18
21
22
+ [ #597 ] : https://github.com/tafia/quick-xml/issues/597
23
+
19
24
20
25
## 0.28.2 -- 2023-04-12
21
26
Original file line number Diff line number Diff line change @@ -760,7 +760,11 @@ impl<'i> NsReader<&'i [u8]> {
760
760
pub fn read_to_end ( & mut self , end : QName ) -> Result < Span > {
761
761
// According to the https://www.w3.org/TR/xml11/#dt-etag, end name should
762
762
// match literally the start name. See `Self::check_end_names` documentation
763
- self . reader . read_to_end ( end)
763
+ let result = self . reader . read_to_end ( end) ?;
764
+ // read_to_end will consume closing tag. Because nobody can access to its
765
+ // content anymore, we directly pop namespace of the opening tag
766
+ self . ns_resolver . pop ( & mut self . buffer ) ;
767
+ Ok ( result)
764
768
}
765
769
766
770
/// Reads content between start and end tags, including any markup. This
Original file line number Diff line number Diff line change 5
5
use std:: sync:: mpsc;
6
6
7
7
use quick_xml:: events:: { BytesStart , Event } ;
8
- use quick_xml:: name:: QName ;
9
- use quick_xml:: reader:: Reader ;
8
+ use quick_xml:: name:: { Namespace , QName , ResolveResult } ;
9
+ use quick_xml:: reader:: { NsReader , Reader } ;
10
10
use quick_xml:: Error ;
11
11
12
12
/// Regression test for https://github.com/tafia/quick-xml/issues/115
@@ -105,3 +105,36 @@ mod issue514 {
105
105
assert_eq ! ( reader. read_event( ) . unwrap( ) , Event :: Eof ) ;
106
106
}
107
107
}
108
+
109
+ #[ test]
110
+ fn issue597 ( ) {
111
+ const S : & ' static str = r#"
112
+ <?xml version="1.0" encoding="UTF-8"?>
113
+ <oval_definitions xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5">
114
+ <tests>
115
+ <xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
116
+ </xmlfilecontent_test>
117
+ <xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
118
+ </xmlfilecontent_test>
119
+ </tests>
120
+ <objects/>
121
+ </oval_definitions>"# ;
122
+
123
+ let mut reader = NsReader :: from_str ( S ) ;
124
+ let ns = loop {
125
+ let ( ns, ev) = reader. read_resolved_event ( ) . unwrap ( ) ;
126
+ match ev {
127
+ Event :: Start ( v) if v. local_name ( ) . as_ref ( ) == b"xmlfilecontent_test" => {
128
+ reader. read_to_end ( v. name ( ) ) . unwrap ( ) ;
129
+ }
130
+ Event :: Empty ( v) if v. local_name ( ) . as_ref ( ) == b"objects" => break ns,
131
+ _ => ( ) ,
132
+ }
133
+ } ;
134
+ assert_eq ! (
135
+ ns,
136
+ ResolveResult :: Bound ( Namespace (
137
+ b"http://oval.mitre.org/XMLSchema/oval-definitions-5"
138
+ ) )
139
+ ) ;
140
+ }
You can’t perform that action at this time.
0 commit comments