]> granicus.if.org Git - libexpat/commitdiff
Extend skip handler test coverage
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 14 Feb 2017 12:20:08 +0000 (12:20 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 21:02:30 +0000 (23:02 +0200)
expat/tests/runtests.c

index 18cfe795b4b9df4b129db63a0def84dd154aa3e6..eb7f6d6de1ef37c48fb16bb8be72dfd8586b4f06 100644 (file)
@@ -2094,6 +2094,15 @@ record_cdata_nodefault_handler(void *userData,
     CharData_AppendString((CharData *)userData, "c");
 }
 
+static void XMLCALL
+record_skip_handler(void *userData,
+                    const XML_Char *UNUSED_P(entityName),
+                    int is_parameter_entity)
+{
+    CharData_AppendString((CharData *)userData,
+                          is_parameter_entity ? "E" : "e");
+}
+
 /* Test XML_DefaultCurrent() passes handling on correctly */
 START_TEST(test_default_current)
 {
@@ -2137,6 +2146,19 @@ START_TEST(test_default_current)
     /* The default handler suppresses the entity */
     CharData_CheckString(&storage, "DDDDDDDDDDDDDDDDDDD");
 
+    /* Again, with a skip handler */
+    XML_ParserReset(parser, NULL);
+    XML_SetDefaultHandler(parser, record_default_handler);
+    XML_SetCharacterDataHandler(parser, record_cdata_handler);
+    XML_SetSkippedEntityHandler(parser, record_skip_handler);
+    CharData_Init(&storage);
+    XML_SetUserData(parser, &storage);
+    if (_XML_Parse_SINGLE_BYTES(parser, entity_text, strlen(entity_text),
+                                XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+    /* The default handler suppresses the entity */
+    CharData_CheckString(&storage, "DDDDDDDDDDDDDDDDDeD");
+
     /* This time, allow the entity through */
     XML_ParserReset(parser, NULL);
     XML_SetDefaultHandlerExpand(parser, record_default_handler);