From b1bcd0060a0a95da2d865398079cfef2445dfbce Mon Sep 17 00:00:00 2001 From: Clark Cooper Date: Fri, 20 Oct 2000 15:37:28 +0000 Subject: [PATCH] Remove aborts and instead return an UNEXPECTED_STATE error. --- expat/Changes | 5 +++-- expat/lib/expat.h | 3 ++- expat/lib/xmlparse.c | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/expat/Changes b/expat/Changes index d957edaa..b9dbaae5 100644 --- a/expat/Changes +++ b/expat/Changes @@ -1,5 +1,6 @@ - - Fixed a bug where parameter entities weren't being expanded inside - entity literals. + - Removed all aborts and instead return an UNEXPECTED_STATE error. + - Fixed a bug where a stray '%' in an entity value would cause an + abort. - Defined XML_SetEndNamespaceDeclHandler. Thanks to Darryl Miles for finding this oversight. - Changed default patterns in lib/Makefile.in to fit non-GNU makes diff --git a/expat/lib/expat.h b/expat/lib/expat.h index d913e599..d43072d8 100644 --- a/expat/lib/expat.h +++ b/expat/lib/expat.h @@ -646,7 +646,8 @@ enum XML_Error { XML_ERROR_INCORRECT_ENCODING, XML_ERROR_UNCLOSED_CDATA_SECTION, XML_ERROR_EXTERNAL_ENTITY_HANDLING, - XML_ERROR_NOT_STANDALONE + XML_ERROR_NOT_STANDALONE, + XML_ERROR_UNEXPECTED_STATE }; /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index 96c9c415..85432d39 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -4,7 +4,7 @@ See the file COPYING for copying permission. */ static char RCSId[] - = "$Header: /cvsroot/expat/expat/lib/xmlparse.c,v 1.8 2000/10/10 18:48:48 coopercc Exp $"; + = "$Header: /cvsroot/expat/expat/lib/xmlparse.c,v 1.9 2000/10/20 15:14:36 coopercc Exp $"; #include @@ -1284,7 +1284,7 @@ const XML_LChar *XML_ErrorString(int code) XML_T("out of memory"), XML_T("syntax error"), XML_T("no element found"), - XML_T("not well-formed"), + XML_T("not well-formed (invalid token)"), XML_T("unclosed token"), XML_T("unclosed token"), XML_T("mismatched tag"), @@ -1302,7 +1302,8 @@ const XML_LChar *XML_ErrorString(int code) XML_T("encoding specified in XML declaration is incorrect"), XML_T("unclosed CDATA section"), XML_T("error in processing external entity reference"), - XML_T("document is not standalone") + XML_T("document is not standalone"), + XML_T("unexpected parser state - please send a bug report") }; if (code > 0 && code < sizeof(message)/sizeof(message[0])) return message[code]; @@ -2233,7 +2234,8 @@ enum XML_Error doCdataSection(XML_Parser parser, } return XML_ERROR_UNCLOSED_CDATA_SECTION; default: - abort(); + *eventPP = next; + return XML_ERROR_UNEXPECTED_STATE; } *eventPP = s = next; } @@ -2310,7 +2312,8 @@ enum XML_Error doIgnoreSection(XML_Parser parser, } return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ default: - abort(); + *eventPP = next; + return XML_ERROR_UNEXPECTED_STATE; } /* not reached */ } @@ -3459,7 +3462,9 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, } break; default: - abort(); + if (enc == encoding) + eventPtr = ptr; + return XML_ERROR_UNEXPECTED_STATE; } ptr = next; } @@ -3565,7 +3570,9 @@ enum XML_Error storeEntityValue(XML_Parser parser, eventPtr = next; return XML_ERROR_INVALID_TOKEN; default: - abort(); + if (enc == encoding) + eventPtr = entityTextPtr; + return XML_ERROR_UNEXPECTED_STATE; } entityTextPtr = next; }