File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 5757- [ #9 ] : Added tests for incorrect nested tags in input
5858- [ #387 ] : Added a bunch of tests for sequences deserialization
5959- [ #393 ] : Added more tests for namespace resolver
60+ - [ #393 ] : Added tests for reserved names (started with "xml"i) -- see < https://www.w3.org/TR/xml-names11/#xmlReserved >
6061
6162[ #8 ] : https://github.com/Mingun/fast-xml/pull/8
6263[ #9 ] : https://github.com/Mingun/fast-xml/pull/9
Original file line number Diff line number Diff line change @@ -349,3 +349,29 @@ fn default_ns_shadowing_expanded() {
349349 e => panic ! ( "Expected End event (</outer>), got {:?}" , e) ,
350350 }
351351}
352+
353+ /// Although the XML specification [recommends against] the use of names where
354+ /// the local name portion begins with the letters "xml" (case insensitive),
355+ /// it also specifies, that processors *MUST NOT* treat them as fatal errors.
356+ /// That means, that processing should continue -- in our case we should read
357+ /// an XML event and user should be able to check constraints later if he/she wish.
358+ ///
359+ /// [recommends against]: https://www.w3.org/TR/xml-names11/#xmlReserved
360+ #[ test]
361+ fn reserved_name ( ) {
362+ // Name "xmlns-something" is reserved according to spec, because started with "xml"
363+ let mut r = Reader :: from_str ( r#"<a xmlns-something="reserved attribute name" xmlns="www1"/>"# ) ;
364+ r. trim_text ( true ) ;
365+
366+ let mut buf = Vec :: new ( ) ;
367+ let mut ns_buf = Vec :: new ( ) ;
368+
369+ // <a />
370+ match r. read_namespaced_event ( & mut buf, & mut ns_buf) {
371+ Ok ( ( ns, Empty ( _) ) ) => assert_eq ! ( ns, Bound ( Namespace ( b"www1" ) ) ) ,
372+ e => panic ! (
373+ "Expected empty element bound to namespace 'www1', got {:?}" ,
374+ e
375+ ) ,
376+ }
377+ }
You can’t perform that action at this time.
0 commit comments