php-src/ext/dom
Niels Dossche 9f7d88802e Fix #80332: Completely broken array access functionality with DOMNamedNodeMap
The problem is the usage of zval_get_long(). In particular, if the
string is non-numeric the result of zval_get_long() will be 0 without
giving an error or warning. This is misleading for users: users get the
impression that they can use strings to access the map because it
coincidentally works for the first item (which is at index 0). Of
course, this fails with any other index which causes confusion and bugs.

This patch adds proper support for using string offsets while accessing
the map. It does so by detecting if it's a non-numeric string, and then
using the getNamedItem() method instead of item(). I had to split up the
array access implementation code for DOMNodeList and DOMNamedNodeMap
first to be able to do this.

Closes GH-11468.
2023-06-18 14:59:19 +02:00
..
tests Fix #80332: Completely broken array access functionality with DOMNamedNodeMap 2023-06-18 14:59:19 +02:00
attr.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
cdatasection.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
characterdata.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
comment.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
config.m4 [RFC] Implement new DOM Living Standard APIs in ext/dom 2020-02-28 16:13:39 +01:00
config.w32 [RFC] Implement new DOM Living Standard APIs in ext/dom 2020-02-28 16:13:39 +01:00
CREDITS
document.c Fix GH-11404: DOMDocument::savexml and friends ommit xmlns="" declaration for null namespace, creating incorrect xml representation of the DOM 2023-06-17 13:36:00 +02:00
documentfragment.c Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
documenttype.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
dom_ce.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
dom_iterators.c Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
dom_properties.h Make a few unuseful DOMEntity properties readonly (#7406) 2021-08-26 10:37:45 +02:00
domexception.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
domexception.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
domimplementation.c Merge branch 'PHP-8.0' into PHP-8.1 2021-11-14 23:29:59 -08:00
element.c Fix GH-11404: DOMDocument::savexml and friends ommit xmlns="" declaration for null namespace, creating incorrect xml representation of the DOM 2023-06-17 13:36:00 +02:00
entity.c Update property read handler comments for DOMEntity 2021-08-26 13:15:24 +02:00
entityreference.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
namednodemap.c Fix #80332: Completely broken array access functionality with DOMNamedNodeMap 2023-06-18 14:59:19 +02:00
node.c Fix GH-11404: DOMDocument::savexml and friends ommit xmlns="" declaration for null namespace, creating incorrect xml representation of the DOM 2023-06-17 13:36:00 +02:00
nodelist.c Fix #80332: Completely broken array access functionality with DOMNamedNodeMap 2023-06-18 14:59:19 +02:00
notation.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
parentnode.c Fix bug #81642: DOMChildNode::replaceWith() bug when replacing a node with itself 2023-06-04 16:19:48 +02:00
php_dom_arginfo.h Fix return value in stub file for DOMNodeList::item 2023-05-29 18:49:26 +02:00
php_dom.c Fix #80332: Completely broken array access functionality with DOMNamedNodeMap 2023-06-18 14:59:19 +02:00
php_dom.h Fix #80332: Completely broken array access functionality with DOMNamedNodeMap 2023-06-18 14:59:19 +02:00
php_dom.stub.php Fix return value in stub file for DOMNodeList::item 2023-05-29 18:49:26 +02:00
processinginstruction.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
text.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
xml_common.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
xpath.c Fix #70359 and #78577: segfaults with DOMNameSpaceNode 2023-06-09 21:35:55 +02:00