From 4af5450ebb183846f2f99b1662f96582baadacad Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 3 Aug 2017 11:25:04 +0100 Subject: [PATCH] Don't suppress default handler unnecessarily (Issue #11) The roles XML_ROLE_DOCTYPE_PUBLIC_ID and XML_ROLE_DOCTYPE_SYSTEM_ID fall through to XML_ROLE_ENTITY_PUBLIC_ID and XML_ROLE_ENTITY_SYSTEM_ID respectively. This lead to the default handler getting suppressed if there was no start doctype declaration handler but there was an entity declaration handler. --- expat/lib/xmlparse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index d247b1fe..28b7a898 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -4501,7 +4501,10 @@ doProlog(XML_Parser parser, normalizePublicId(tem); declEntity->publicId = tem; poolFinish(&dtd->pool); - if (entityDeclHandler) + /* Don't suppress the default handler if we fell through from + * the XML_ROLE_DOCTYPE_PUBLIC_ID case. + */ + if (entityDeclHandler && role == XML_ROLE_ENTITY_PUBLIC_ID) handleDefault = XML_FALSE; } break; @@ -4805,7 +4808,10 @@ doProlog(XML_Parser parser, return XML_ERROR_NO_MEMORY; declEntity->base = curBase; poolFinish(&dtd->pool); - if (entityDeclHandler) + /* Don't suppress the default handler if we fell through from + * the XML_ROLE_DOCTYPE_SYSTEM_ID case. + */ + if (entityDeclHandler && role == XML_ROLE_ENTITY_SYSTEM_ID) handleDefault = XML_FALSE; } break; -- 2.40.0