diff --git a/mozilla/expat/xmlparse/xmlparse.c b/mozilla/expat/xmlparse/xmlparse.c index d3033c3a8cc..b9c67c172f8 100644 --- a/mozilla/expat/xmlparse/xmlparse.c +++ b/mozilla/expat/xmlparse/xmlparse.c @@ -1278,13 +1278,8 @@ doContent(XML_Parser parser, return XML_ERROR_NO_MEMORY; entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); poolDiscard(&dtd.pool); - if (!entity) { - if (dtd.complete || dtd.standalone) - return XML_ERROR_UNDEFINED_ENTITY; - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } + if (!entity) + return XML_ERROR_UNDEFINED_ENTITY; if (entity->open) return XML_ERROR_RECURSIVE_ENTITY_REF; if (entity->notation) @@ -2959,8 +2954,8 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, if (dtd.complete) { if (enc == encoding) eventPtr = ptr; - return XML_ERROR_UNDEFINED_ENTITY; } + return XML_ERROR_UNDEFINED_ENTITY; } else if (entity->open) { if (enc == encoding) diff --git a/mozilla/htmlparser/src/nsExpatDriver.cpp b/mozilla/htmlparser/src/nsExpatDriver.cpp index b0c63c3d232..daa0c818867 100644 --- a/mozilla/htmlparser/src/nsExpatDriver.cpp +++ b/mozilla/htmlparser/src/nsExpatDriver.cpp @@ -200,7 +200,7 @@ Driver_HandleExternalEntityRef(XML_Parser parser, XML_SetBase(entParser, (const XML_Char*) absURL.get()); - while (NS_SUCCEEDED(uniIn->Read(uniBuf, 0, 1024, &readCount))) { + while (NS_SUCCEEDED(uniIn->Read(uniBuf, 0, 1024, &readCount)) && result) { if (readCount) { // Pass the buffer to expat for parsing result = XML_Parse(entParser, (char *)uniBuf, readCount * sizeof(PRUnichar), 0); @@ -459,7 +459,9 @@ IsLoadableDTD(const XML_Char* aFPIStr, nsCOMPtr* aDTD) if (!isLoadable) { // try to see if we can map the public ID to a known local DTD nsXPIDLCString fileName; - RemapDTD(aFPIStr, fileName); + if (aFPIStr) { + RemapDTD(aFPIStr, fileName); + } if (fileName.IsEmpty()) { // try to see if the user has installed the DTD file -- we extract the // filename.ext of the DTD here. Hence, for any DTD for which we have diff --git a/mozilla/parser/expat/lib/xmlparse.c b/mozilla/parser/expat/lib/xmlparse.c index d3033c3a8cc..b9c67c172f8 100644 --- a/mozilla/parser/expat/lib/xmlparse.c +++ b/mozilla/parser/expat/lib/xmlparse.c @@ -1278,13 +1278,8 @@ doContent(XML_Parser parser, return XML_ERROR_NO_MEMORY; entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); poolDiscard(&dtd.pool); - if (!entity) { - if (dtd.complete || dtd.standalone) - return XML_ERROR_UNDEFINED_ENTITY; - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } + if (!entity) + return XML_ERROR_UNDEFINED_ENTITY; if (entity->open) return XML_ERROR_RECURSIVE_ENTITY_REF; if (entity->notation) @@ -2959,8 +2954,8 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, if (dtd.complete) { if (enc == encoding) eventPtr = ptr; - return XML_ERROR_UNDEFINED_ENTITY; } + return XML_ERROR_UNDEFINED_ENTITY; } else if (entity->open) { if (enc == encoding) diff --git a/mozilla/parser/htmlparser/src/nsExpatDriver.cpp b/mozilla/parser/htmlparser/src/nsExpatDriver.cpp index b0c63c3d232..daa0c818867 100644 --- a/mozilla/parser/htmlparser/src/nsExpatDriver.cpp +++ b/mozilla/parser/htmlparser/src/nsExpatDriver.cpp @@ -200,7 +200,7 @@ Driver_HandleExternalEntityRef(XML_Parser parser, XML_SetBase(entParser, (const XML_Char*) absURL.get()); - while (NS_SUCCEEDED(uniIn->Read(uniBuf, 0, 1024, &readCount))) { + while (NS_SUCCEEDED(uniIn->Read(uniBuf, 0, 1024, &readCount)) && result) { if (readCount) { // Pass the buffer to expat for parsing result = XML_Parse(entParser, (char *)uniBuf, readCount * sizeof(PRUnichar), 0); @@ -459,7 +459,9 @@ IsLoadableDTD(const XML_Char* aFPIStr, nsCOMPtr* aDTD) if (!isLoadable) { // try to see if we can map the public ID to a known local DTD nsXPIDLCString fileName; - RemapDTD(aFPIStr, fileName); + if (aFPIStr) { + RemapDTD(aFPIStr, fileName); + } if (fileName.IsEmpty()) { // try to see if the user has installed the DTD file -- we extract the // filename.ext of the DTD here. Hence, for any DTD for which we have