@@ -239,7 +239,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert(
239239 lxml_attr -> children = lxml_attr -> last = lxml_text ;
240240 lxml_text -> parent = (xmlNodePtr ) lxml_attr ;
241241
242- if (attr -> node .ns == LXB_NS_XMLNS ) {
242+ if (attr -> node .ns == LXB_NS_XMLNS && ( attr -> node . prefix || strcmp (( const char * ) local_name , "xmlns" ) == 0 ) ) {
243243 if (strcmp ((const char * ) local_name , "xmlns" ) != 0 ) {
244244 if (prefixed_xmlns_ns == NULL ) {
245245 prefixed_xmlns_ns = php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe (ns_mapper , "xmlns" , DOM_XMLNS_NS_URI );
@@ -249,13 +249,13 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert(
249249 lxml_attr -> ns = php_dom_libxml_ns_mapper_ensure_prefixless_xmlns_ns (ns_mapper );
250250 }
251251 lxml_attr -> ns -> _private = (void * ) php_dom_ns_is_xmlns_magic_token ;
252- } else if (attr -> node .ns == LXB_NS_XLINK ) {
252+ } else if (attr -> node .prefix && attr -> node . ns == LXB_NS_XLINK ) {
253253 if (xlink_ns == NULL ) {
254254 xlink_ns = php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe (ns_mapper , "xlink" , DOM_XLINK_NS_URI );
255255 xlink_ns -> _private = (void * ) php_dom_ns_is_xlink_magic_token ;
256256 }
257257 lxml_attr -> ns = xlink_ns ;
258- } else if (attr -> node .ns == LXB_NS_XML ) {
258+ } else if (attr -> node .prefix && attr -> node . ns == LXB_NS_XML ) {
259259 if (xml_ns == NULL ) {
260260 xml_ns = php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe (ns_mapper , "xml" , DOM_XML_NS_URI );
261261 xml_ns -> _private = (void * ) php_dom_ns_is_xml_magic_token ;
@@ -272,7 +272,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert(
272272 last_added_attr = lxml_attr ;
273273
274274 /* xmlIsID does some other stuff too that is irrelevant here. */
275- if (local_name_length == 2 && local_name [0 ] == 'i' && local_name [1 ] == 'd' && attr -> node . ns == LXB_NS_HTML ) {
275+ if (local_name_length == 2 && local_name [0 ] == 'i' && local_name [1 ] == 'd' && lxml_attr -> ns == NULL ) {
276276 if (xmlAddID (NULL , lxml_doc , value , lxml_attr ) == 0 ) {
277277 /* If the ID already exists, the ID attribute still needs to be marked as an ID. */
278278 lxml_attr -> atype = XML_ATTRIBUTE_ID ;
0 commit comments