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 59
59
} \
60
60
obj = Z_TIDY_P(object); \
61
61
62
+ #define TIDY_FETCH_INITIALIZED_OBJECT \
63
+ TIDY_FETCH_OBJECT; \
64
+ if (!obj->ptdoc->initialized) { \
65
+ zend_throw_error(NULL, "tidy object is not initialized"); \
66
+ return; \
67
+ }
68
+
62
69
#define TIDY_FETCH_ONLY_OBJECT \
63
70
PHPTidyObj *obj; \
64
71
TIDY_SET_CONTEXT; \
@@ -1229,7 +1236,7 @@ PHP_FUNCTION(tidy_get_status)
1229
1236
/* {{{ Get the Detected HTML version for the specified document. */
1230
1237
PHP_FUNCTION (tidy_get_html_ver )
1231
1238
{
1232
- TIDY_FETCH_OBJECT ;
1239
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1233
1240
1234
1241
RETURN_LONG (tidyDetectedHtmlVersion (obj -> ptdoc -> doc ));
1235
1242
}
@@ -1238,7 +1245,7 @@ PHP_FUNCTION(tidy_get_html_ver)
1238
1245
/* {{{ Indicates if the document is a XHTML document. */
1239
1246
PHP_FUNCTION (tidy_is_xhtml )
1240
1247
{
1241
- TIDY_FETCH_OBJECT ;
1248
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1242
1249
1243
1250
RETURN_BOOL (tidyDetectedXhtml (obj -> ptdoc -> doc ));
1244
1251
}
@@ -1247,7 +1254,7 @@ PHP_FUNCTION(tidy_is_xhtml)
1247
1254
/* {{{ Indicates if the document is a generic (non HTML/XHTML) XML document. */
1248
1255
PHP_FUNCTION (tidy_is_xml )
1249
1256
{
1250
- TIDY_FETCH_OBJECT ;
1257
+ TIDY_FETCH_INITIALIZED_OBJECT ;
1251
1258
1252
1259
RETURN_BOOL (tidyDetectedGenericXml (obj -> ptdoc -> doc ));
1253
1260
}
You can’t perform that action at this time.
0 commit comments