From bccd924e3f4108dc925a4b9136fabed939fda527 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 2 Jul 2023 17:08:14 +0200 Subject: [PATCH] Add edge-case testcase for offset in DOMNamedNodeMap --- .../DOMNamedNodeMap_edge_case_offset.phpt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ext/dom/tests/DOMNamedNodeMap_edge_case_offset.phpt diff --git a/ext/dom/tests/DOMNamedNodeMap_edge_case_offset.phpt b/ext/dom/tests/DOMNamedNodeMap_edge_case_offset.phpt new file mode 100644 index 00000000000..30a961143c7 --- /dev/null +++ b/ext/dom/tests/DOMNamedNodeMap_edge_case_offset.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test edge case offsets in DOMNamedNodeMap +--EXTENSIONS-- +dom +--FILE-- +createElement('root'); +$document->appendChild($root); +$root->setAttribute('attrib', 'value'); +var_dump($root->attributes->length); +// Consistent with the method call +try { + var_dump($root->attributes[-1]); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + $root->attributes[][] = null; +} catch (Throwable $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +int(1) +must be between 0 and 2147483647 +Cannot access DOMNamedNodeMap without offset