--- /dev/null
+--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
} \
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 \
PHPTidyObj *obj; \
TIDY_SET_CONTEXT; \
Get the Detected HTML version for the specified document. */
static PHP_FUNCTION(tidy_get_html_ver)
{
- TIDY_FETCH_OBJECT;
+ TIDY_FETCH_INITIALIZED_OBJECT;
RETURN_LONG(tidyDetectedHtmlVersion(obj->ptdoc->doc));
}
Indicates if the document is a XHTML document. */
static PHP_FUNCTION(tidy_is_xhtml)
{
- TIDY_FETCH_OBJECT;
+ TIDY_FETCH_INITIALIZED_OBJECT;
RETURN_BOOL(tidyDetectedXhtml(obj->ptdoc->doc));
}
Indicates if the document is a generic (non HTML/XHTML) XML document. */
static PHP_FUNCTION(tidy_is_xml)
{
- TIDY_FETCH_OBJECT;
+ TIDY_FETCH_INITIALIZED_OBJECT;
RETURN_BOOL(tidyDetectedGenericXml(obj->ptdoc->doc));
}