File tree 3 files changed +81
-1
lines changed 3 files changed +81
-1
lines changed Original file line number Diff line number Diff line change 18
18
19
19
### Bug Fixes
20
20
21
+ - [ #603 ] : Fix a regression from [ #581 ] that an XML comment or a processing
22
+ instruction between a <! DOCTYPE> and the root element in the file brokes
23
+ deserialization of structs by returning ` DeError::ExpectedStart `
24
+
21
25
### Misc Changes
22
26
27
+ [ #581 ] : https://github.com/tafia/quick-xml/pull/581
23
28
[ #601 ] : https://github.com/tafia/quick-xml/pull/601
29
+ [ #603 ] : https://github.com/tafia/quick-xml/pull/603
24
30
[ #606 ] : https://github.com/tafia/quick-xml/pull/606
25
31
26
32
Original file line number Diff line number Diff line change @@ -2880,7 +2880,7 @@ impl StartTrimmer {
2880
2880
#[ inline( always) ]
2881
2881
fn trim < ' a > ( & mut self , event : Event < ' a > ) -> Option < PayloadEvent < ' a > > {
2882
2882
let ( event, trim_next_event) = match event {
2883
- Event :: DocType ( e) => ( PayloadEvent :: DocType ( e) , false ) ,
2883
+ Event :: DocType ( e) => ( PayloadEvent :: DocType ( e) , true ) ,
2884
2884
Event :: Start ( e) => ( PayloadEvent :: Start ( e) , true ) ,
2885
2885
Event :: End ( e) => ( PayloadEvent :: End ( e) , true ) ,
2886
2886
Event :: Eof => ( PayloadEvent :: Eof , true ) ,
Original file line number Diff line number Diff line change @@ -6496,3 +6496,77 @@ mod resolve {
6496
6496
) ;
6497
6497
}
6498
6498
}
6499
+
6500
+ /// Tests for https://github.com/tafia/quick-xml/pull/603.
6501
+ ///
6502
+ /// According to <https://www.w3.org/TR/xml11/#NT-prolog> comments,
6503
+ /// processing instructions and spaces are possible after XML declaration or DTD.
6504
+ /// Their existence should not break deserializing
6505
+ ///
6506
+ /// ```text
6507
+ /// [22] prolog ::= XMLDecl Misc* (doctypedecl Misc*)?
6508
+ /// [27] Misc ::= Comment | PI | S
6509
+ /// ```
6510
+ mod xml_prolog {
6511
+ use super :: * ;
6512
+ use pretty_assertions:: assert_eq;
6513
+ use std:: collections:: HashMap ;
6514
+
6515
+ #[ test]
6516
+ fn spaces ( ) {
6517
+ assert_eq ! (
6518
+ from_str:: <HashMap <( ) , ( ) >>(
6519
+ r#"
6520
+ <?xml version="1.1"?>
6521
+
6522
+ <!DOCTYPE dict>
6523
+
6524
+ <doc>
6525
+ </doc>
6526
+ "#
6527
+ )
6528
+ . unwrap( ) ,
6529
+ HashMap :: new( )
6530
+ ) ;
6531
+ }
6532
+
6533
+ #[ test]
6534
+ fn comments ( ) {
6535
+ assert_eq ! (
6536
+ from_str:: <HashMap <( ) , ( ) >>(
6537
+ r#"
6538
+ <?xml version="1.1"?>
6539
+ <!-- comment between xml declaration and doctype -->
6540
+ <!-- another comment -->
6541
+ <!DOCTYPE dict>
6542
+ <!-- comment between doctype and root element -->
6543
+ <!-- another comment -->
6544
+ <doc>
6545
+ </doc>
6546
+ "# ,
6547
+ )
6548
+ . unwrap( ) ,
6549
+ HashMap :: new( )
6550
+ ) ;
6551
+ }
6552
+
6553
+ #[ test]
6554
+ fn pi ( ) {
6555
+ assert_eq ! (
6556
+ from_str:: <HashMap <( ) , ( ) >>(
6557
+ r#"
6558
+ <?xml version="1.1"?>
6559
+ <?pi?>
6560
+ <?another pi?>
6561
+ <!DOCTYPE dict>
6562
+ <?pi?>
6563
+ <?another pi?>
6564
+ <doc>
6565
+ </doc>
6566
+ "# ,
6567
+ )
6568
+ . unwrap( ) ,
6569
+ HashMap :: new( )
6570
+ ) ;
6571
+ }
6572
+ }
You can’t perform that action at this time.
0 commit comments