Bug 35984, make an undefined entity always a fatal error; report errors while parsing external entities (regression) and a minor optimization in loading external entities. r=harishd, sr=jst.

This commit is contained in:
heikki%netscape.com 2002-01-25 23:19:23 +00:00
parent 26ac6b9972
commit 17ab5a619c
4 changed files with 14 additions and 20 deletions

View File

@ -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)

View File

@ -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<nsIURI>* 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

View File

@ -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)

View File

@ -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<nsIURI>* 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