Skip to content

Commit bccd924

Browse files
committed
Add edge-case testcase for offset in DOMNamedNodeMap
1 parent 2aebca8 commit bccd924

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Test edge case offsets in DOMNamedNodeMap
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$document = new DomDocument();
9+
$root = $document->createElement('root');
10+
$document->appendChild($root);
11+
$root->setAttribute('attrib', 'value');
12+
var_dump($root->attributes->length);
13+
// Consistent with the method call
14+
try {
15+
var_dump($root->attributes[-1]);
16+
} catch (ValueError $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
try {
20+
$root->attributes[][] = null;
21+
} catch (Throwable $e) {
22+
echo $e->getMessage(), "\n";
23+
}
24+
25+
?>
26+
--EXPECT--
27+
int(1)
28+
must be between 0 and 2147483647
29+
Cannot access DOMNamedNodeMap without offset

0 commit comments

Comments
 (0)