mirror of
https://github.com/GNOME/libxml2.git
synced 2025-10-15 12:57:28 +08:00
valid: Don't add ids when validating entity content
The id table shouldn't reference ids in entities. The id will be created
when expanding the entity.
Probably regressed with d025cfbb
.
Note that we still register ids in entities if entities are not
replaced. This is required to make IDREF checks work.
Fixes #974.
This commit is contained in:
22
SAX2.c
22
SAX2.c
@@ -1190,8 +1190,19 @@ xmlSAX1Attribute(xmlParserCtxtPtr ctxt, const xmlChar *fullname,
|
|||||||
xmlFree(val);
|
xmlFree(val);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* When replacing entities, make sure that IDs in
|
||||||
|
* entities aren't registered. This also shouldn't be
|
||||||
|
* done when entities aren't replaced, but this would
|
||||||
|
* require to rework IDREF checks.
|
||||||
|
*/
|
||||||
|
if (ctxt->input->entity != NULL)
|
||||||
|
ctxt->vctxt.flags |= XML_VCTXT_IN_ENTITY;
|
||||||
|
|
||||||
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
|
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
|
||||||
ctxt->node, ret, value);
|
ctxt->node, ret, value);
|
||||||
|
|
||||||
|
ctxt->vctxt.flags &= ~XML_VCTXT_IN_ENTITY;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* LIBXML_VALID_ENABLED */
|
#endif /* LIBXML_VALID_ENABLED */
|
||||||
@@ -2057,8 +2068,19 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
|
|||||||
if (dup == NULL)
|
if (dup == NULL)
|
||||||
xmlSAX2ErrMemory(ctxt);
|
xmlSAX2ErrMemory(ctxt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When replacing entities, make sure that IDs in
|
||||||
|
* entities aren't registered. This also shouldn't be
|
||||||
|
* done when entities aren't replaced, but this would
|
||||||
|
* require to rework IDREF checks.
|
||||||
|
*/
|
||||||
|
if (ctxt->input->entity != NULL)
|
||||||
|
ctxt->vctxt.flags |= XML_VCTXT_IN_ENTITY;
|
||||||
|
|
||||||
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
|
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
|
||||||
ctxt->myDoc, ctxt->node, ret, dup);
|
ctxt->myDoc, ctxt->node, ret, dup);
|
||||||
|
|
||||||
|
ctxt->vctxt.flags &= ~XML_VCTXT_IN_ENTITY;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* LIBXML_VALID_ENABLED */
|
#endif /* LIBXML_VALID_ENABLED */
|
||||||
|
@@ -22,6 +22,10 @@
|
|||||||
* Set if the validation is enabled.
|
* Set if the validation is enabled.
|
||||||
*/
|
*/
|
||||||
#define XML_VCTXT_VALIDATE (1u << 2)
|
#define XML_VCTXT_VALIDATE (1u << 2)
|
||||||
|
/**
|
||||||
|
* Set when parsing entities.
|
||||||
|
*/
|
||||||
|
#define XML_VCTXT_IN_ENTITY (1u << 3)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Rename to avoid confusion with xmlParserInputFlags
|
* TODO: Rename to avoid confusion with xmlParserInputFlags
|
||||||
|
3
valid.c
3
valid.c
@@ -3962,7 +3962,8 @@ xmlValidateOneAttribute(xmlValidCtxt *ctxt, xmlDoc *doc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Validity Constraint: ID uniqueness */
|
/* Validity Constraint: ID uniqueness */
|
||||||
if (attrDecl->atype == XML_ATTRIBUTE_ID) {
|
if (attrDecl->atype == XML_ATTRIBUTE_ID &&
|
||||||
|
(ctxt->flags & XML_VCTXT_IN_ENTITY) == 0) {
|
||||||
if (xmlAddID(ctxt, doc, value, attr) == NULL)
|
if (xmlAddID(ctxt, doc, value, attr) == NULL)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user