mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
parser: Don't create reference in xmlLookupGeneralEntity
This should only be done in xmlParseReference. The handling of undeclared entities is still somewhat inconsistent. In element content we create references even if entity substitution is enabled. In attribute values undeclared entities are always ignored.
This commit is contained in:
25
parser.c
25
parser.c
@@ -7363,9 +7363,22 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
* We are seeing an entity reference
|
||||
*/
|
||||
name = xmlParseEntityRefInternal(ctxt);
|
||||
if (name != NULL)
|
||||
ent = xmlLookupGeneralEntity(ctxt, name, /* isAttr */ 0);
|
||||
if (ent == NULL) return;
|
||||
if (name == NULL)
|
||||
return;
|
||||
ent = xmlLookupGeneralEntity(ctxt, name, /* isAttr */ 0);
|
||||
if (ent == NULL) {
|
||||
/*
|
||||
* Create a reference for undeclared entities.
|
||||
* TODO: Should we really create a reference if entity
|
||||
* substitution is enabled?
|
||||
*/
|
||||
if ((ctxt->sax != NULL) &&
|
||||
(ctxt->disableSAX == 0) &&
|
||||
(ctxt->sax->reference != NULL)) {
|
||||
ctxt->sax->reference(ctxt->userData, name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!ctxt->wellFormed)
|
||||
return;
|
||||
|
||||
@@ -7602,12 +7615,6 @@ xmlLookupGeneralEntity(xmlParserCtxtPtr ctxt, const xmlChar *name, int inAttr) {
|
||||
} else {
|
||||
xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
|
||||
"Entity '%s' not defined\n", name, NULL);
|
||||
if ((ctxt->inSubset == 0) &&
|
||||
(ctxt->sax != NULL) &&
|
||||
(ctxt->disableSAX == 0) &&
|
||||
(ctxt->sax->reference != NULL)) {
|
||||
ctxt->sax->reference(ctxt->userData, name);
|
||||
}
|
||||
}
|
||||
ctxt->valid = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user