mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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.
This commit is contained in:
parent
e857dfa7cc
commit
e68acd031d
3 changed files with 37 additions and 4 deletions
3
NEWS
3
NEWS
|
@ -35,6 +35,9 @@ PHP NEWS
|
|||
. Fixed bug #76943 (Inconsistent stream_wrapper_restore() errors). (cmb)
|
||||
. Fixed bug #76735 (Incorrect message in fopen on invalid mode). (cmb)
|
||||
|
||||
- Tidy:
|
||||
. Fixed bug #77040 (tidyNode::isHtml() is completely broken). (cmb)
|
||||
|
||||
01 Oct 2020, PHP 7.3.23
|
||||
|
||||
- Core:
|
||||
|
|
27
ext/tidy/tests/bug77040.phpt
Normal file
27
ext/tidy/tests/bug77040.phpt
Normal file
|
@ -0,0 +1,27 @@
|
|||
--TEST--
|
||||
Bug #77040 (tidyNode::isHtml() is completely broken)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('tidy')) die('skip tidy extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$tidy = new tidy;
|
||||
$tidy->parseString("<p>text</p><p><![CDATA[cdata]]></p>");
|
||||
$p = $tidy->body()->child[0];
|
||||
var_dump($p->type === TIDY_NODETYPE_START);
|
||||
var_dump($p->isHtml());
|
||||
$text = $p->child[0];
|
||||
var_dump($text->type === TIDY_NODETYPE_TEXT);
|
||||
var_dump($text->isHtml());
|
||||
$cdata = $tidy->body()->child[1]->child[0];
|
||||
var_dump($cdata->type === TIDY_NODETYPE_CDATA);
|
||||
var_dump($cdata->isHtml());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
|
@ -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;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue