Skip to content

Commit

Permalink
Merge branch 'PHP-8.3'
Browse files Browse the repository at this point in the history
* PHP-8.3:
  Fix phpGH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
  • Loading branch information
nielsdos committed Dec 22, 2023
2 parents 08b11e8 + b1206ea commit ec8e86b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
34 changes: 34 additions & 0 deletions ext/tidy/tests/gh12980.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
GH-12980 (tidynode.props.attribute is missing "Boolean Attributes" and empty attributes)
--EXTENSIONS--
tidy
--FILE--
<?php
$html = '<!DOCTYPE html><html lang="en" boolean empty="" selected="selected"></html>';

$tidy = new tidy();
$tidy->ParseString($html);
echo tidy_get_output($tidy), "\n";

var_dump($tidy->root()->child[1]->attribute);

?>
--EXPECT--
<!DOCTYPE html>
<html lang="en" boolean="" empty="" selected="selected">
<head>
<title></title>
</head>
<body>
</body>
</html>
array(4) {
["lang"]=>
string(2) "en"
["boolean"]=>
string(0) ""
["empty"]=>
string(0) ""
["selected"]=>
string(8) "selected"
}
8 changes: 6 additions & 2 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,12 @@ static void tidy_add_node_default_properties(PHPTidyObj *obj)
do {
name = (char *)tidyAttrName(tempattr);
val = (char *)tidyAttrValue(tempattr);
if (name && val) {
add_assoc_string(&attribute, name, val);
if (name) {
if (val) {
add_assoc_string(&attribute, name, val);
} else {
add_assoc_str(&attribute, name, zend_empty_string);
}
}
} while((tempattr = tidyAttrNext(tempattr)));
} else {
Expand Down

0 comments on commit ec8e86b

Please sign in to comment.