Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ext/dom/html5_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert(

/* xmlIsID does some other stuff too that is irrelevant here. */
if (local_name_length == 2 && local_name[0] == 'i' && local_name[1] == 'd' && attr->node.ns == LXB_NS_HTML) {
xmlAddID(NULL, lxml_doc, value, lxml_attr);
if (xmlAddID(NULL, lxml_doc, value, lxml_attr) == 0) {
/* If the ID already exists, the ID attribute still needs to be marked as an ID. */
lxml_attr->atype = XML_ATTRIBUTE_ID;
}
}

/* libxml2 doesn't support line numbers on this anyway, it derives them instead, so don't bother */
Expand Down
15 changes: 15 additions & 0 deletions ext/dom/tests/modern/html/interactions/gh20281.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GH-20281 (\Dom\Document::getElementById() is inconsistent after nodes are removed)
--EXTENSIONS--
dom
--CREDITS--
cscott
--FILE--
<?php
$d = \Dom\HTMLDocument::createFromString('<p id="a">b</p><p id="a">c</p>', LIBXML_NOERROR);
$p = $d->getElementById('a');
$p->remove();
echo $d->getElementById('a')->textContent, "\n";
?>
--EXPECT--
c
21 changes: 3 additions & 18 deletions ext/phar/tests/tar/bug70417.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,17 @@ Bug #70417 (PharData::compress() doesn't close temp file)
--EXTENSIONS--
phar
zlib
--SKIPIF--
<?php

exec('lsof -p ' . getmypid(), $out, $status);
if ($status !== 0) {
die("skip lsof(8) not available");
}
if (!str_starts_with($out[0], 'COMMAND')) {
die("skip Might be a different lsof");
}
?>
--FILE--
<?php
function countOpenFiles() {
exec('lsof -p ' . escapeshellarg(getmypid()) . ' 2> /dev/null', $out); // Note: valgrind can produce false positives for /usr/bin/lsof
return count($out);
}
$filename = __DIR__ . '/bug70417.tar';
@unlink("$filename.gz");
$openFiles1 = countOpenFiles();
$resBefore = count(get_resources());
$arch = new PharData($filename);
$arch->addFromString('foo', 'bar');
$arch->compress(Phar::GZ);
unset($arch);
$openFiles2 = countOpenFiles();
var_dump($openFiles1 === $openFiles2);
$resAfter = count(get_resources());
var_dump($resBefore === $resAfter);
?>
--CLEAN--
<?php
Expand Down