From: Dmitry Volyntsev Date: Wed, 2 Dec 2026 00:23:11 +0000 (-0800) Subject: XML: ignore DTD attribute declarations in removeAttribute() X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=e81721be69e348edfd6f7f328697b0ae6765f46c;p=njs.git XML: ignore DTD attribute declarations in removeAttribute() Previously, njs_xml_node_attr_handler() and qjs_xml_node_attr_handler() passed the result of xmlHasProp() directly to xmlRemoveProp(). Because xmlHasProp() can return an XML_ATTRIBUTE_DECL node from the DTD when the element does not have an own attribute of that name, xmlRemoveProp() read past the end of the declaration structure. Only call xmlRemoveProp() when xmlHasProp() returns an XML_ATTRIBUTE_NODE. The issues were introduced in 7d656627 (0.7.11) and cec9a165 (0.8.10). --- diff --git a/external/njs_xml_module.c b/external/njs_xml_module.c index cacbd091..e24e7125 100644 --- a/external/njs_xml_module.c +++ b/external/njs_xml_module.c @@ -1212,7 +1212,7 @@ njs_xml_node_attr_handler(njs_vm_t *vm, xmlNode *current, njs_str_t *name, attr = xmlHasProp(current, name_c); - if (attr != NULL) { + if (attr != NULL && attr->type == XML_ATTRIBUTE_NODE) { xmlRemoveProp(attr); } diff --git a/external/qjs_xml_module.c b/external/qjs_xml_module.c index d5621924..ae2b8b33 100644 --- a/external/qjs_xml_module.c +++ b/external/qjs_xml_module.c @@ -760,7 +760,7 @@ qjs_xml_node_attr_modify(JSContext *cx, JSValue current, const u_char *name, if (JS_IsNullOrUndefined(setval)) { attr = xmlHasProp(node->node, name); - if (attr != NULL) { + if (attr != NULL && attr->type == XML_ATTRIBUTE_NODE) { xmlRemoveProp(attr); }