summaryrefslogtreecommitdiff
path: root/ext/tidy/tidy.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-10-07 12:45:43 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-10-07 17:43:56 +0200
commite68acd031db679ff882710ce89bfac67e65bd9f0 (patch)
treec1ab2a4a4ba921f91651f6a0f55e389b6dd97294 /ext/tidy/tidy.c
parente857dfa7cc9d28174e2328bd3ef74d9c436afda9 (diff)
downloadphp-git-e68acd031db679ff882710ce89bfac67e65bd9f0.tar.gz
Fix #77040: tidyNode::isHtml() is completely broken
The documentation of `tidyNode::isHtml()` states that this method "checks if a node is part of a HTML document". That is, of course, nonsense, since a tidyNode is "an HTML node in an HTML file, as detected by tidy." What this method is actually supposed to do is to check whether a node is an element (unless it is the root element). This has been broken by commit d8eeb8e[1], which assumed that `enum TidyNodeType` would represent flags of a bitmask, what it does not. [1] <http://git.php.net/?p=php-src.git;a=commit;h=d8eeb8e28673236bca3f066ded75037a5bdf6378> Closes GH-6290.
Diffstat (limited to 'ext/tidy/tidy.c')
-rw-r--r--ext/tidy/tidy.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 0fde23cb11..60170585ce 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -1786,11 +1786,14 @@ static TIDY_NODE_METHOD(isHtml)
{
TIDY_FETCH_ONLY_OBJECT;
- if (tidyNodeGetType(obj->node) & (TidyNode_Start | TidyNode_End | TidyNode_StartEnd)) {
- RETURN_TRUE;
+ switch (tidyNodeGetType(obj->node)) {
+ case TidyNode_Start:
+ case TidyNode_End:
+ case TidyNode_StartEnd:
+ RETURN_TRUE;
+ default:
+ RETURN_FALSE;
}
-
- RETURN_FALSE;
}
/* }}} */