New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidynode.props.attribute is missing "Boolean Attributes" and empty attributes. #12980
Comments
This needs a label of "Extension: tidy" |
Good catch.
NULL seems dubious indeed. Although true is better, that does break the documentation that claims the value is a string. From the docs:
What the DOM spec does in this case is return the empty string instead of a boolean. And I think that makes sense here too. |
I think an empty string would be a good fix. A fix like that would probably not need to wait on php8.4 so it could possibly be in a much sooner release of 8.2&8.3 hopefully.(Not sure what the policy on that is but from looking at the guidelines it appears this should be submitted against 8.2 and merged into 8.3 and master.) @nielsdos Is this something you will fix or do you want me to try and open a pull request for it?(And does submitting it to 8.2 seem like the correct place?) If you want me to do it does this look correct? Or does the
|
I just realized that attributes that just have empty values are also not in the array too. Like |
I edited the issue to reflect that the bug applies to empty attributes too. |
Indeed, this can be fixed in stable versions.
Right, I get that. However, as far as I know, whether an attribute is boolean or not depends on how the browser interprets it (i.e. assigns special meaning to certain attribute names). Boolean in this context means that the value doesn't really matter: what matters is that the attribute is present. A boolean attribute may have the empty string as value, or the attribute name itself even. Source: https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML Also, looks like we can't distinguish between "empty attributes" and "boolean attributes" like you said.
Either way works for me.
Yes
At that point, |
You are correct that the name is what matters in HTML. If you can do it that would be great, My c is not perfect. And I don't have a build and testing env setup for PHP to test this. I think that this would be correct.
|
…tes" and empty attributes
I submitted a PR with the local patch I had. |
* PHP-8.2: Fix GH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
* PHP-8.3: Fix GH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
|
Description
The following code:
Resulted in this output:
But I expected this output instead:
Note: This ticket was originally submitted regarding boolean attributes but the example above has been updated to reflect empty attributes showing the same behavior.
Documentation for tidynode.props.attribute, There isn't any mention about this and I believe it is an unintended bug.
https://www.php.net/manual/en/class.tidynode.php#tidynode.props.attribute
The value of a "Boolean Attribute" is debatable. It could be NULL but I think it would be better if it was true.(If NULL was desired the fix below would need to be tweaked.)
After reviewing the PHP source code I believe the issue is probably located here
https://github.com/php/php-src/blob/master/ext/tidy/tidy.c
on line 665
I would suggest that the fix look something like this starting on line 665 /ext/tidy/tidy.c
Feel free to use the above code in making a patch, I the author disclaim and release all copyright to it.
PHP Version
PHP 8.2.10
Operating System
No response
The text was updated successfully, but these errors were encountered: