]> granicus.if.org Git - libexpat/commitdiff
Test malformed XML/text declaration rejected by ext entity parser
authorRhodri James <rhodri@kynesim.co.uk>
Thu, 2 Mar 2017 16:46:29 +0000 (16:46 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 19:29:03 +0000 (21:29 +0200)
expat/tests/runtests.c

index e40e679449d00e0dad917dd7199bae93061279b1..a3d5bccdc22ee7f7e1dba3a663feec377756ee1e 100644 (file)
@@ -3689,6 +3689,7 @@ external_entity_valuer(XML_Parser parser,
     else if (!strcmp(systemId, "004-2.ent")) {
         ExtFaults *fault = (ExtFaults *)XML_GetUserData(parser);
         enum XML_Status status;
+        enum XML_Error error;
 
         status = _XML_Parse_SINGLE_BYTES(ext_parser,
                                          fault->parse_text,
@@ -3700,7 +3701,10 @@ external_entity_valuer(XML_Parser parser,
         } else {
             if (status != XML_STATUS_ERROR)
                 fail(fault->fail_text);
-            if (XML_GetErrorCode(ext_parser) != fault->error)
+            error = XML_GetErrorCode(ext_parser);
+            if (error != fault->error &&
+                (fault->error != XML_ERROR_XML_DECL ||
+                 error != XML_ERROR_TEXT_DECL))
                 xml_failure(ext_parser);
         }
     }
@@ -3745,6 +3749,12 @@ START_TEST(test_external_entity_values)
             NULL,
             XML_ERROR_NONE
         },
+        {
+            "<?xml?>",
+            "Malformed XML declaration not faulted",
+            NULL,
+            XML_ERROR_XML_DECL
+        },
         { NULL, NULL, NULL, XML_ERROR_NONE }
     };
     int i;