Skip to content

Commit ec8e86b

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix phpGH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
2 parents 08b11e8 + b1206ea commit ec8e86b

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

ext/tidy/tests/gh12980.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
GH-12980 (tidynode.props.attribute is missing "Boolean Attributes" and empty attributes)
3+
--EXTENSIONS--
4+
tidy
5+
--FILE--
6+
<?php
7+
$html = '<!DOCTYPE html><html lang="en" boolean empty="" selected="selected"></html>';
8+
9+
$tidy = new tidy();
10+
$tidy->ParseString($html);
11+
echo tidy_get_output($tidy), "\n";
12+
13+
var_dump($tidy->root()->child[1]->attribute);
14+
15+
?>
16+
--EXPECT--
17+
<!DOCTYPE html>
18+
<html lang="en" boolean="" empty="" selected="selected">
19+
<head>
20+
<title></title>
21+
</head>
22+
<body>
23+
</body>
24+
</html>
25+
array(4) {
26+
["lang"]=>
27+
string(2) "en"
28+
["boolean"]=>
29+
string(0) ""
30+
["empty"]=>
31+
string(0) ""
32+
["selected"]=>
33+
string(8) "selected"
34+
}

ext/tidy/tidy.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,12 @@ static void tidy_add_node_default_properties(PHPTidyObj *obj)
662662
do {
663663
name = (char *)tidyAttrName(tempattr);
664664
val = (char *)tidyAttrValue(tempattr);
665-
if (name && val) {
666-
add_assoc_string(&attribute, name, val);
665+
if (name) {
666+
if (val) {
667+
add_assoc_string(&attribute, name, val);
668+
} else {
669+
add_assoc_str(&attribute, name, zend_empty_string);
670+
}
667671
}
668672
} while((tempattr = tidyAttrNext(tempattr)));
669673
} else {

0 commit comments

Comments
 (0)