File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Operations on uninitialized tidy object
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ("tidy " )) print "skip " ; ?>
5
+ --FILE--
6
+ <?php
7
+
8
+ $ tidy = new tidy ;
9
+ try {
10
+ var_dump ($ tidy ->getHtmlVer ());
11
+ } catch (Error $ e ) {
12
+ echo $ e ->getMessage (), "\n" ;
13
+ }
14
+ try {
15
+ var_dump ($ tidy ->isXhtml ());
16
+ } catch (Error $ e ) {
17
+ echo $ e ->getMessage (), "\n" ;
18
+ }
19
+ try {
20
+ var_dump ($ tidy ->isXml ());
21
+ } catch (Error $ e ) {
22
+ echo $ e ->getMessage (), "\n" ;
23
+ }
24
+
25
+ ?>
26
+ --EXPECT--
27
+ tidy object is not initialized
28
+ tidy object is not initialized
29
+ tidy object is not initialized
Original file line number Diff line number Diff line change 66
66
} \
67
67
obj = Z_TIDY_P(object); \
68
68
69
+ #define TIDY_FETCH_INITIALIZED_OBJECT \
70
+ TIDY_FETCH_OBJECT; \
71
+ if (!obj->ptdoc->initialized) { \
72
+ zend_throw_error(NULL, "tidy object is not initialized"); \
73
+ return; \
74
+ }
75
+
69
76
#define TIDY_FETCH_ONLY_OBJECT \
70
77
PHPTidyObj *obj; \
71
78
TIDY_SET_CONTEXT; \
@@ -1486,7 +1493,7 @@ static PHP_FUNCTION(tidy_get_status)
1486
1493
Get the Detected HTML version for the specified document. */
1487
1494
static PHP_FUNCTION (tidy_get_html_ver )
1488
1495
{
1489
- TIDY_FETCH_OBJECT ;
1496
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1490
1497
1491
1498
RETURN_LONG (tidyDetectedHtmlVersion (obj -> ptdoc -> doc ));
1492
1499
}
@@ -1496,7 +1503,7 @@ static PHP_FUNCTION(tidy_get_html_ver)
1496
1503
Indicates if the document is a XHTML document. */
1497
1504
static PHP_FUNCTION (tidy_is_xhtml )
1498
1505
{
1499
- TIDY_FETCH_OBJECT ;
1506
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1500
1507
1501
1508
RETURN_BOOL (tidyDetectedXhtml (obj -> ptdoc -> doc ));
1502
1509
}
@@ -1506,7 +1513,7 @@ static PHP_FUNCTION(tidy_is_xhtml)
1506
1513
Indicates if the document is a generic (non HTML/XHTML) XML document. */
1507
1514
static PHP_FUNCTION (tidy_is_xml )
1508
1515
{
1509
- TIDY_FETCH_OBJECT ;
1516
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1510
1517
1511
1518
RETURN_BOOL (tidyDetectedGenericXml (obj -> ptdoc -> doc ));
1512
1519
}
You can’t perform that action at this time.
0 commit comments