mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Don't crash on uninitialized tidy object
This commit is contained in:
commit
6de6f2a4e9
29
ext/tidy/tests/uninitialized.phpt
Normal file
29
ext/tidy/tests/uninitialized.phpt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
--TEST--
|
||||||
|
Operations on uninitialized tidy object
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("tidy")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$tidy = new tidy;
|
||||||
|
try {
|
||||||
|
var_dump($tidy->getHtmlVer());
|
||||||
|
} catch (Error $e) {
|
||||||
|
echo $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var_dump($tidy->isXhtml());
|
||||||
|
} catch (Error $e) {
|
||||||
|
echo $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var_dump($tidy->isXml());
|
||||||
|
} catch (Error $e) {
|
||||||
|
echo $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
tidy object is not initialized
|
||||||
|
tidy object is not initialized
|
||||||
|
tidy object is not initialized
|
@ -59,6 +59,13 @@
|
|||||||
} \
|
} \
|
||||||
obj = Z_TIDY_P(object); \
|
obj = Z_TIDY_P(object); \
|
||||||
|
|
||||||
|
#define TIDY_FETCH_INITIALIZED_OBJECT \
|
||||||
|
TIDY_FETCH_OBJECT; \
|
||||||
|
if (!obj->ptdoc->initialized) { \
|
||||||
|
zend_throw_error(NULL, "tidy object is not initialized"); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define TIDY_FETCH_ONLY_OBJECT \
|
#define TIDY_FETCH_ONLY_OBJECT \
|
||||||
PHPTidyObj *obj; \
|
PHPTidyObj *obj; \
|
||||||
TIDY_SET_CONTEXT; \
|
TIDY_SET_CONTEXT; \
|
||||||
@ -1229,7 +1236,7 @@ PHP_FUNCTION(tidy_get_status)
|
|||||||
/* {{{ Get the Detected HTML version for the specified document. */
|
/* {{{ Get the Detected HTML version for the specified document. */
|
||||||
PHP_FUNCTION(tidy_get_html_ver)
|
PHP_FUNCTION(tidy_get_html_ver)
|
||||||
{
|
{
|
||||||
TIDY_FETCH_OBJECT;
|
TIDY_FETCH_INITIALIZED_OBJECT;
|
||||||
|
|
||||||
RETURN_LONG(tidyDetectedHtmlVersion(obj->ptdoc->doc));
|
RETURN_LONG(tidyDetectedHtmlVersion(obj->ptdoc->doc));
|
||||||
}
|
}
|
||||||
@ -1238,7 +1245,7 @@ PHP_FUNCTION(tidy_get_html_ver)
|
|||||||
/* {{{ Indicates if the document is a XHTML document. */
|
/* {{{ Indicates if the document is a XHTML document. */
|
||||||
PHP_FUNCTION(tidy_is_xhtml)
|
PHP_FUNCTION(tidy_is_xhtml)
|
||||||
{
|
{
|
||||||
TIDY_FETCH_OBJECT;
|
TIDY_FETCH_INITIALIZED_OBJECT;
|
||||||
|
|
||||||
RETURN_BOOL(tidyDetectedXhtml(obj->ptdoc->doc));
|
RETURN_BOOL(tidyDetectedXhtml(obj->ptdoc->doc));
|
||||||
}
|
}
|
||||||
@ -1247,7 +1254,7 @@ PHP_FUNCTION(tidy_is_xhtml)
|
|||||||
/* {{{ Indicates if the document is a generic (non HTML/XHTML) XML document. */
|
/* {{{ Indicates if the document is a generic (non HTML/XHTML) XML document. */
|
||||||
PHP_FUNCTION(tidy_is_xml)
|
PHP_FUNCTION(tidy_is_xml)
|
||||||
{
|
{
|
||||||
TIDY_FETCH_OBJECT;
|
TIDY_FETCH_INITIALIZED_OBJECT;
|
||||||
|
|
||||||
RETURN_BOOL(tidyDetectedGenericXml(obj->ptdoc->doc));
|
RETURN_BOOL(tidyDetectedGenericXml(obj->ptdoc->doc));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user