代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libxml2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From e03590c9adfed2856866b5b1edaaf339b4523913 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <[email protected]>
Date: Tue, 8 Feb 2022 02:42:30 +0100
Subject: [PATCH 3/3] Don't add IDs containing unexpanded entity references
When parsing without entity substitution, IDs or IDREFs containing
unexpanded entity reference like "abc&x;def" could be created. We could
try to expand these entities like in validation mode, but it seems
safer to honor the request not to expand entities. We silently ignore
such IDs for now.
---
SAX2.c | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/SAX2.c b/SAX2.c
index edfb06f3..ae6181c4 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1368,7 +1368,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
- ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
+ ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
+ /* Don't create IDs containing entity references */
+ (ret->children != NULL) &&
+ (ret->children->type == XML_TEXT_NODE) &&
+ (ret->children->next == NULL)) {
+ xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@@ -1379,16 +1384,16 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
*
* Open issue: normalization of the value.
*/
- if (xmlValidateNCName(value, 1) != 0) {
+ if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
- (const char *) value, NULL);
+ (const char *) content, NULL);
}
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
error:
@@ -2121,7 +2126,12 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
- ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
+ ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
+ /* Don't create IDs containing entity references */
+ (ret->children != NULL) &&
+ (ret->children->type == XML_TEXT_NODE) &&
+ (ret->children->next == NULL)) {
+ xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@@ -2134,27 +2144,20 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
*
* Open issue: normalization of the value.
*/
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#ifdef LIBXML_VALID_ENABLED
- if (xmlValidateNCName(dup, 1) != 0) {
+ if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
- (const char *) dup, NULL);
+ (const char *) content, NULL);
}
#endif
#endif
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
- /* might be worth duplicate entry points and not copy */
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
}
if (dup != NULL)
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。