summaryrefslogtreecommitdiff
path: root/ext/tidy
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tidy')
-rw-r--r--ext/tidy/CREDITS2
-rw-r--r--ext/tidy/README7
-rw-r--r--ext/tidy/config.m444
-rw-r--r--ext/tidy/config.w3222
-rw-r--r--ext/tidy/examples/cleanhtml.php40
-rw-r--r--ext/tidy/examples/cleanhtml5.php39
-rw-r--r--ext/tidy/examples/dumpit5.php92
-rw-r--r--ext/tidy/examples/urlgrab5.php39
-rw-r--r--ext/tidy/package.xml65
-rw-r--r--ext/tidy/php_tidy.def290
-rw-r--r--ext/tidy/php_tidy.h57
-rw-r--r--ext/tidy/tests/001.phpt10
-rw-r--r--ext/tidy/tests/002.phpt18
-rw-r--r--ext/tidy/tests/003.phpt21
-rw-r--r--ext/tidy/tests/004.phpt31
-rw-r--r--ext/tidy/tests/005.html1
-rw-r--r--ext/tidy/tests/005.phpt18
-rw-r--r--ext/tidy/tests/006.phpt16
-rw-r--r--ext/tidy/tests/007.html1
-rw-r--r--ext/tidy/tests/007.phpt29
-rw-r--r--ext/tidy/tests/008.phpt15
-rw-r--r--ext/tidy/tests/009.phpt19
-rw-r--r--ext/tidy/tests/010.phpt317
-rw-r--r--ext/tidy/tests/011.phpt22
-rw-r--r--ext/tidy/tests/012.phpt473
-rw-r--r--ext/tidy/tests/013.html1
-rw-r--r--ext/tidy/tests/013.phpt13
-rw-r--r--ext/tidy/tests/014.phpt14
-rw-r--r--ext/tidy/tests/015.html1
-rw-r--r--ext/tidy/tests/015.phpt13
-rw-r--r--ext/tidy/tests/016.html1
-rw-r--r--ext/tidy/tests/016.phpt24
-rw-r--r--ext/tidy/tests/016.tcfg1
-rw-r--r--ext/tidy/tests/017.phpt17
-rw-r--r--ext/tidy/tests/018.phpt16
-rw-r--r--ext/tidy/tests/019.phpt42
-rw-r--r--ext/tidy/tests/020.phpt36
-rw-r--r--ext/tidy/tests/021.phpt18
-rw-r--r--ext/tidy/tests/022.phpt42
-rw-r--r--ext/tidy/tests/023.phpt41
-rw-r--r--ext/tidy/tests/024.phpt40
-rw-r--r--ext/tidy/tests/025.phpt36
-rw-r--r--ext/tidy/tests/026.phpt24
-rw-r--r--ext/tidy/tests/027.phpt59
-rw-r--r--ext/tidy/tests/028.phpt15
-rw-r--r--ext/tidy/tests/029.phpt28
-rw-r--r--ext/tidy/tests/030.phpt29
-rw-r--r--ext/tidy/tests/031.phpt18
-rw-r--r--ext/tidy/tests/032.phpt17
-rw-r--r--ext/tidy/tests/033.phpt17
-rw-r--r--ext/tidy/tests/034.phpt20
-rw-r--r--ext/tidy/tests/035.phpt12
-rw-r--r--ext/tidy/tests/bug54682.phpt13
-rw-r--r--ext/tidy/tests/bug_50558.phpt28
-rw-r--r--ext/tidy/tests/tidy_error.phpt41
-rw-r--r--ext/tidy/tests/tidy_error1.phpt19
-rw-r--r--ext/tidy/tidy.c2001
-rwxr-xr-xext/tidy/tidy.dsp108
58 files changed, 4493 insertions, 0 deletions
diff --git a/ext/tidy/CREDITS b/ext/tidy/CREDITS
new file mode 100644
index 0000000..1c77b2f
--- /dev/null
+++ b/ext/tidy/CREDITS
@@ -0,0 +1,2 @@
+tidy
+John Coggeshall, Ilia Alshanetsky
diff --git a/ext/tidy/README b/ext/tidy/README
new file mode 100644
index 0000000..0fb6c0f
--- /dev/null
+++ b/ext/tidy/README
@@ -0,0 +1,7 @@
+
+README FOR ext/tidy by John Coggeshall <john@php.net>
+
+
+Tidy is an extension based on Libtidy (http://tidy.sf.net/) and allows a PHP developer
+to clean, repair, and traverse HTML, XHTML, and XML documents -- including ones with
+embedded scripting languages such as PHP or ASP within them using OO constructs.
diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4
new file mode 100644
index 0000000..675498c
--- /dev/null
+++ b/ext/tidy/config.m4
@@ -0,0 +1,44 @@
+dnl
+dnl $Id$
+dnl
+
+PHP_ARG_WITH(tidy,for TIDY support,
+[ --with-tidy[=DIR] Include TIDY support])
+
+if test "$PHP_TIDY" != "no"; then
+
+ if test "$PHP_TIDY" != "yes"; then
+ TIDY_SEARCH_DIRS=$PHP_TIDY
+ else
+ TIDY_SEARCH_DIRS="/usr/local /usr"
+ fi
+
+ for i in $TIDY_SEARCH_DIRS; do
+ if test -f $i/include/tidy/tidy.h; then
+ TIDY_DIR=$i
+ TIDY_INCDIR=$i/include/tidy
+ elif test -f $i/include/tidy.h; then
+ TIDY_DIR=$i
+ TIDY_INCDIR=$i/include
+ fi
+ done
+
+ if test -z "$TIDY_DIR"; then
+ AC_MSG_ERROR(Cannot find libtidy)
+ fi
+
+ TIDY_LIBDIR=$TIDY_DIR/$PHP_LIBDIR
+
+ PHP_ADD_LIBRARY_WITH_PATH(tidy, $TIDY_LIBDIR, TIDY_SHARED_LIBADD)
+ PHP_ADD_INCLUDE($TIDY_INCDIR)
+
+ PHP_CHECK_LIBRARY(tidy,tidyOptGetDoc,
+ [
+ AC_DEFINE(HAVE_TIDYOPTGETDOC,1,[ ])
+ ],[],[])
+
+
+ PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared)
+ PHP_SUBST(TIDY_SHARED_LIBADD)
+ AC_DEFINE(HAVE_TIDY,1,[ ])
+fi
diff --git a/ext/tidy/config.w32 b/ext/tidy/config.w32
new file mode 100644
index 0000000..41f2175
--- /dev/null
+++ b/ext/tidy/config.w32
@@ -0,0 +1,22 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_WITH("tidy", "TIDY support", "no");
+
+if (PHP_TIDY != "no") {
+ if (CHECK_LIB("libtidy_a.lib;libtidy.lib", "tidy", PHP_TIDY) &&
+ (
+ CHECK_HEADER_ADD_INCLUDE("tidy.h", "CFLAGS_TIDY") ||
+ CHECK_HEADER_ADD_INCLUDE("tidy/tidy.h", "CFLAGS_TIDY", null, null, true) ||
+ CHECK_HEADER_ADD_INCLUDE("libtidy/tidy.h", "CFLAGS_TIDY", null, null, true)
+ )) {
+ EXTENSION("tidy", "tidy.c");
+ AC_DEFINE('HAVE_TIDY', 1, 'Have TIDY library');
+ if (!PHP_TIDY_SHARED) {
+ ADD_DEF_FILE("ext\\tidy\\php_tidy.def");
+ }
+ } else {
+ WARNING("tidy not enabled; libraries and headers not found");
+ }
+}
+
diff --git a/ext/tidy/examples/cleanhtml.php b/ext/tidy/examples/cleanhtml.php
new file mode 100644
index 0000000..2644210
--- /dev/null
+++ b/ext/tidy/examples/cleanhtml.php
@@ -0,0 +1,40 @@
+<?php
+
+ /*
+ * cleanhtml.php
+ *
+ * A simple script to clean and repair HTML,XHTML,PHP,ASP,etc. documents
+ * if no file is provided, it reads from standard input.
+ *
+ * NOTE: Works only with tidy for PHP 4.3.x, for tidy in PHP 5 see cleanhtml5.php
+ *
+ * By: John Coggeshall <john@php.net>
+ *
+ * Usage: php cleanhtml.php [filename]
+ *
+ */
+
+ if(!isset($_SERVER['argv'][1])) {
+ $data = file_get_contents("php://stdin");
+ tidy_parse_string($data);
+ } else {
+ tidy_parse_file($_SERVER['argv'][1]);
+ }
+
+ tidy_clean_repair();
+
+ if(tidy_warning_count() ||
+ tidy_error_count()) {
+
+ echo "\n\nThe following errors or warnings occurred:\n";
+ echo tidy_get_error_buffer();
+ echo "\n";
+ }
+
+ echo tidy_get_output();
+
+?>
+
+
+
+ \ No newline at end of file
diff --git a/ext/tidy/examples/cleanhtml5.php b/ext/tidy/examples/cleanhtml5.php
new file mode 100644
index 0000000..2ce683a
--- /dev/null
+++ b/ext/tidy/examples/cleanhtml5.php
@@ -0,0 +1,39 @@
+<?php
+
+ /*
+ * cleanhtml5.php
+ *
+ * A simple script to clean and repair HTML,XHTML,PHP,ASP,etc. documents
+ * if no file is provided, it reads from standard input.
+ *
+ * NOTE: Works only with tidy for PHP 5, for tidy in PHP 4.3.x see cleanhtml.php
+ *
+ * By: John Coggeshall <john@php.net>
+ *
+ * Usage: php cleanhtml5.php [filename]
+ *
+ */
+
+ if(!isset($_SERVER['argv'][1])) {
+ $data = file_get_contents("php://stdin");
+ $tidy = tidy_parse_string($data);
+ } else {
+ $tidy = tidy_parse_file($_SERVER['argv'][1]);
+ }
+
+ $tidy->cleanRepair();
+
+ if(!empty($tidy->errorBuffer)) {
+
+ echo "\n\nThe following errors or warnings occurred:\n";
+ echo "{$tidy->errorBuffer}\n";
+
+ }
+
+ echo $tidy;
+
+?>
+
+
+
+
diff --git a/ext/tidy/examples/dumpit5.php b/ext/tidy/examples/dumpit5.php
new file mode 100644
index 0000000..d7aee2d
--- /dev/null
+++ b/ext/tidy/examples/dumpit5.php
@@ -0,0 +1,92 @@
+<?php
+ /*
+ * dumpit5.php
+ *
+ * a command-line script which dumps the given HTML, PHP, ASP, XHTML, etc.
+ * file as it is represented in the document model.
+ *
+ * NOTE: Only works with tidy for PHP 5+, for tidy in 4.3.x, see dumpit.php
+ *
+ * By: John Coggeshall <john@php.net>
+ *
+ * Usage; php dumpit5.php <filename>
+ */
+
+ $tidy = tidy_parse_file($_SERVER['argv'][1]);
+
+ /* Optionally you can do this here if you want to fix up the document */
+
+ /* $tidy->clean_repair() */
+
+ $tree = $tidy->root();
+ dump_tree($tree);
+ echo "\n";
+
+ function node_type($type) {
+
+ switch($type) {
+
+ case TIDY_NODETYPE_ROOT: return "Root Node";
+ case TIDY_NODETYPE_DOCTYPE: return "DocType Node";
+ case TIDY_NODETYPE_COMMENT: return "Comment Node";
+ case TIDY_NODETYPE_PROCINS: return "ProcIns Node";
+ case TIDY_NODETYPE_TEXT: return "Text Node";
+ case TIDY_NODETYPE_START: return "Start Node";
+ case TIDY_NODETYPE_END: return "End Node";
+ case TIDY_NODETYPE_STARTEND: return "Start/End Node";
+ case TIDY_NODETYPE_CDATA: return "CDATA Node";
+ case TIDY_NODETYPE_SECTION: return "Section Node";
+ case TIDY_NODETYPE_ASP: return "ASP Source Code Node";
+ case TIDY_NODETYPE_PHP: return "PHP Source Code Node";
+ case TIDY_NODETYPE_JSTE: return "JSTE Source Code";
+ case TIDY_NODETYPE_XMLDECL: return "XML Declaration Node";
+ default: return "Unknown Node";
+ }
+ }
+
+ function do_leaf($string, $indent) {
+ for($i = 0; $i < $indent; $i++) {
+ echo " ";
+ }
+ echo $string;
+ }
+
+ function dump_tree(tidyNode $node, $indent = 0) {
+
+ /* Put something there if the node name is empty */
+ $nodename = trim(strtoupper($node->name));
+ $nodename = (empty($nodename)) ? "[EMPTY]" : $nodename;
+
+ /* Generate the Node, and a pretty name for it */
+ do_leaf(" + $nodename (".node_type($node->type).")\n", $indent);
+
+ /* Check to see if this node is a text node. Text nodes are
+ generated by start/end tags and contain the text in between.
+ i.e. <B>foo</B> will create a text node with $node->value
+ equal to 'foo' */
+ if($node->type == TIDY_NODETYPE_TEXT) {
+ do_leaf(" |\n", $indent);
+ do_leaf(" +---- Value: '{$node->value}'\n", $indent);
+ }
+
+ if(count($node->attribute)) {
+ do_leaf(" |\n", $indent);
+ do_leaf(" +---- Attributes\n", $indent);
+
+ foreach($node->attribute as $name=>$value) {
+ @do_leaf(" +-- $name\n", $indent);
+ do_leaf(" | +-- Value: $value\n", $indent);
+ }
+ }
+
+ /* Recurse along the children to generate the remaining nodes */
+ if($node->hasChildren()) {
+ foreach($node->child as $child) {
+ dump_tree($child, $indent + 3);
+ }
+ }
+
+ }
+
+
+?> \ No newline at end of file
diff --git a/ext/tidy/examples/urlgrab5.php b/ext/tidy/examples/urlgrab5.php
new file mode 100644
index 0000000..875baf0
--- /dev/null
+++ b/ext/tidy/examples/urlgrab5.php
@@ -0,0 +1,39 @@
+<?php
+ /*
+ * urlgrab5.php
+ *
+ * A simple command-line utility to extract all of the URLS contained
+ * within <A HREF> tags from a document.
+ *
+ * NOTE: Only works with tidy for PHP 5, please see urlgrab.php for tidy for PHP 4.3.x
+ *
+ * By: John Coggeshall <john@php.net>
+ *
+ * Usage: php urlgrab5.php <file>
+ *
+ */
+ function dump_nodes(tidyNode $node, &$urls = NULL) {
+
+ $urls = (is_array($urls)) ? $urls : array();
+
+ if(isset($node->id)) {
+ if($node->id == TIDY_TAG_A) {
+ $urls[] = $node->attribute['href'];
+ }
+ }
+
+ if($node->hasChildren()) {
+
+ foreach($node->child as $c) {
+ dump_nodes($c, $urls);
+ }
+
+ }
+
+ return $urls;
+ }
+
+ $a = tidy_parse_file($_SERVER['argv'][1]);
+ $a->cleanRepair();
+ print_r(dump_nodes($a->html()));
+?>
diff --git a/ext/tidy/package.xml b/ext/tidy/package.xml
new file mode 100644
index 0000000..a5b461c
--- /dev/null
+++ b/ext/tidy/package.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE package SYSTEM "../pear/package.dtd">
+<package>
+ <name>tidy</name>
+ <summary>Tidy HTML Repairing and Parsing</summary>
+ <maintainers>
+ <maintainer>
+ <user>john</user>
+ <name>John Coggeshall</name>
+ <email>john@php.net</email>
+ <role>lead</role>
+ </maintainer>
+ <maintainer>
+ <user>iliaa</user>
+ <name>Ilia Alshanetsky</name>
+ <email>ilia@php.net</email>
+ <role>developer</role>
+ </maintainer>
+ </maintainers>
+ <description>
+Tidy is a binding for the Tidy HTML clean and repair utility which
+allows you to not only clean and otherwise manipluate HTML documents,
+but also traverse the document tree using the Zend Engine 2 OO semantics.
+ </description>
+ <license>PHP</license>
+ <release>
+ <state>beta</state>
+ <version>2.0dev</version>
+ <date>2003-11-13</date>
+ <notes>
+ Major API changes for PHP 5.0, including the re-introduction of resources, output buffering support,
+ dual-nature syntax (tidy_clean_repair($tidy_res) or $tidy->clean_repair()) and more.
+ </notes>
+ <configureoptions>
+ <configureoption name="with-tidy" default="autodetect" prompt="Tidy library installation dir?"/>
+ </configureoptions>
+ <filelist>
+ <file role="src" name="config.m4"/>
+ <file role="src" name="tidy.c"/>
+ <file role="src" name="php_tidy.h"/>
+
+ <file role="doc" name="CREDITS"/>
+ <file role="doc" name="TODO"/>
+ <file role="doc" name="examples/cleanhtml.php"/>
+ <file role="doc" name="examples/dumpit.php"/>
+ <file role="doc" name="examples/urlgrab.php"/>
+ <file role="doc" name="libtidy.txt"/>
+
+ <file role="test" name="tests/001.phpt"/>
+ <file role="test" name="tests/002.phpt"/>
+ <file role="test" name="tests/003.phpt"/>
+ <file role="test" name="tests/004.phpt"/>
+ <file role="test" name="tests/005.phpt"/>
+ <file role="test" name="tests/005.html"/>
+ <file role="test" name="tests/006.phpt"/>
+ <file role="test" name="tests/007.phpt"/>
+ </filelist>
+ <deps>
+ <dep type="php" rel="ge" version="5" />
+ </deps>
+ </release>
+</package>
+<!--
+vim:et:ts=1:sw=1
+-->
diff --git a/ext/tidy/php_tidy.def b/ext/tidy/php_tidy.def
new file mode 100644
index 0000000..1d438a7
--- /dev/null
+++ b/ext/tidy/php_tidy.def
@@ -0,0 +1,290 @@
+EXPORTS
+tidyBufInit
+tidyBufAlloc
+tidyBufCheckAlloc
+tidyBufFree
+tidyBufClear
+tidyBufAttach
+tidyBufDetach
+tidyBufAppend
+tidyBufPutByte
+tidyBufPopByte
+tidyBufGetByte
+tidyBufEndOfInput
+tidyBufUngetByte
+tidyCreate
+tidyRelease
+tidySetAppData
+tidyGetAppData
+tidyReleaseDate
+tidyStatus
+tidyDetectedHtmlVersion
+tidyDetectedXhtml
+tidyDetectedGenericXml
+tidyErrorCount
+tidyWarningCount
+tidyAccessWarningCount
+tidyConfigErrorCount
+tidyLoadConfig
+tidyLoadConfigEnc
+tidyFileExists
+tidySetCharEncoding
+tidySetOptionCallback
+tidyOptGetIdForName
+tidyGetOptionList
+tidyGetNextOption
+tidyGetOption
+tidyGetOptionByName
+tidyOptGetId
+tidyOptGetName
+tidyOptGetType
+tidyOptIsReadOnly
+tidyOptGetCategory
+tidyOptGetDefault
+tidyOptGetDefaultInt
+tidyOptGetDefaultBool
+tidyOptGetPickList
+tidyOptGetNextPick
+tidyOptGetValue
+tidyOptSetValue
+tidyOptParseValue
+tidyOptGetInt
+tidyOptSetInt
+tidyOptGetBool
+tidyOptSetBool
+tidyOptResetToDefault
+tidyOptResetAllToDefault
+tidyOptSnapshot
+tidyOptResetToSnapshot
+tidyOptDiffThanDefault
+tidyOptDiffThanSnapshot
+tidyOptCopyConfig
+tidyOptGetEncName
+tidyOptGetCurrPick
+tidyOptGetDeclTagList
+tidyOptGetNextDeclTag
+tidyInitSource
+tidyGetByte
+tidyUngetByte
+tidyIsEOF
+tidyInitSink
+tidyPutByte
+tidySetReportFilter
+tidySetErrorFile
+tidySetErrorBuffer
+tidySetErrorSink
+tidySetMallocCall
+tidySetReallocCall
+tidySetFreeCall
+tidySetPanicCall
+tidyParseFile
+tidyParseStdin
+tidyParseString
+tidyParseBuffer
+tidyParseSource
+tidyCleanAndRepair
+tidyRunDiagnostics
+tidySaveFile
+tidySaveStdout
+tidySaveBuffer
+tidySaveString
+tidySaveSink
+tidyOptSaveFile
+tidyOptSaveSink
+tidyErrorSummary
+tidyGeneralInfo
+tidyGetRoot
+tidyGetHtml
+tidyGetHead
+tidyGetBody
+tidyGetParent
+tidyGetChild
+tidyGetNext
+tidyGetPrev
+tidyAttrFirst
+tidyAttrNext
+tidyAttrName
+tidyAttrValue
+tidyNodeGetType
+tidyNodeGetName
+tidyNodeIsText
+tidyNodeIsProp
+tidyNodeIsHeader
+tidyNodeHasText
+tidyNodeGetText
+tidyNodeGetId
+tidyNodeLine
+tidyNodeColumn
+tidyNodeIsHTML
+tidyNodeIsHEAD
+tidyNodeIsTITLE
+tidyNodeIsBASE
+tidyNodeIsMETA
+tidyNodeIsBODY
+tidyNodeIsFRAMESET
+tidyNodeIsFRAME
+tidyNodeIsIFRAME
+tidyNodeIsNOFRAMES
+tidyNodeIsHR
+tidyNodeIsH1
+tidyNodeIsH2
+tidyNodeIsPRE
+tidyNodeIsLISTING
+tidyNodeIsP
+tidyNodeIsUL
+tidyNodeIsOL
+tidyNodeIsDL
+tidyNodeIsDIR
+tidyNodeIsLI
+tidyNodeIsDT
+tidyNodeIsDD
+tidyNodeIsTABLE
+tidyNodeIsCAPTION
+tidyNodeIsTD
+tidyNodeIsTH
+tidyNodeIsTR
+tidyNodeIsCOL
+tidyNodeIsCOLGROUP
+tidyNodeIsBR
+tidyNodeIsA
+tidyNodeIsLINK
+tidyNodeIsB
+tidyNodeIsI
+tidyNodeIsSTRONG
+tidyNodeIsEM
+tidyNodeIsBIG
+tidyNodeIsSMALL
+tidyNodeIsPARAM
+tidyNodeIsOPTION
+tidyNodeIsOPTGROUP
+tidyNodeIsIMG
+tidyNodeIsMAP
+tidyNodeIsAREA
+tidyNodeIsNOBR
+tidyNodeIsWBR
+tidyNodeIsFONT
+tidyNodeIsLAYER
+tidyNodeIsSPACER
+tidyNodeIsCENTER
+tidyNodeIsSTYLE
+tidyNodeIsSCRIPT
+tidyNodeIsNOSCRIPT
+tidyNodeIsFORM
+tidyNodeIsTEXTAREA
+tidyNodeIsBLOCKQUOTE
+tidyNodeIsAPPLET
+tidyNodeIsOBJECT
+tidyNodeIsDIV
+tidyNodeIsSPAN
+tidyNodeIsINPUT
+tidyNodeIsQ
+tidyNodeIsLABEL
+tidyNodeIsH3
+tidyNodeIsH4
+tidyNodeIsH5
+tidyNodeIsH6
+tidyNodeIsADDRESS
+tidyNodeIsXMP
+tidyNodeIsSELECT
+tidyNodeIsBLINK
+tidyNodeIsMARQUEE
+tidyNodeIsEMBED
+tidyNodeIsBASEFONT
+tidyNodeIsISINDEX
+tidyNodeIsS
+tidyNodeIsSTRIKE
+tidyNodeIsU
+tidyNodeIsMENU
+tidyAttrGetId
+tidyAttrIsEvent
+tidyAttrIsProp
+tidyAttrIsHREF
+tidyAttrIsSRC
+tidyAttrIsID
+tidyAttrIsNAME
+tidyAttrIsSUMMARY
+tidyAttrIsALT
+tidyAttrIsLONGDESC
+tidyAttrIsUSEMAP
+tidyAttrIsISMAP
+tidyAttrIsLANGUAGE
+tidyAttrIsTYPE
+tidyAttrIsVALUE
+tidyAttrIsCONTENT
+tidyAttrIsTITLE
+tidyAttrIsXMLNS
+tidyAttrIsDATAFLD
+tidyAttrIsWIDTH
+tidyAttrIsHEIGHT
+tidyAttrIsFOR
+tidyAttrIsSELECTED
+tidyAttrIsCHECKED
+tidyAttrIsLANG
+tidyAttrIsTARGET
+tidyAttrIsHTTP_EQUIV
+tidyAttrIsREL
+tidyAttrIsOnMOUSEMOVE
+tidyAttrIsOnMOUSEDOWN
+tidyAttrIsOnMOUSEUP
+tidyAttrIsOnCLICK
+tidyAttrIsOnMOUSEOVER
+tidyAttrIsOnMOUSEOUT
+tidyAttrIsOnKEYDOWN
+tidyAttrIsOnKEYUP
+tidyAttrIsOnKEYPRESS
+tidyAttrIsOnFOCUS
+tidyAttrIsOnBLUR
+tidyAttrIsBGCOLOR
+tidyAttrIsLINK
+tidyAttrIsALINK
+tidyAttrIsVLINK
+tidyAttrIsTEXT
+tidyAttrIsSTYLE
+tidyAttrIsABBR
+tidyAttrIsCOLSPAN
+tidyAttrIsROWSPAN
+tidyAttrGetHREF
+tidyAttrGetSRC
+tidyAttrGetID
+tidyAttrGetNAME
+tidyAttrGetSUMMARY
+tidyAttrGetALT
+tidyAttrGetLONGDESC
+tidyAttrGetUSEMAP
+tidyAttrGetISMAP
+tidyAttrGetLANGUAGE
+tidyAttrGetTYPE
+tidyAttrGetVALUE
+tidyAttrGetCONTENT
+tidyAttrGetTITLE
+tidyAttrGetXMLNS
+tidyAttrGetDATAFLD
+tidyAttrGetWIDTH
+tidyAttrGetHEIGHT
+tidyAttrGetFOR
+tidyAttrGetSELECTED
+tidyAttrGetCHECKED
+tidyAttrGetLANG
+tidyAttrGetTARGET
+tidyAttrGetHTTP_EQUIV
+tidyAttrGetREL
+tidyAttrGetOnMOUSEMOVE
+tidyAttrGetOnMOUSEDOWN
+tidyAttrGetOnMOUSEUP
+tidyAttrGetOnCLICK
+tidyAttrGetOnMOUSEOVER
+tidyAttrGetOnMOUSEOUT
+tidyAttrGetOnKEYDOWN
+tidyAttrGetOnKEYUP
+tidyAttrGetOnKEYPRESS
+tidyAttrGetOnFOCUS
+tidyAttrGetOnBLUR
+tidyAttrGetBGCOLOR
+tidyAttrGetLINK
+tidyAttrGetALINK
+tidyAttrGetVLINK
+tidyAttrGetTEXT
+tidyAttrGetSTYLE
+tidyAttrGetABBR
+tidyAttrGetCOLSPAN
+tidyAttrGetROWSPAN
diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h
new file mode 100644
index 0000000..9417803
--- /dev/null
+++ b/ext/tidy/php_tidy.h
@@ -0,0 +1,57 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: John Coggeshall <john@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_TIDY_H
+#define PHP_TIDY_H
+
+extern zend_module_entry tidy_module_entry;
+#define phpext_tidy_ptr &tidy_module_entry
+
+#define TIDY_METHOD_MAP(name, func_name, arg_types) \
+ ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
+#define TIDY_NODE_METHOD(name) PHP_FUNCTION(tnm_ ##name)
+#define TIDY_NODE_ME(name, param) TIDY_METHOD_MAP(name, tnm_ ##name, param)
+#define TIDY_NODE_PRIVATE_ME(name, param) ZEND_NAMED_ME(name, ZEND_FN(tnm_ ##name), param, ZEND_ACC_PRIVATE)
+#define TIDY_DOC_METHOD(name) PHP_FUNCTION(tdm_ ##name)
+#define TIDY_DOC_ME(name, param) TIDY_METHOD_MAP(name, tdm_ ##name, param)
+#define TIDY_ATTR_METHOD(name) PHP_FUNCTION(tam_ ##name)
+#define TIDY_ATTR_ME(name, param) TIDY_METHOD_MAP(name, tam_ ##name, param)
+
+ZEND_BEGIN_MODULE_GLOBALS(tidy)
+ char *default_config;
+ zend_bool clean_output;
+ZEND_END_MODULE_GLOBALS(tidy)
+
+#ifdef ZTS
+#define TG(v) TSRMG(tidy_globals_id, zend_tidy_globals *, v)
+#else
+#define TG(v) (tidy_globals.v)
+#endif
+
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/tidy/tests/001.phpt b/ext/tidy/tests/001.phpt
new file mode 100644
index 0000000..bfd3782
--- /dev/null
+++ b/ext/tidy/tests/001.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Check for tidy presence
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+echo "tidy extension is available";
+?>
+--EXPECT--
+tidy extension is available
diff --git a/ext/tidy/tests/002.phpt b/ext/tidy/tests/002.phpt
new file mode 100644
index 0000000..89c3804
--- /dev/null
+++ b/ext/tidy/tests/002.phpt
@@ -0,0 +1,18 @@
+--TEST--
+tidy_parse_string()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $a = tidy_parse_string("<HTML></HTML>");
+ echo tidy_get_output($a);
+
+?>
+--EXPECT--
+<html>
+<head>
+<title></title>
+</head>
+<body>
+</body>
+</html> \ No newline at end of file
diff --git a/ext/tidy/tests/003.phpt b/ext/tidy/tests/003.phpt
new file mode 100644
index 0000000..7201d6a
--- /dev/null
+++ b/ext/tidy/tests/003.phpt
@@ -0,0 +1,21 @@
+--TEST--
+tidy_clean_repair()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+ $a = tidy_parse_string("<HTML></HTML>");
+ tidy_clean_repair($a);
+ echo tidy_get_output($a);
+
+?>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title></title>
+</head>
+<body>
+</body>
+</html>
diff --git a/ext/tidy/tests/004.phpt b/ext/tidy/tests/004.phpt
new file mode 100644
index 0000000..d13c37d
--- /dev/null
+++ b/ext/tidy/tests/004.phpt
@@ -0,0 +1,31 @@
+--TEST--
+tidy_diagnose()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+$a = tidy_parse_string('<HTML></HTML>');
+var_dump(tidy_diagnose($a));
+echo str_replace("\r", "", tidy_get_error_buffer($a));
+
+$html = <<< HTML
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head><title>foo</title></head>
+<body><p>hello</p></body>
+</html>
+HTML;
+$a = tidy_parse_string($html);
+var_dump(tidy_diagnose($a));
+echo tidy_get_error_buffer($a);
+?>
+--EXPECT--
+bool(true)
+line 1 column 1 - Warning: missing <!DOCTYPE> declaration
+line 1 column 7 - Warning: discarding unexpected </html>
+line 1 column 14 - Warning: inserting missing 'title' element
+Info: Document content looks like HTML 3.2
+3 warnings, 0 errors were found!
+bool(true)
+Info: Document content looks like HTML 3.2
+No warnings or errors were found.
diff --git a/ext/tidy/tests/005.html b/ext/tidy/tests/005.html
new file mode 100644
index 0000000..8c17451
--- /dev/null
+++ b/ext/tidy/tests/005.html
@@ -0,0 +1 @@
+<HTML></HTML>
diff --git a/ext/tidy/tests/005.phpt b/ext/tidy/tests/005.phpt
new file mode 100644
index 0000000..1d3a10c
--- /dev/null
+++ b/ext/tidy/tests/005.phpt
@@ -0,0 +1,18 @@
+--TEST--
+tidy_parse_file()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $a = tidy_parse_file(dirname(__FILE__)."/005.html");
+ echo tidy_get_output($a);
+
+?>
+--EXPECT--
+<html>
+<head>
+<title></title>
+</head>
+<body>
+</body>
+</html> \ No newline at end of file
diff --git a/ext/tidy/tests/006.phpt b/ext/tidy/tests/006.phpt
new file mode 100644
index 0000000..c826181
--- /dev/null
+++ b/ext/tidy/tests/006.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Verbose tidy_get_error_buffer()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $a = tidy_parse_string("<HTML><asd asdf></HTML>");
+ echo tidy_get_error_buffer($a);
+
+?>
+--EXPECT--
+line 1 column 1 - Warning: missing <!DOCTYPE> declaration
+line 1 column 7 - Error: <asd> is not recognized!
+line 1 column 7 - Warning: discarding unexpected <asd>
+line 1 column 17 - Warning: discarding unexpected </html>
+line 1 column 7 - Warning: inserting missing 'title' element \ No newline at end of file
diff --git a/ext/tidy/tests/007.html b/ext/tidy/tests/007.html
new file mode 100644
index 0000000..7dc0357
--- /dev/null
+++ b/ext/tidy/tests/007.html
@@ -0,0 +1 @@
+<B>testing</I>
diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt
new file mode 100644
index 0000000..f6bb13d
--- /dev/null
+++ b/ext/tidy/tests/007.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Verbose tidy_getopt()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--INI--
+tidy.default_config=
+--FILE--
+<?php
+ $a = new tidy(dirname(__FILE__)."/007.html");
+ echo "Current Value of 'tidy-mark': ";
+ var_dump($a->getopt("tidy-mark"));
+ echo "Current Value of 'error-file': ";
+ var_dump($a->getopt("error-file"));
+ echo "Current Value of 'tab-size': ";
+ var_dump($a->getopt("tab-size"));
+
+ var_dump($a->getopt('bogus-opt'));
+ var_dump(tidy_getopt($a, 'non-ASCII string àáç'));
+?>
+--EXPECTF--
+Current Value of 'tidy-mark': bool(false)
+Current Value of 'error-file': string(0) ""
+Current Value of 'tab-size': int(8)
+
+Warning: tidy::getOpt(): Unknown Tidy Configuration Option 'bogus-opt' in %s007.php on line 10
+bool(false)
+
+Warning: tidy_getopt(): Unknown Tidy Configuration Option 'non-ASCII string àáç' in %s007.php on line 11
+bool(false)
diff --git a/ext/tidy/tests/008.phpt b/ext/tidy/tests/008.phpt
new file mode 100644
index 0000000..150b98f
--- /dev/null
+++ b/ext/tidy/tests/008.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Accessing the error buffer via $obj->error_buf...
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $a = tidy_parse_string("<HTML><asd asdf></HTML>");
+ echo $a->errorBuffer;
+?>
+--EXPECT--
+line 1 column 1 - Warning: missing <!DOCTYPE> declaration
+line 1 column 7 - Error: <asd> is not recognized!
+line 1 column 7 - Warning: discarding unexpected <asd>
+line 1 column 17 - Warning: discarding unexpected </html>
+line 1 column 7 - Warning: inserting missing 'title' element \ No newline at end of file
diff --git a/ext/tidy/tests/009.phpt b/ext/tidy/tests/009.phpt
new file mode 100644
index 0000000..02c65df
--- /dev/null
+++ b/ext/tidy/tests/009.phpt
@@ -0,0 +1,19 @@
+--TEST--
+tidy_doc object overloading
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+ $a = tidy_parse_string("<HTML></HTML>");
+ echo $a;
+
+?>
+--EXPECT--
+<html>
+<head>
+<title></title>
+</head>
+<body>
+</body>
+</html> \ No newline at end of file
diff --git a/ext/tidy/tests/010.phpt b/ext/tidy/tests/010.phpt
new file mode 100644
index 0000000..9d5ab82
--- /dev/null
+++ b/ext/tidy/tests/010.phpt
@@ -0,0 +1,317 @@
+--TEST--
+Accessing root, body, html, and head nodes..
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+$a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>", array('newline' => 'LF'));
+var_dump($a->root());
+var_dump($a->body());
+var_dump($a->html());
+var_dump($a->head());
+
+?>
+--EXPECT--
+object(tidyNode)#2 (8) {
+ ["value"]=>
+ string(94) "<html>
+<head>
+<title></title>
+</head>
+<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+</html>"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(0)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#3 (9) {
+ ["value"]=>
+ string(94) "<html>
+<head>
+<title></title>
+</head>
+<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+</html>"
+ ["name"]=>
+ string(4) "html"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(48)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(2) {
+ [0]=>
+ &object(tidyNode)#4 (9) {
+ ["value"]=>
+ string(31) "<head>
+<title></title>
+</head>
+"
+ ["name"]=>
+ string(4) "head"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(46)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#5 (9) {
+ ["value"]=>
+ string(16) "<title></title>
+"
+ ["name"]=>
+ string(5) "title"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(111)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ [1]=>
+ &object(tidyNode)#6 (9) {
+ ["value"]=>
+ string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+"
+ ["name"]=>
+ string(4) "body"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(16)
+ ["attribute"]=>
+ array(2) {
+ ["bgcolor"]=>
+ string(7) "#FFFFFF"
+ ["alink"]=>
+ string(7) "#000000"
+ }
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+object(tidyNode)#2 (9) {
+ ["value"]=>
+ string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+"
+ ["name"]=>
+ string(4) "body"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(16)
+ ["attribute"]=>
+ array(2) {
+ ["bgcolor"]=>
+ string(7) "#FFFFFF"
+ ["alink"]=>
+ string(7) "#000000"
+ }
+ ["child"]=>
+ NULL
+}
+object(tidyNode)#2 (9) {
+ ["value"]=>
+ string(94) "<html>
+<head>
+<title></title>
+</head>
+<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+</html>"
+ ["name"]=>
+ string(4) "html"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(48)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(2) {
+ [0]=>
+ &object(tidyNode)#3 (9) {
+ ["value"]=>
+ string(31) "<head>
+<title></title>
+</head>
+"
+ ["name"]=>
+ string(4) "head"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(46)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#6 (9) {
+ ["value"]=>
+ string(16) "<title></title>
+"
+ ["name"]=>
+ string(5) "title"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(111)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ [1]=>
+ &object(tidyNode)#4 (9) {
+ ["value"]=>
+ string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+</body>
+"
+ ["name"]=>
+ string(4) "body"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(16)
+ ["attribute"]=>
+ array(2) {
+ ["bgcolor"]=>
+ string(7) "#FFFFFF"
+ ["alink"]=>
+ string(7) "#000000"
+ }
+ ["child"]=>
+ NULL
+ }
+ }
+}
+object(tidyNode)#2 (9) {
+ ["value"]=>
+ string(31) "<head>
+<title></title>
+</head>
+"
+ ["name"]=>
+ string(4) "head"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(46)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#4 (9) {
+ ["value"]=>
+ string(16) "<title></title>
+"
+ ["name"]=>
+ string(5) "title"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(111)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+}
diff --git a/ext/tidy/tests/011.phpt b/ext/tidy/tests/011.phpt
new file mode 100644
index 0000000..2a94616
--- /dev/null
+++ b/ext/tidy/tests/011.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Accessing attributes of a node
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>");
+ $body = $a->body();
+ var_dump($body->attribute);
+ foreach($body->attribute as $key=>$val) {
+ echo "Attrib '$key': $val\n";
+ }
+?>
+--EXPECT--
+array(2) {
+ ["bgcolor"]=>
+ string(7) "#FFFFFF"
+ ["alink"]=>
+ string(7) "#000000"
+}
+Attrib 'bgcolor': #FFFFFF
+Attrib 'alink': #000000 \ No newline at end of file
diff --git a/ext/tidy/tests/012.phpt b/ext/tidy/tests/012.phpt
new file mode 100644
index 0000000..1205812
--- /dev/null
+++ b/ext/tidy/tests/012.phpt
@@ -0,0 +1,473 @@
+--TEST--
+Accessing children nodes
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+ function dump_nodes(tidyNode $node) {
+
+ var_dump($node->hasChildren());
+ if($node->hasChildren()) {
+
+ foreach($node->child as $c) {
+
+ var_dump($c);
+
+ if($c->hasChildren()) {
+
+ dump_nodes($c);
+
+ }
+ }
+
+ }
+
+ }
+
+ $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>", array('newline' => 'LF'));
+ $html = $a->html();
+ dump_nodes($html);
+
+?>
+--EXPECT--
+bool(true)
+object(tidyNode)#3 (9) {
+ ["value"]=>
+ string(31) "<head>
+<title></title>
+</head>
+"
+ ["name"]=>
+ string(4) "head"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(46)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#4 (9) {
+ ["value"]=>
+ string(16) "<title></title>
+"
+ ["name"]=>
+ string(5) "title"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(87)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(111)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+}
+bool(true)
+object(tidyNode)#4 (9) {
+ ["value"]=>
+ string(16) "<title></title>
+"
+ ["name"]=>
+ string(5) "title"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(87)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(111)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+}
+object(tidyNode)#5 (9) {
+ ["value"]=>
+ string(80) "<body bgcolor="#FFFFFF" alink="#000000">
+<b>Hi</b><i>Bye<u>Test</u></i>
+</body>
+"
+ ["name"]=>
+ string(4) "body"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(16)
+ ["attribute"]=>
+ array(2) {
+ ["bgcolor"]=>
+ string(7) "#FFFFFF"
+ ["alink"]=>
+ string(7) "#000000"
+ }
+ ["child"]=>
+ array(2) {
+ [0]=>
+ &object(tidyNode)#6 (9) {
+ ["value"]=>
+ string(9) "<b>Hi</b>"
+ ["name"]=>
+ string(1) "b"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(43)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(8)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#7 (8) {
+ ["value"]=>
+ string(2) "Hi"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(46)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ [1]=>
+ &object(tidyNode)#8 (9) {
+ ["value"]=>
+ string(21) "<i>Bye<u>Test</u></i>"
+ ["name"]=>
+ string(1) "i"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(52)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(49)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(2) {
+ [0]=>
+ &object(tidyNode)#9 (8) {
+ ["value"]=>
+ string(3) "Bye"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(55)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ [1]=>
+ &object(tidyNode)#10 (9) {
+ ["value"]=>
+ string(11) "<u>Test</u>"
+ ["name"]=>
+ string(1) "u"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(58)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(114)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#11 (8) {
+ ["value"]=>
+ string(4) "Test"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(61)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ }
+ }
+ }
+}
+bool(true)
+object(tidyNode)#6 (9) {
+ ["value"]=>
+ string(9) "<b>Hi</b>"
+ ["name"]=>
+ string(1) "b"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(43)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(8)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#7 (8) {
+ ["value"]=>
+ string(2) "Hi"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(46)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+}
+bool(true)
+object(tidyNode)#7 (8) {
+ ["value"]=>
+ string(2) "Hi"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(46)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+}
+object(tidyNode)#8 (9) {
+ ["value"]=>
+ string(21) "<i>Bye<u>Test</u></i>"
+ ["name"]=>
+ string(1) "i"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(52)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(49)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(2) {
+ [0]=>
+ &object(tidyNode)#9 (8) {
+ ["value"]=>
+ string(3) "Bye"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(55)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ [1]=>
+ &object(tidyNode)#10 (9) {
+ ["value"]=>
+ string(11) "<u>Test</u>"
+ ["name"]=>
+ string(1) "u"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(58)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(114)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#11 (8) {
+ ["value"]=>
+ string(4) "Test"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(61)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+bool(true)
+object(tidyNode)#9 (8) {
+ ["value"]=>
+ string(3) "Bye"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(55)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+}
+object(tidyNode)#10 (9) {
+ ["value"]=>
+ string(11) "<u>Test</u>"
+ ["name"]=>
+ string(1) "u"
+ ["type"]=>
+ int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(58)
+ ["proprietary"]=>
+ bool(false)
+ ["id"]=>
+ int(114)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ array(1) {
+ [0]=>
+ &object(tidyNode)#11 (8) {
+ ["value"]=>
+ string(4) "Test"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(61)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+ }
+ }
+}
+bool(true)
+object(tidyNode)#11 (8) {
+ ["value"]=>
+ string(4) "Test"
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ int(4)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(61)
+ ["proprietary"]=>
+ bool(false)
+ ["attribute"]=>
+ NULL
+ ["child"]=>
+ NULL
+}
diff --git a/ext/tidy/tests/013.html b/ext/tidy/tests/013.html
new file mode 100644
index 0000000..7dc0357
--- /dev/null
+++ b/ext/tidy/tests/013.html
@@ -0,0 +1 @@
+<B>testing</I>
diff --git a/ext/tidy/tests/013.phpt b/ext/tidy/tests/013.phpt
new file mode 100644
index 0000000..8f1ac94
--- /dev/null
+++ b/ext/tidy/tests/013.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Parsing a file using constructor
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $tidy = new tidy(dirname(__FILE__)."/013.html", array("show-body-only"=>true));
+ $tidy->cleanRepair();
+ echo $tidy;
+
+?>
+--EXPECT--
+<b>testing</b>
diff --git a/ext/tidy/tests/014.phpt b/ext/tidy/tests/014.phpt
new file mode 100644
index 0000000..a391b3d
--- /dev/null
+++ b/ext/tidy/tests/014.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Passing configuration options through tidy_parse_string().
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $text = "<B>testing</I>";
+ $tidy = tidy_parse_string($text, array('show-body-only'=>true));
+ tidy_clean_repair($tidy);
+ echo tidy_get_output($tidy);
+
+?>
+--EXPECT--
+<b>testing</b> \ No newline at end of file
diff --git a/ext/tidy/tests/015.html b/ext/tidy/tests/015.html
new file mode 100644
index 0000000..7dc0357
--- /dev/null
+++ b/ext/tidy/tests/015.html
@@ -0,0 +1 @@
+<B>testing</I>
diff --git a/ext/tidy/tests/015.phpt b/ext/tidy/tests/015.phpt
new file mode 100644
index 0000000..03018ff
--- /dev/null
+++ b/ext/tidy/tests/015.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Passing configuration options through tidy_parse_file().
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $tidy = tidy_parse_file(dirname(__FILE__)."/015.html", array('show-body-only'=>true));
+ tidy_clean_repair($tidy);
+ echo tidy_get_output($tidy);
+
+?>
+--EXPECT--
+<b>testing</b> \ No newline at end of file
diff --git a/ext/tidy/tests/016.html b/ext/tidy/tests/016.html
new file mode 100644
index 0000000..7dc6e4a
--- /dev/null
+++ b/ext/tidy/tests/016.html
@@ -0,0 +1 @@
+<P><B><FONT SIZE=10 COLOR=#FF0000>testing</FONT></I></P>
diff --git a/ext/tidy/tests/016.phpt b/ext/tidy/tests/016.phpt
new file mode 100644
index 0000000..001371a
--- /dev/null
+++ b/ext/tidy/tests/016.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Passing configuration file through tidy_parse_file() (may fail with buggy libtidy)
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+ $tidy = tidy_parse_file(dirname(__FILE__)."/016.html", dirname(__FILE__)."/016.tcfg");
+ tidy_clean_repair($tidy);
+ echo tidy_get_output($tidy);
+?>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title></title>
+
+<style type="text/css">
+ p.c1 {font-weight: bold}
+</style>
+</head>
+<body>
+<p class="c1">testing</p>
+</body>
+</html>
diff --git a/ext/tidy/tests/016.tcfg b/ext/tidy/tests/016.tcfg
new file mode 100644
index 0000000..fd6e4e4
--- /dev/null
+++ b/ext/tidy/tests/016.tcfg
@@ -0,0 +1 @@
+clean: yes
diff --git a/ext/tidy/tests/017.phpt b/ext/tidy/tests/017.phpt
new file mode 100644
index 0000000..ba620a3
--- /dev/null
+++ b/ext/tidy/tests/017.phpt
@@ -0,0 +1,17 @@
+--TEST--
+The Tidy Output Buffer Filter
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php ob_start("ob_tidyhandler"); ?>
+<B>testing</I>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<b>testing</b>
+</body>
+</html> \ No newline at end of file
diff --git a/ext/tidy/tests/018.phpt b/ext/tidy/tests/018.phpt
new file mode 100644
index 0000000..405a46d
--- /dev/null
+++ b/ext/tidy/tests/018.phpt
@@ -0,0 +1,16 @@
+--TEST--
+binary safety
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+$x = tidy_repair_string("<p>abra\0cadabra</p>",
+ array( 'show-body-only' => true,
+ 'clean' => false,
+ 'newline' => "\n")
+ );
+var_dump($x);
+?>
+--EXPECT--
+string(19) "<p>abracadabra</p>
+"
diff --git a/ext/tidy/tests/019.phpt b/ext/tidy/tests/019.phpt
new file mode 100644
index 0000000..5e9c38d
--- /dev/null
+++ b/ext/tidy/tests/019.phpt
@@ -0,0 +1,42 @@
+--TEST--
+tidy_repair_*() and invalid parameters
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+$l = 1;
+$s = "";
+$a = array();
+
+tidy_repair_string($s, $l, $l, $l);
+tidy_repair_string($s, $s, $s, $s);
+tidy_repair_string($l, $l, $l ,$l);
+tidy_repair_string($a, $a, $a, $a);
+
+tidy_repair_file($s, $l, $l, $l);
+tidy_repair_file($s, $s, $s, $s);
+tidy_repair_file($l, $l, $l ,$l);
+tidy_repair_file($a, $a, $a, $a);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d
+
+Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d
+
+Warning: tidy_repair_file() expects parameter 1 to be a valid path, array given in %s on line %d
+Done
diff --git a/ext/tidy/tests/020.phpt b/ext/tidy/tests/020.phpt
new file mode 100644
index 0000000..dbfda96
--- /dev/null
+++ b/ext/tidy/tests/020.phpt
@@ -0,0 +1,36 @@
+--TEST--
+OO API
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+$tidy = new tidy();
+$str = <<<EOF
+<p>Isto é um texto em Português<br>
+para testes.</p>
+EOF;
+
+$tidy->parseString($str, array('output-xhtml'=>1), 'latin1');
+$tidy->cleanRepair();
+$tidy->diagnose();
+var_dump(tidy_warning_count($tidy) > 0);
+var_dump(strlen($tidy->errorBuffer) > 50);
+
+echo $tidy;
+?>
+--EXPECT--
+bool(true)
+bool(true)
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title></title>
+</head>
+<body>
+<p>Isto é um texto em Português<br />
+para testes.</p>
+</body>
+</html>
diff --git a/ext/tidy/tests/021.phpt b/ext/tidy/tests/021.phpt
new file mode 100644
index 0000000..bdf9546
--- /dev/null
+++ b/ext/tidy/tests/021.phpt
@@ -0,0 +1,18 @@
+--TEST--
+tidy_get_opt_doc()
+--SKIPIF--
+<?php if (!extension_loaded("tidy") || !function_exists('tidy_get_opt_doc')) print "skip"; ?>
+--FILE--
+<?php
+
+var_dump(tidy_get_opt_doc(new tidy, 'some_bogus_cfg'));
+
+$t = new tidy;
+var_dump($t->getOptDoc('ncr'));
+var_dump(strlen(tidy_get_opt_doc($t, 'wrap')) > 99);
+?>
+--EXPECTF--
+Warning: tidy_get_opt_doc(): Unknown Tidy Configuration Option 'some_bogus_cfg' in %s021.php on line 3
+bool(false)
+string(73) "This option specifies if Tidy should allow numeric character references. "
+bool(true)
diff --git a/ext/tidy/tests/022.phpt b/ext/tidy/tests/022.phpt
new file mode 100644
index 0000000..5e9c38d
--- /dev/null
+++ b/ext/tidy/tests/022.phpt
@@ -0,0 +1,42 @@
+--TEST--
+tidy_repair_*() and invalid parameters
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+$l = 1;
+$s = "";
+$a = array();
+
+tidy_repair_string($s, $l, $l, $l);
+tidy_repair_string($s, $s, $s, $s);
+tidy_repair_string($l, $l, $l ,$l);
+tidy_repair_string($a, $a, $a, $a);
+
+tidy_repair_file($s, $l, $l, $l);
+tidy_repair_file($s, $s, $s, $s);
+tidy_repair_file($l, $l, $l ,$l);
+tidy_repair_file($a, $a, $a, $a);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d
+
+Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d
+
+Warning: tidy_repair_file() expects parameter 1 to be a valid path, array given in %s on line %d
+Done
diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt
new file mode 100644
index 0000000..1f7b02d
--- /dev/null
+++ b/ext/tidy/tests/023.phpt
@@ -0,0 +1,41 @@
+--TEST--
+tidy and tidyNode OO
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) echo 'skip'; ?>
+--FILE--
+<?php
+
+//test leaks here:
+new tidy();
+var_dump(new tidy());
+
+echo "-------\n";
+
+$tidy = new tidy();
+$tidy->parseString('<html><?php echo "xpto;" ?></html>');
+
+var_dump(tidy_get_root($tidy)->child[0]->isHtml());
+var_dump(tidy_get_root($tidy)->child[0]->child[0]->isPHP());
+var_dump(tidy_get_root($tidy)->child[0]->child[0]->isAsp());
+var_dump(tidy_get_root($tidy)->child[0]->child[0]->isJste());
+var_dump(tidy_get_root($tidy)->child[0]->child[0]->type === TIDY_NODETYPE_PHP);
+
+var_dump(tidy_get_root($tidy)->child[0]->hasChildren());
+var_dump(tidy_get_root($tidy)->child[0]->child[0]->hasChildren());
+
+?>
+--EXPECT--
+object(tidy)#1 (2) {
+ ["errorBuffer"]=>
+ NULL
+ ["value"]=>
+ NULL
+}
+-------
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/tidy/tests/024.phpt b/ext/tidy/tests/024.phpt
new file mode 100644
index 0000000..b09f5b4
--- /dev/null
+++ b/ext/tidy/tests/024.phpt
@@ -0,0 +1,40 @@
+--TEST--
+libtidy handling of 'new-blocklevel-tags'
+--SKIPIF--
+<?php
+if (!extension_loaded('tidy')) die('skip');
+if (strtotime(tidy_get_release()) < strtotime('20 january 2007')) die ('skip old libtidy');
+?>
+--FILE--
+<?php
+
+// more info at http://sf.net/tracker/?func=detail&atid=390963&aid=1598422&group_id=27659
+
+$contents = '
+<wps:block>
+<wps:var>
+<wps:value/>
+</wps:var>
+</wps:block>';
+
+$config = array(
+'new-blocklevel-tags' => 'wps:block,wps:var,wps:value',
+'newline' => 'LF'
+);
+
+$tidy = tidy_parse_string($contents, $config, 'utf8');
+$tidy->cleanRepair();
+
+var_dump($tidy->value);
+
+?>
+--EXPECTF--
+string(11%d) "<html>
+<head>
+<title></title>
+</head>
+<body>
+<wps:block>%w<wps:var>
+<wps:value></wps:var>%w</wps:block>
+</body>
+</html>"
diff --git a/ext/tidy/tests/025.phpt b/ext/tidy/tests/025.phpt
new file mode 100644
index 0000000..df9392e
--- /dev/null
+++ b/ext/tidy/tests/025.phpt
@@ -0,0 +1,36 @@
+--TEST--
+tidyNode tests
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) die('skip'); ?>
+--FILE--
+<?php
+
+$tidy=tidy_parse_string('<% %>', array('newline' => 'LF'));
+var_dump($tidy->Root()->child[0]->isAsp());
+
+$tidy=tidy_parse_string('<# #>', array('newline' => 'LF'));
+var_dump($tidy->Root()->child[0]->isJste());
+
+$tidy=tidy_parse_string('<html><body>text</body></html>');
+var_dump($tidy->Root()->child[0]->child[1]->child[0]->isText());
+
+$tidy=tidy_parse_string('<html><body><!-- comment --></body></html>', array('newline' => 'LF'));
+$n = $tidy->Root()->child[0]->child[1]->child[0];
+var_dump($n->isComment());
+var_dump((string)$n);
+var_dump((bool)$n);
+var_dump((double)$n);
+var_dump((int)$n);
+var_dump($tidy->Root()->child[0]->child[0]->hasSiblings());
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+string(16) "<!-- comment -->"
+bool(true)
+float(0)
+int(0)
+bool(true)
diff --git a/ext/tidy/tests/026.phpt b/ext/tidy/tests/026.phpt
new file mode 100644
index 0000000..24a1e6f
--- /dev/null
+++ b/ext/tidy/tests/026.phpt
@@ -0,0 +1,24 @@
+--TEST--
+tidy.clean_output test
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) die('skip'); ?>
+--INI--
+tidy.clean_output=1
+--FILE--
+<html>
+<?php
+
+echo '<p>xpto</p>';
+
+?>
+</html>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<p>xpto</p>
+</body>
+</html>
diff --git a/ext/tidy/tests/027.phpt b/ext/tidy/tests/027.phpt
new file mode 100644
index 0000000..8d9f66e
--- /dev/null
+++ b/ext/tidy/tests/027.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Bug: tidy segfaults with markup=false
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) die('skip'); ?>
+--FILE--
+<?php
+
+// bug report from http://sf.net/tracker/?func=detail&atid=390963&aid=1641868&group_id=27659
+
+abstract class BaseClass {
+ private static $tidyconfig;
+
+ public function BaseClass() {
+ $this->tidyconfig = array(
+ 'indent' => false,
+ 'clean' => true,
+ 'merge-divs' => false,
+ 'quote-marks' => true,
+ 'drop-empty-paras' => false,
+ 'markup' => false,
+ 'output-xhtml' => true,
+ 'wrap' => 0);
+
+ }
+
+ abstract public function run();
+
+ public function getURL($url) {
+ $data = "awerawer"; // in my code, $data is downloaded from a site
+
+ $tidy = new tidy;
+ $tidy->parseString($data, $this->tidyconfig, 'utf8');
+ $tidy->cleanRepair();
+
+ return $tidy;
+ }
+
+}
+
+class ChildClass extends BaseClass {
+ public function ChildClass() {
+ parent::__construct();
+ }
+
+ public function run() {
+ $result = $this->getURL('awer');
+ if ($result === null) {
+ echo "\tError:\n";
+ }
+ var_dump((string)$result);
+ }
+}
+
+$instance = new ChildClass();
+$instance->run();
+
+?>
+--EXPECT--
+string(0) ""
diff --git a/ext/tidy/tests/028.phpt b/ext/tidy/tests/028.phpt
new file mode 100644
index 0000000..01f3fd1
--- /dev/null
+++ b/ext/tidy/tests/028.phpt
@@ -0,0 +1,15 @@
+--TEST--
+tidyNode::getParent()
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+$x = tidy_parse_string("<body><div>Content</div></body>");
+var_dump($x->body()->child[0]->name);
+var_dump($x->body()->child[0]->getParent()->name);
+var_dump($x->root()->getParent());
+?>
+--EXPECT--
+string(3) "div"
+string(4) "body"
+NULL
diff --git a/ext/tidy/tests/029.phpt b/ext/tidy/tests/029.phpt
new file mode 100644
index 0000000..1709cd6
--- /dev/null
+++ b/ext/tidy/tests/029.phpt
@@ -0,0 +1,28 @@
+--TEST--
+tidy_get_body() crash
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) die('skip'); ?>
+--FILE--
+<?php
+
+// bug report taken from http://news.php.net/php.notes/130628
+
+$inputs = array(
+ '<frameset > </frameset>',
+ '<html><frameset> </frameset> </html',
+);
+
+
+foreach ($inputs as $input) {
+
+ $t = tidy_parse_string($input);
+ $t->cleanRepair();
+ var_dump(tidy_get_body($t));
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+NULL
+NULL
+Done
diff --git a/ext/tidy/tests/030.phpt b/ext/tidy/tests/030.phpt
new file mode 100644
index 0000000..c351f9a
--- /dev/null
+++ b/ext/tidy/tests/030.phpt
@@ -0,0 +1,29 @@
+--TEST--
+getConfig() method - basic test for getConfig()
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<html></html>';
+$config = array(
+ 'indent' => true, // AutoBool
+ 'indent-attributes' => true, // Boolean
+ 'indent-spaces' => 3, // Integer
+ 'language' => 'de'); // String
+$tidy = new tidy();
+$tidy->parseString($buffer, $config);
+$c = $tidy->getConfig();
+var_dump($c['indent']);
+var_dump($c['indent-attributes']);
+var_dump($c['indent-spaces']);
+var_dump($c['language']);
+?>
+--EXPECTF--
+int(1)
+bool(true)
+int(3)
+%s(2) "de"
diff --git a/ext/tidy/tests/031.phpt b/ext/tidy/tests/031.phpt
new file mode 100644
index 0000000..cf6aed9
--- /dev/null
+++ b/ext/tidy/tests/031.phpt
@@ -0,0 +1,18 @@
+--TEST--
+tidy_config_count() function - basic test for tidy_config_count()
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<html></html>';
+$config = array('doctype' => 'php');
+
+$tidy = tidy_parse_string($buffer, $config);
+var_dump(tidy_config_count($tidy));
+?>
+--EXPECTF--
+int(%d)
diff --git a/ext/tidy/tests/032.phpt b/ext/tidy/tests/032.phpt
new file mode 100644
index 0000000..23230b0
--- /dev/null
+++ b/ext/tidy/tests/032.phpt
@@ -0,0 +1,17 @@
+--TEST--
+tidy_error_count() function - basic test for tidy_error_count()
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<img src="file.png" /><php>';
+
+$tidy = tidy_parse_string($buffer);
+var_dump(tidy_error_count($tidy));
+?>
+--EXPECTF--
+int(%d)
diff --git a/ext/tidy/tests/033.phpt b/ext/tidy/tests/033.phpt
new file mode 100644
index 0000000..2c4bb44
--- /dev/null
+++ b/ext/tidy/tests/033.phpt
@@ -0,0 +1,17 @@
+--TEST--
+tidy_warning_count() function - basic test for tidy_warning_count()
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<img src="file.png" /><php>';
+
+$tidy = tidy_parse_string($buffer);
+var_dump(tidy_warning_count($tidy));
+?>
+--EXPECTF--
+int(%d)
diff --git a/ext/tidy/tests/034.phpt b/ext/tidy/tests/034.phpt
new file mode 100644
index 0000000..9780315
--- /dev/null
+++ b/ext/tidy/tests/034.phpt
@@ -0,0 +1,20 @@
+--TEST--
+tidy_access_count() function - basic test for tidy_access_count()
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<img src="file.png" /><php>';
+$config = array(
+ 'accessibility-check' => 1);
+
+$tidy = tidy_parse_string($buffer, $config);
+$tidy->diagnose();
+var_dump(tidy_access_count($tidy));
+?>
+--EXPECTF--
+int(%d)
diff --git a/ext/tidy/tests/035.phpt b/ext/tidy/tests/035.phpt
new file mode 100644
index 0000000..832f90f
--- /dev/null
+++ b/ext/tidy/tests/035.phpt
@@ -0,0 +1,12 @@
+--TEST--
+tidyNode::__construct()
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+new tidyNode;
+?>
+--EXPECTF--
+Fatal error: Call to private tidyNode::__construct() from invalid context in %s on line %d
diff --git a/ext/tidy/tests/bug54682.phpt b/ext/tidy/tests/bug54682.phpt
new file mode 100644
index 0000000..2bebe11
--- /dev/null
+++ b/ext/tidy/tests/bug54682.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Tidy::diagnose() NULL pointer dereference
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+$nx = new Tidy("*");
+$nx->diagnose();
+
+?>
+--EXPECTF--
+Warning: tidy::__construct(): Cannot Load '*' into memory%win %s on line %d
diff --git a/ext/tidy/tests/bug_50558.phpt b/ext/tidy/tests/bug_50558.phpt
new file mode 100644
index 0000000..b37cb92
--- /dev/null
+++ b/ext/tidy/tests/bug_50558.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #50558 - Broken object model when extending tidy
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+class MyTidy extends tidy
+{
+ // foo
+}
+
+function doSomething(MyTidy $o)
+{
+ var_dump($o);
+}
+
+$o = new MyTidy();
+var_dump($o instanceof MyTidy);
+doSomething($o);
+?>
+--EXPECTF--
+bool(true)
+object(MyTidy)#%d (%d) {
+ ["errorBuffer"]=>
+ NULL
+ ["value"]=>
+ NULL
+}
diff --git a/ext/tidy/tests/tidy_error.phpt b/ext/tidy/tests/tidy_error.phpt
new file mode 100644
index 0000000..5416da8
--- /dev/null
+++ b/ext/tidy/tests/tidy_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Ensure tidy_get_status() returns correct status
+--CREDITS--
+Stefan Priebsch
+--SKIPIF--
+<?php
+ if (!extension_loaded("tidy")) print "skip tidy extension not loaded";
+?>
+--FILE--
+<?php
+
+$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<p>paragraph</p>
+</body>
+</html>';
+$tidy = tidy_parse_string($html);
+
+echo tidy_get_status($tidy);
+// status 0 indicates no errors or warnings
+
+$html = '<p>paragraph</i>';
+$tidy = tidy_parse_string($html);
+
+echo tidy_get_status($tidy);
+// status 1 indicates warnings
+
+$html = '<bogus>test</bogus>';
+$tidy = tidy_parse_string($html);
+
+echo tidy_get_status($tidy);
+// status 2 indicates error
+
+?>
+--EXPECT--
+012
+
diff --git a/ext/tidy/tests/tidy_error1.phpt b/ext/tidy/tests/tidy_error1.phpt
new file mode 100644
index 0000000..a924469
--- /dev/null
+++ b/ext/tidy/tests/tidy_error1.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Notice triggered by invalid configuration options
+--CREDITS--
+Christian Wenz <wenz@php.net>
+--SKIPIF--
+<?php
+ if (!extension_loaded('tidy')) die ('skip tidy not present');
+?>
+--FILE--
+<?php
+$buffer = '<html></html>';
+$config = array('bogus' => 'willnotwork');
+
+$tidy = new tidy();
+var_dump($tidy->parseString($buffer, $config));
+?>
+--EXPECTF--
+Notice: tidy::parseString(): Unknown Tidy Configuration Option 'bogus' in %s on line %d
+bool(true)
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
new file mode 100644
index 0000000..5cfb164
--- /dev/null
+++ b/ext/tidy/tidy.c
@@ -0,0 +1,2001 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: John Coggeshall <john@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_tidy.h"
+
+#if HAVE_TIDY
+
+#include "php_ini.h"
+#include "ext/standard/info.h"
+
+#include "tidy.h"
+#include "buffio.h"
+
+/* compatibility with older versions of libtidy */
+#ifndef TIDY_CALL
+#define TIDY_CALL
+#endif
+
+#define PHP_TIDY_MODULE_VERSION "2.0"
+
+/* {{{ ext/tidy macros
+*/
+#define FIX_BUFFER(bptr) do { if ((bptr)->size) { (bptr)->bp[(bptr)->size-1] = '\0'; } } while(0)
+
+#define TIDY_SET_CONTEXT \
+ zval *object = getThis();
+
+#define TIDY_FETCH_OBJECT \
+ PHPTidyObj *obj; \
+ TIDY_SET_CONTEXT; \
+ if (object) { \
+ if (zend_parse_parameters_none() == FAILURE) { \
+ return; \
+ } \
+ } else { \
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "O", &object, tidy_ce_doc) == FAILURE) { \
+ RETURN_FALSE; \
+ } \
+ } \
+ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); \
+
+#define TIDY_FETCH_ONLY_OBJECT \
+ PHPTidyObj *obj; \
+ TIDY_SET_CONTEXT; \
+ if (zend_parse_parameters_none() == FAILURE) { \
+ return; \
+ } \
+ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); \
+
+#define TIDY_APPLY_CONFIG_ZVAL(_doc, _val) \
+ if(_val) { \
+ if(Z_TYPE_PP(_val) == IS_ARRAY) { \
+ _php_tidy_apply_config_array(_doc, HASH_OF(*_val) TSRMLS_CC); \
+ } else { \
+ convert_to_string_ex(_val); \
+ TIDY_OPEN_BASE_DIR_CHECK(Z_STRVAL_PP(_val)); \
+ switch (tidyLoadConfig(_doc, Z_STRVAL_PP(_val))) { \
+ case -1: \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_PP(_val)); \
+ break; \
+ case 1: \
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There were errors while parsing the configuration file '%s'", Z_STRVAL_PP(_val)); \
+ break; \
+ } \
+ } \
+ }
+
+#define REGISTER_TIDY_CLASS(classname, name, parent, __flags) \
+ { \
+ zend_class_entry ce; \
+ INIT_CLASS_ENTRY(ce, # classname, tidy_funcs_ ## name); \
+ ce.create_object = tidy_object_new_ ## name; \
+ tidy_ce_ ## name = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
+ tidy_ce_ ## name->ce_flags |= __flags; \
+ memcpy(&tidy_object_handlers_ ## name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \
+ tidy_object_handlers_ ## name.clone_obj = NULL; \
+ }
+
+#define TIDY_TAG_CONST(tag) REGISTER_LONG_CONSTANT("TIDY_TAG_" #tag, TidyTag_##tag, CONST_CS | CONST_PERSISTENT)
+#define TIDY_NODE_CONST(name, type) REGISTER_LONG_CONSTANT("TIDY_NODETYPE_" #name, TidyNode_##type, CONST_CS | CONST_PERSISTENT)
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define ADD_PROPERTY_STRING(_table, _key, _string) \
+ { \
+ zval *tmp; \
+ MAKE_STD_ZVAL(tmp); \
+ if (_string) { \
+ ZVAL_STRING(tmp, (char *)_string, 1); \
+ } else { \
+ ZVAL_EMPTY_STRING(tmp); \
+ } \
+ zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+ }
+
+#define ADD_PROPERTY_STRINGL(_table, _key, _string, _len) \
+ { \
+ zval *tmp; \
+ MAKE_STD_ZVAL(tmp); \
+ if (_string) { \
+ ZVAL_STRINGL(tmp, (char *)_string, _len, 1); \
+ } else { \
+ ZVAL_EMPTY_STRING(tmp); \
+ } \
+ zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+ }
+
+#define ADD_PROPERTY_LONG(_table, _key, _long) \
+ { \
+ zval *tmp; \
+ MAKE_STD_ZVAL(tmp); \
+ ZVAL_LONG(tmp, _long); \
+ zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+ }
+
+#define ADD_PROPERTY_NULL(_table, _key) \
+ { \
+ zval *tmp; \
+ MAKE_STD_ZVAL(tmp); \
+ ZVAL_NULL(tmp); \
+ zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+ }
+
+#define ADD_PROPERTY_BOOL(_table, _key, _bool) \
+ { \
+ zval *tmp; \
+ MAKE_STD_ZVAL(tmp); \
+ ZVAL_BOOL(tmp, _bool); \
+ zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+ }
+
+#define TIDY_OPEN_BASE_DIR_CHECK(filename) \
+if (php_check_open_basedir(filename TSRMLS_CC)) { \
+ RETURN_FALSE; \
+} \
+
+#define TIDY_SET_DEFAULT_CONFIG(_doc) \
+ if (TG(default_config) && TG(default_config)[0]) { \
+ if (tidyLoadConfig(_doc, TG(default_config)) < 0) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load Tidy configuration file at '%s'.", TG(default_config)); \
+ } \
+ }
+/* }}} */
+
+/* {{{ ext/tidy structs
+*/
+typedef struct _PHPTidyDoc PHPTidyDoc;
+typedef struct _PHPTidyObj PHPTidyObj;
+
+typedef enum {
+ is_node,
+ is_doc
+} tidy_obj_type;
+
+typedef enum {
+ is_root_node,
+ is_html_node,
+ is_head_node,
+ is_body_node
+} tidy_base_nodetypes;
+
+struct _PHPTidyDoc {
+ TidyDoc doc;
+ TidyBuffer *errbuf;
+ unsigned int ref_count;
+ unsigned int initialized:1;
+};
+
+struct _PHPTidyObj {
+ zend_object std;
+ TidyNode node;
+ tidy_obj_type type;
+ PHPTidyDoc *ptdoc;
+};
+/* }}} */
+
+/* {{{ ext/tidy prototypes
+*/
+static char *php_tidy_file_to_mem(char *, zend_bool, int * TSRMLS_DC);
+static void tidy_object_free_storage(void * TSRMLS_DC);
+static zend_object_value tidy_object_new_node(zend_class_entry * TSRMLS_DC);
+static zend_object_value tidy_object_new_doc(zend_class_entry * TSRMLS_DC);
+static zval * tidy_instanciate(zend_class_entry *, zval * TSRMLS_DC);
+static int tidy_doc_cast_handler(zval *, zval *, int TSRMLS_DC);
+static int tidy_node_cast_handler(zval *, zval *, int TSRMLS_DC);
+static void tidy_doc_update_properties(PHPTidyObj * TSRMLS_DC);
+static void tidy_add_default_properties(PHPTidyObj *, tidy_obj_type TSRMLS_DC);
+static void *php_tidy_get_opt_val(PHPTidyDoc *, TidyOption, TidyOptionType * TSRMLS_DC);
+static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetypes);
+static int _php_tidy_set_tidy_opt(TidyDoc, char *, zval * TSRMLS_DC);
+static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC);
+static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS);
+static void _php_tidy_register_tags(INIT_FUNC_ARGS);
+static PHP_INI_MH(php_tidy_set_clean_output);
+static void php_tidy_clean_output_start(const char *name, size_t name_len TSRMLS_DC);
+static php_output_handler *php_tidy_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC);
+static int php_tidy_output_handler(void **nothing, php_output_context *output_context);
+
+static PHP_MINIT_FUNCTION(tidy);
+static PHP_MSHUTDOWN_FUNCTION(tidy);
+static PHP_RINIT_FUNCTION(tidy);
+static PHP_MINFO_FUNCTION(tidy);
+
+static PHP_FUNCTION(tidy_getopt);
+static PHP_FUNCTION(tidy_parse_string);
+static PHP_FUNCTION(tidy_parse_file);
+static PHP_FUNCTION(tidy_clean_repair);
+static PHP_FUNCTION(tidy_repair_string);
+static PHP_FUNCTION(tidy_repair_file);
+static PHP_FUNCTION(tidy_diagnose);
+static PHP_FUNCTION(tidy_get_output);
+static PHP_FUNCTION(tidy_get_error_buffer);
+static PHP_FUNCTION(tidy_get_release);
+static PHP_FUNCTION(tidy_get_config);
+static PHP_FUNCTION(tidy_get_status);
+static PHP_FUNCTION(tidy_get_html_ver);
+#if HAVE_TIDYOPTGETDOC
+static PHP_FUNCTION(tidy_get_opt_doc);
+#endif
+static PHP_FUNCTION(tidy_is_xhtml);
+static PHP_FUNCTION(tidy_is_xml);
+static PHP_FUNCTION(tidy_error_count);
+static PHP_FUNCTION(tidy_warning_count);
+static PHP_FUNCTION(tidy_access_count);
+static PHP_FUNCTION(tidy_config_count);
+
+static PHP_FUNCTION(tidy_get_root);
+static PHP_FUNCTION(tidy_get_html);
+static PHP_FUNCTION(tidy_get_head);
+static PHP_FUNCTION(tidy_get_body);
+
+static TIDY_DOC_METHOD(__construct);
+static TIDY_DOC_METHOD(parseFile);
+static TIDY_DOC_METHOD(parseString);
+
+static TIDY_NODE_METHOD(hasChildren);
+static TIDY_NODE_METHOD(hasSiblings);
+static TIDY_NODE_METHOD(isComment);
+static TIDY_NODE_METHOD(isHtml);
+static TIDY_NODE_METHOD(isText);
+static TIDY_NODE_METHOD(isJste);
+static TIDY_NODE_METHOD(isAsp);
+static TIDY_NODE_METHOD(isPhp);
+static TIDY_NODE_METHOD(getParent);
+static TIDY_NODE_METHOD(__construct);
+/* }}} */
+
+ZEND_DECLARE_MODULE_GLOBALS(tidy)
+
+PHP_INI_BEGIN()
+STD_PHP_INI_ENTRY("tidy.default_config", "", PHP_INI_SYSTEM, OnUpdateString, default_config, zend_tidy_globals, tidy_globals)
+STD_PHP_INI_ENTRY("tidy.clean_output", "0", PHP_INI_USER, php_tidy_set_clean_output, clean_output, zend_tidy_globals, tidy_globals)
+PHP_INI_END()
+
+/* {{{ arginfo */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_parse_string, 0, 0, 1)
+ ZEND_ARG_INFO(0, input)
+ ZEND_ARG_INFO(0, config_options)
+ ZEND_ARG_INFO(0, encoding)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_error_buffer, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_output, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_parse_file, 0, 0, 1)
+ ZEND_ARG_INFO(0, file)
+ ZEND_ARG_INFO(0, config_options)
+ ZEND_ARG_INFO(0, encoding)
+ ZEND_ARG_INFO(0, use_include_path)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_clean_repair, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_repair_string, 0, 0, 1)
+ ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(0, config_file)
+ ZEND_ARG_INFO(0, encoding)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_repair_file, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, config_file)
+ ZEND_ARG_INFO(0, encoding)
+ ZEND_ARG_INFO(0, use_include_path)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_diagnose, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_release, 0)
+ZEND_END_ARG_INFO()
+
+#if HAVE_TIDYOPTGETDOC
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_get_opt_doc, 0, 0, 2)
+ ZEND_ARG_INFO(0, resource)
+ ZEND_ARG_INFO(0, optname)
+ZEND_END_ARG_INFO()
+#endif
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_config, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_status, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_html_ver, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_is_xhtml, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_is_xml, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_error_count, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_warning_count, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_access_count, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_config_count, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_getopt, 0, 0, 1)
+ ZEND_ARG_INFO(0, option)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_root, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_html, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_head, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_tidy_get_body, 0, 0, 1)
+ ZEND_ARG_INFO(0, tidy)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+static const zend_function_entry tidy_functions[] = {
+ PHP_FE(tidy_getopt, arginfo_tidy_getopt)
+ PHP_FE(tidy_parse_string, arginfo_tidy_parse_string)
+ PHP_FE(tidy_parse_file, arginfo_tidy_parse_file)
+ PHP_FE(tidy_get_output, arginfo_tidy_get_output)
+ PHP_FE(tidy_get_error_buffer, arginfo_tidy_get_error_buffer)
+ PHP_FE(tidy_clean_repair, arginfo_tidy_clean_repair)
+ PHP_FE(tidy_repair_string, arginfo_tidy_repair_string)
+ PHP_FE(tidy_repair_file, arginfo_tidy_repair_file)
+ PHP_FE(tidy_diagnose, arginfo_tidy_diagnose)
+ PHP_FE(tidy_get_release, arginfo_tidy_get_release)
+ PHP_FE(tidy_get_config, arginfo_tidy_get_config)
+ PHP_FE(tidy_get_status, arginfo_tidy_get_status)
+ PHP_FE(tidy_get_html_ver, arginfo_tidy_get_html_ver)
+ PHP_FE(tidy_is_xhtml, arginfo_tidy_is_xhtml)
+ PHP_FE(tidy_is_xml, arginfo_tidy_is_xml)
+ PHP_FE(tidy_error_count, arginfo_tidy_error_count)
+ PHP_FE(tidy_warning_count, arginfo_tidy_warning_count)
+ PHP_FE(tidy_access_count, arginfo_tidy_access_count)
+ PHP_FE(tidy_config_count, arginfo_tidy_config_count)
+#if HAVE_TIDYOPTGETDOC
+ PHP_FE(tidy_get_opt_doc, arginfo_tidy_get_opt_doc)
+#endif
+ PHP_FE(tidy_get_root, arginfo_tidy_get_root)
+ PHP_FE(tidy_get_head, arginfo_tidy_get_head)
+ PHP_FE(tidy_get_html, arginfo_tidy_get_html)
+ PHP_FE(tidy_get_body, arginfo_tidy_get_body)
+ PHP_FE_END
+};
+
+static const zend_function_entry tidy_funcs_doc[] = {
+ TIDY_METHOD_MAP(getOpt, tidy_getopt, NULL)
+ TIDY_METHOD_MAP(cleanRepair, tidy_clean_repair, NULL)
+ TIDY_DOC_ME(parseFile, NULL)
+ TIDY_DOC_ME(parseString, NULL)
+ TIDY_METHOD_MAP(repairString, tidy_repair_string, NULL)
+ TIDY_METHOD_MAP(repairFile, tidy_repair_file, NULL)
+ TIDY_METHOD_MAP(diagnose, tidy_diagnose, NULL)
+ TIDY_METHOD_MAP(getRelease, tidy_get_release, NULL)
+ TIDY_METHOD_MAP(getConfig, tidy_get_config, NULL)
+ TIDY_METHOD_MAP(getStatus, tidy_get_status, NULL)
+ TIDY_METHOD_MAP(getHtmlVer, tidy_get_html_ver, NULL)
+#if HAVE_TIDYOPTGETDOC
+ TIDY_METHOD_MAP(getOptDoc, tidy_get_opt_doc, NULL)
+#endif
+ TIDY_METHOD_MAP(isXhtml, tidy_is_xhtml, NULL)
+ TIDY_METHOD_MAP(isXml, tidy_is_xml, NULL)
+ TIDY_METHOD_MAP(root, tidy_get_root, NULL)
+ TIDY_METHOD_MAP(head, tidy_get_head, NULL)
+ TIDY_METHOD_MAP(html, tidy_get_html, NULL)
+ TIDY_METHOD_MAP(body, tidy_get_body, NULL)
+ TIDY_DOC_ME(__construct, NULL)
+ PHP_FE_END
+};
+
+static const zend_function_entry tidy_funcs_node[] = {
+ TIDY_NODE_ME(hasChildren, NULL)
+ TIDY_NODE_ME(hasSiblings, NULL)
+ TIDY_NODE_ME(isComment, NULL)
+ TIDY_NODE_ME(isHtml, NULL)
+ TIDY_NODE_ME(isText, NULL)
+ TIDY_NODE_ME(isJste, NULL)
+ TIDY_NODE_ME(isAsp, NULL)
+ TIDY_NODE_ME(isPhp, NULL)
+ TIDY_NODE_ME(getParent, NULL)
+ TIDY_NODE_PRIVATE_ME(__construct, NULL)
+ PHP_FE_END
+};
+
+static zend_class_entry *tidy_ce_doc, *tidy_ce_node;
+
+static zend_object_handlers tidy_object_handlers_doc;
+static zend_object_handlers tidy_object_handlers_node;
+
+zend_module_entry tidy_module_entry = {
+ STANDARD_MODULE_HEADER,
+ "tidy",
+ tidy_functions,
+ PHP_MINIT(tidy),
+ PHP_MSHUTDOWN(tidy),
+ PHP_RINIT(tidy),
+ NULL,
+ PHP_MINFO(tidy),
+ PHP_TIDY_MODULE_VERSION,
+ PHP_MODULE_GLOBALS(tidy),
+ NULL,
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
+};
+
+#ifdef COMPILE_DL_TIDY
+ZEND_GET_MODULE(tidy)
+#endif
+
+static void* TIDY_CALL php_tidy_malloc(size_t len)
+{
+ return emalloc(len);
+}
+
+static void* TIDY_CALL php_tidy_realloc(void *buf, size_t len)
+{
+ return erealloc(buf, len);
+}
+
+static void TIDY_CALL php_tidy_free(void *buf)
+{
+ efree(buf);
+}
+
+static void TIDY_CALL php_tidy_panic(ctmbstr msg)
+{
+ TSRMLS_FETCH();
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
+}
+
+static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS_DC)
+{
+ TidyOption opt = tidyGetOptionByName(doc, optname);
+ zval conv = *value;
+
+ if (!opt) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname);
+ return FAILURE;
+ }
+
+ if (tidyOptIsReadOnly(opt)) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Attempting to set read-only option '%s'", optname);
+ return FAILURE;
+ }
+
+ switch(tidyOptGetType(opt)) {
+ case TidyString:
+ if (Z_TYPE(conv) != IS_STRING) {
+ zval_copy_ctor(&conv);
+ convert_to_string(&conv);
+ }
+ if (tidyOptSetValue(doc, tidyOptGetId(opt), Z_STRVAL(conv))) {
+ if (Z_TYPE(conv) != Z_TYPE_P(value)) {
+ zval_dtor(&conv);
+ }
+ return SUCCESS;
+ }
+ if (Z_TYPE(conv) != Z_TYPE_P(value)) {
+ zval_dtor(&conv);
+ }
+ break;
+
+ case TidyInteger:
+ if (Z_TYPE(conv) != IS_LONG) {
+ zval_copy_ctor(&conv);
+ convert_to_long(&conv);
+ }
+ if (tidyOptSetInt(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
+ return SUCCESS;
+ }
+ break;
+
+ case TidyBoolean:
+ if (Z_TYPE(conv) != IS_LONG) {
+ zval_copy_ctor(&conv);
+ convert_to_long(&conv);
+ }
+ if (tidyOptSetBool(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
+ return SUCCESS;
+ }
+ break;
+
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of configuration option");
+ break;
+ }
+
+ return FAILURE;
+}
+
+static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file)
+{
+ char *data=NULL, *arg1, *enc = NULL;
+ int arg1_len, enc_len = 0, data_len = 0;
+ zend_bool use_include_path = 0;
+ TidyDoc doc;
+ TidyBuffer *errbuf;
+ zval **config = NULL;
+
+ if (is_file) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+ if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) {
+ RETURN_FALSE;
+ }
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+ data = arg1;
+ data_len = arg1_len;
+ }
+
+ doc = tidyCreate();
+ errbuf = emalloc(sizeof(TidyBuffer));
+ tidyBufInit(errbuf);
+
+ if (tidySetErrorBuffer(doc, errbuf) != 0) {
+ tidyBufFree(errbuf);
+ efree(errbuf);
+ tidyRelease(doc);
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
+ }
+
+ tidyOptSetBool(doc, TidyForceOutput, yes);
+ tidyOptSetBool(doc, TidyMark, no);
+
+ TIDY_SET_DEFAULT_CONFIG(doc);
+
+ if (config) {
+ TIDY_APPLY_CONFIG_ZVAL(doc, config);
+ }
+
+ if(enc_len) {
+ if (tidySetCharEncoding(doc, enc) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
+ RETVAL_FALSE;
+ }
+ }
+
+ if (data) {
+ TidyBuffer buf;
+
+ tidyBufInit(&buf);
+ tidyBufAttach(&buf, (byte *) data, data_len);
+
+ if (tidyParseBuffer(doc, &buf) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf->bp);
+ RETVAL_FALSE;
+ } else {
+ if (tidyCleanAndRepair(doc) >= 0) {
+ TidyBuffer output;
+ tidyBufInit(&output);
+
+ tidySaveBuffer (doc, &output);
+ FIX_BUFFER(&output);
+ RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1);
+ tidyBufFree(&output);
+ } else {
+ RETVAL_FALSE;
+ }
+ }
+ }
+
+ if (is_file) {
+ efree(data);
+ }
+
+ tidyBufFree(errbuf);
+ efree(errbuf);
+ tidyRelease(doc);
+}
+
+static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path, int *len TSRMLS_DC)
+{
+ php_stream *stream;
+ char *data = NULL;
+
+ if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0), NULL))) {
+ return NULL;
+ }
+ if ((*len = (int) php_stream_copy_to_mem(stream, (void*) &data, PHP_STREAM_COPY_ALL, 0)) == 0) {
+ data = estrdup("");
+ *len = 0;
+ }
+ php_stream_close(stream);
+
+ return data;
+}
+
+static void tidy_object_free_storage(void *object TSRMLS_DC)
+{
+ PHPTidyObj *intern = (PHPTidyObj *)object;
+
+ zend_object_std_dtor(&intern->std TSRMLS_CC);
+
+ if (intern->ptdoc) {
+ intern->ptdoc->ref_count--;
+
+ if (intern->ptdoc->ref_count <= 0) {
+ tidyBufFree(intern->ptdoc->errbuf);
+ efree(intern->ptdoc->errbuf);
+ tidyRelease(intern->ptdoc->doc);
+ efree(intern->ptdoc);
+ }
+ }
+
+ efree(object);
+}
+
+static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers,
+ zend_object_value *retval, tidy_obj_type objtype TSRMLS_DC)
+{
+ PHPTidyObj *intern;
+
+ intern = emalloc(sizeof(PHPTidyObj));
+ memset(intern, 0, sizeof(PHPTidyObj));
+ zend_object_std_init(&intern->std, class_type TSRMLS_CC);
+ object_properties_init(&intern->std, class_type);
+
+ switch(objtype) {
+ case is_node:
+ break;
+
+ case is_doc:
+ intern->ptdoc = emalloc(sizeof(PHPTidyDoc));
+ intern->ptdoc->doc = tidyCreate();
+ intern->ptdoc->ref_count = 1;
+ intern->ptdoc->initialized = 0;
+ intern->ptdoc->errbuf = emalloc(sizeof(TidyBuffer));
+ tidyBufInit(intern->ptdoc->errbuf);
+
+ if (tidySetErrorBuffer(intern->ptdoc->doc, intern->ptdoc->errbuf) != 0) {
+ tidyBufFree(intern->ptdoc->errbuf);
+ efree(intern->ptdoc->errbuf);
+ tidyRelease(intern->ptdoc->doc);
+ efree(intern->ptdoc);
+ efree(intern);
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
+ }
+
+ tidyOptSetBool(intern->ptdoc->doc, TidyForceOutput, yes);
+ tidyOptSetBool(intern->ptdoc->doc, TidyMark, no);
+
+ TIDY_SET_DEFAULT_CONFIG(intern->ptdoc->doc);
+
+ tidy_add_default_properties(intern, is_doc TSRMLS_CC);
+ break;
+ }
+
+ retval->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) tidy_object_free_storage, NULL TSRMLS_CC);
+ retval->handlers = handlers;
+}
+
+static zend_object_value tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC)
+{
+ zend_object_value retval;
+ tidy_object_new(class_type, &tidy_object_handlers_node, &retval, is_node TSRMLS_CC);
+ return retval;
+}
+
+static zend_object_value tidy_object_new_doc(zend_class_entry *class_type TSRMLS_DC)
+{
+ zend_object_value retval;
+ tidy_object_new(class_type, &tidy_object_handlers_doc, &retval, is_doc TSRMLS_CC);
+ return retval;
+}
+
+static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
+{
+ if (!object) {
+ ALLOC_ZVAL(object);
+ }
+
+ Z_TYPE_P(object) = IS_OBJECT;
+ object_init_ex(object, pce);
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
+ return object;
+}
+
+static int tidy_doc_cast_handler(zval *in, zval *out, int type TSRMLS_DC)
+{
+ TidyBuffer output;
+ PHPTidyObj *obj;
+
+ switch(type) {
+ case IS_LONG:
+ ZVAL_LONG(out, 0);
+ break;
+
+ case IS_DOUBLE:
+ ZVAL_DOUBLE(out, 0);
+ break;
+
+ case IS_BOOL:
+ ZVAL_BOOL(out, TRUE);
+ break;
+
+ case IS_STRING:
+ obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
+ tidyBufInit(&output);
+ tidySaveBuffer (obj->ptdoc->doc, &output);
+ ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0, 1);
+ tidyBufFree(&output);
+ break;
+
+ default:
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static int tidy_node_cast_handler(zval *in, zval *out, int type TSRMLS_DC)
+{
+ TidyBuffer buf;
+ PHPTidyObj *obj;
+
+ switch(type) {
+ case IS_LONG:
+ ZVAL_LONG(out, 0);
+ break;
+
+ case IS_DOUBLE:
+ ZVAL_DOUBLE(out, 0);
+ break;
+
+ case IS_BOOL:
+ ZVAL_BOOL(out, TRUE);
+ break;
+
+ case IS_STRING:
+ obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
+ tidyBufInit(&buf);
+ if (obj->ptdoc) {
+ tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
+ ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1, 1);
+ } else {
+ ZVAL_EMPTY_STRING(out);
+ }
+ tidyBufFree(&buf);
+ break;
+
+ default:
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC)
+{
+
+ TidyBuffer output;
+ zval *temp;
+
+ tidyBufInit(&output);
+ tidySaveBuffer (obj->ptdoc->doc, &output);
+
+ if (output.size) {
+ if (!obj->std.properties) {
+ rebuild_object_properties(&obj->std);
+ }
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, (char*)output.bp, output.size-1, TRUE);
+ zend_hash_update(obj->std.properties, "value", sizeof("value"), (void *)&temp, sizeof(zval *), NULL);
+ }
+
+ tidyBufFree(&output);
+
+ if (obj->ptdoc->errbuf->size) {
+ if (!obj->std.properties) {
+ rebuild_object_properties(&obj->std);
+ }
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, (char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, TRUE);
+ zend_hash_update(obj->std.properties, "errorBuffer", sizeof("errorBuffer"), (void *)&temp, sizeof(zval *), NULL);
+ }
+}
+
+static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRMLS_DC)
+{
+
+ TidyBuffer buf;
+ TidyAttr tempattr;
+ TidyNode tempnode;
+ zval *attribute, *children, *temp;
+ PHPTidyObj *newobj;
+
+ switch(type) {
+
+ case is_node:
+ if (!obj->std.properties) {
+ rebuild_object_properties(&obj->std);
+ }
+ tidyBufInit(&buf);
+ tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
+ ADD_PROPERTY_STRINGL(obj->std.properties, value, buf.bp, buf.size ? buf.size-1 : 0);
+ tidyBufFree(&buf);
+
+ ADD_PROPERTY_STRING(obj->std.properties, name, tidyNodeGetName(obj->node));
+ ADD_PROPERTY_LONG(obj->std.properties, type, tidyNodeGetType(obj->node));
+ ADD_PROPERTY_LONG(obj->std.properties, line, tidyNodeLine(obj->node));
+ ADD_PROPERTY_LONG(obj->std.properties, column, tidyNodeColumn(obj->node));
+ ADD_PROPERTY_BOOL(obj->std.properties, proprietary, tidyNodeIsProp(obj->ptdoc->doc, obj->node));
+
+ switch(tidyNodeGetType(obj->node)) {
+ case TidyNode_Root:
+ case TidyNode_DocType:
+ case TidyNode_Text:
+ case TidyNode_Comment:
+ break;
+
+ default:
+ ADD_PROPERTY_LONG(obj->std.properties, id, tidyNodeGetId(obj->node));
+ }
+
+ tempattr = tidyAttrFirst(obj->node);
+ MAKE_STD_ZVAL(attribute);
+
+ if (tempattr) {
+ char *name, *val;
+ array_init(attribute);
+
+ do {
+ name = (char *)tidyAttrName(tempattr);
+ val = (char *)tidyAttrValue(tempattr);
+ if (name && val) {
+ add_assoc_string(attribute, name, val, TRUE);
+ }
+ } while((tempattr = tidyAttrNext(tempattr)));
+ } else {
+ ZVAL_NULL(attribute);
+ }
+ zend_hash_update(obj->std.properties, "attribute", sizeof("attribute"), (void *)&attribute, sizeof(zval *), NULL);
+
+ tempnode = tidyGetChild(obj->node);
+
+ MAKE_STD_ZVAL(children);
+ if (tempnode) {
+ array_init(children);
+ do {
+ MAKE_STD_ZVAL(temp);
+ tidy_instanciate(tidy_ce_node, temp TSRMLS_CC);
+ newobj = (PHPTidyObj *) zend_object_store_get_object(temp TSRMLS_CC);
+ newobj->node = tempnode;
+ newobj->type = is_node;
+ newobj->ptdoc = obj->ptdoc;
+ newobj->ptdoc->ref_count++;
+
+ tidy_add_default_properties(newobj, is_node TSRMLS_CC);
+ add_next_index_zval(children, temp);
+
+ } while((tempnode = tidyGetNext(tempnode)));
+
+ } else {
+ ZVAL_NULL(children);
+ }
+
+ zend_hash_update(obj->std.properties, "child", sizeof("child"), (void *)&children, sizeof(zval *), NULL);
+
+ break;
+
+ case is_doc:
+ if (!obj->std.properties) {
+ rebuild_object_properties(&obj->std);
+ }
+ ADD_PROPERTY_NULL(obj->std.properties, errorBuffer);
+ ADD_PROPERTY_NULL(obj->std.properties, value);
+ break;
+ }
+}
+
+static void *php_tidy_get_opt_val(PHPTidyDoc *ptdoc, TidyOption opt, TidyOptionType *type TSRMLS_DC)
+{
+ *type = tidyOptGetType(opt);
+
+ switch (*type) {
+ case TidyString: {
+ char *val = (char *) tidyOptGetValue(ptdoc->doc, tidyOptGetId(opt));
+ if (val) {
+ return (void *) estrdup(val);
+ } else {
+ return (void *) estrdup("");
+ }
+ }
+ break;
+
+ case TidyInteger:
+ return (void *) tidyOptGetInt(ptdoc->doc, tidyOptGetId(opt));
+ break;
+
+ case TidyBoolean:
+ return (void *) tidyOptGetBool(ptdoc->doc, tidyOptGetId(opt));
+ break;
+ }
+
+ /* should not happen */
+ return NULL;
+}
+
+static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetypes node_type)
+{
+ PHPTidyObj *newobj;
+ TidyNode node;
+ TIDY_FETCH_OBJECT;
+
+ switch (node_type) {
+ case is_root_node:
+ node = tidyGetRoot(obj->ptdoc->doc);
+ break;
+
+ case is_html_node:
+ node = tidyGetHtml(obj->ptdoc->doc);
+ break;
+
+ case is_head_node:
+ node = tidyGetHead(obj->ptdoc->doc);
+ break;
+
+ case is_body_node:
+ node = tidyGetBody(obj->ptdoc->doc);
+ break;
+
+ default:
+ RETURN_NULL();
+ break;
+ }
+
+ if (!node) {
+ RETURN_NULL();
+ }
+
+ tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC);
+ newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
+ newobj->type = is_node;
+ newobj->ptdoc = obj->ptdoc;
+ newobj->node = node;
+ newobj->ptdoc->ref_count++;
+
+ tidy_add_default_properties(newobj, is_node TSRMLS_CC);
+}
+
+static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC)
+{
+ char *opt_name;
+ zval **opt_val;
+ ulong opt_indx;
+ uint opt_name_len;
+ zend_bool clear_str;
+
+ for (zend_hash_internal_pointer_reset(ht_options);
+ zend_hash_get_current_data(ht_options, (void *) &opt_val) == SUCCESS;
+ zend_hash_move_forward(ht_options)) {
+
+ switch (zend_hash_get_current_key_ex(ht_options, &opt_name, &opt_name_len, &opt_indx, FALSE, NULL)) {
+ case HASH_KEY_IS_STRING:
+ clear_str = 0;
+ break;
+
+ case HASH_KEY_IS_LONG:
+ continue; /* ignore numeric keys */
+
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not retrieve key from option array");
+ return FAILURE;
+ }
+
+ _php_tidy_set_tidy_opt(doc, opt_name, *opt_val TSRMLS_CC);
+ if (clear_str) {
+ efree(opt_name);
+ }
+ }
+
+ return SUCCESS;
+}
+
+static int php_tidy_parse_string(PHPTidyObj *obj, char *string, int len, char *enc TSRMLS_DC)
+{
+ TidyBuffer buf;
+
+ if(enc) {
+ if (tidySetCharEncoding(obj->ptdoc->doc, enc) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
+ return FAILURE;
+ }
+ }
+
+ obj->ptdoc->initialized = 1;
+
+ tidyBufInit(&buf);
+ tidyBufAttach(&buf, (byte *) string, len);
+ if (tidyParseBuffer(obj->ptdoc->doc, &buf) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", obj->ptdoc->errbuf->bp);
+ return FAILURE;
+ }
+ tidy_doc_update_properties(obj TSRMLS_CC);
+
+ return SUCCESS;
+}
+
+static PHP_MINIT_FUNCTION(tidy)
+{
+ tidySetMallocCall(php_tidy_malloc);
+ tidySetReallocCall(php_tidy_realloc);
+ tidySetFreeCall(php_tidy_free);
+ tidySetPanicCall(php_tidy_panic);
+
+ REGISTER_INI_ENTRIES();
+ REGISTER_TIDY_CLASS(tidy, doc, NULL, 0);
+ REGISTER_TIDY_CLASS(tidyNode, node, NULL, ZEND_ACC_FINAL_CLASS);
+
+ tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler;
+ tidy_object_handlers_node.cast_object = tidy_node_cast_handler;
+
+ _php_tidy_register_tags(INIT_FUNC_ARGS_PASSTHRU);
+ _php_tidy_register_nodetypes(INIT_FUNC_ARGS_PASSTHRU);
+
+ php_output_handler_alias_register(ZEND_STRL("ob_tidyhandler"), php_tidy_output_handler_init TSRMLS_CC);
+
+ return SUCCESS;
+}
+
+static PHP_RINIT_FUNCTION(tidy)
+{
+ php_tidy_clean_output_start(ZEND_STRL("ob_tidyhandler") TSRMLS_CC);
+
+ return SUCCESS;
+}
+
+static PHP_MSHUTDOWN_FUNCTION(tidy)
+{
+ UNREGISTER_INI_ENTRIES();
+ return SUCCESS;
+}
+
+static PHP_MINFO_FUNCTION(tidy)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Tidy support", "enabled");
+ php_info_print_table_row(2, "libTidy Release", (char *)tidyReleaseDate());
+ php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id$)");
+ php_info_print_table_end();
+
+ DISPLAY_INI_ENTRIES();
+}
+
+static PHP_INI_MH(php_tidy_set_clean_output)
+{
+ int status;
+ zend_bool value;
+
+ if (new_value_length==2 && strcasecmp("on", new_value)==0) {
+ value = (zend_bool) 1;
+ } else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
+ value = (zend_bool) 1;
+ } else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
+ value = (zend_bool) 1;
+ } else {
+ value = (zend_bool) atoi(new_value);
+ }
+
+ if (stage == PHP_INI_STAGE_RUNTIME) {
+ status = php_output_get_status(TSRMLS_C);
+
+ if (value && (status & PHP_OUTPUT_WRITTEN)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot enable tidy.clean_output - there has already been output");
+ return FAILURE;
+ }
+ if (status & PHP_OUTPUT_SENT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot change tidy.clean_output - headers already sent");
+ return FAILURE;
+ }
+ }
+
+ status = OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+
+ if (stage == PHP_INI_STAGE_RUNTIME && value) {
+ if (!php_output_handler_started(ZEND_STRL("ob_tidyhandler") TSRMLS_CC)) {
+ php_tidy_clean_output_start(ZEND_STRL("ob_tidyhandler") TSRMLS_CC);
+ }
+ }
+
+ return status;
+}
+
+/*
+ * NOTE: tidy does not support iterative/cumulative parsing, so chunk-sized output handler is not possible
+ */
+
+static void php_tidy_clean_output_start(const char *name, size_t name_len TSRMLS_DC)
+{
+ php_output_handler *h;
+
+ if (TG(clean_output) && (h = php_tidy_output_handler_init(name, name_len, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC))) {
+ php_output_handler_start(h TSRMLS_CC);
+ }
+}
+
+static php_output_handler *php_tidy_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC)
+{
+ if (chunk_size) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot use a chunk size for ob_tidyhandler");
+ return NULL;
+ }
+ if (!TG(clean_output)) {
+ TG(clean_output) = 1;
+ }
+ return php_output_handler_create_internal(handler_name, handler_name_len, php_tidy_output_handler, chunk_size, flags TSRMLS_CC);
+}
+
+static int php_tidy_output_handler(void **nothing, php_output_context *output_context)
+{
+ int status = FAILURE;
+ TidyDoc doc;
+ TidyBuffer inbuf, outbuf, errbuf;
+ PHP_OUTPUT_TSRMLS(output_context);
+
+ if (TG(clean_output) && (output_context->op & PHP_OUTPUT_HANDLER_START) && (output_context->op & PHP_OUTPUT_HANDLER_FINAL)) {
+ doc = tidyCreate();
+ tidyBufInit(&errbuf);
+
+ if (0 == tidySetErrorBuffer(doc, &errbuf)) {
+ tidyOptSetBool(doc, TidyForceOutput, yes);
+ tidyOptSetBool(doc, TidyMark, no);
+
+ TIDY_SET_DEFAULT_CONFIG(doc);
+
+ tidyBufInit(&inbuf);
+ tidyBufAttach(&inbuf, (byte *) output_context->in.data, output_context->in.used);
+
+ if (0 <= tidyParseBuffer(doc, &inbuf) && 0 <= tidyCleanAndRepair(doc)) {
+ tidyBufInit(&outbuf);
+ tidySaveBuffer(doc, &outbuf);
+ FIX_BUFFER(&outbuf);
+ output_context->out.data = (char *) outbuf.bp;
+ output_context->out.used = outbuf.size ? outbuf.size-1 : 0;
+ output_context->out.free = 1;
+ status = SUCCESS;
+ }
+ }
+
+ tidyRelease(doc);
+ tidyBufFree(&errbuf);
+ }
+
+ return status;
+}
+
+/* {{{ proto bool tidy_parse_string(string input [, mixed config_options [, string encoding]])
+ Parse a document stored in a string */
+static PHP_FUNCTION(tidy_parse_string)
+{
+ char *input, *enc = NULL;
+ int input_len, enc_len = 0;
+ zval **options = NULL;
+ PHPTidyObj *obj;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC);
+ obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
+
+ TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
+
+ if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == FAILURE) {
+ zval_dtor(return_value);
+ INIT_ZVAL(*return_value);
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto string tidy_get_error_buffer()
+ Return warnings and errors which occurred parsing the specified document*/
+static PHP_FUNCTION(tidy_get_error_buffer)
+{
+ TIDY_FETCH_OBJECT;
+
+ if (obj->ptdoc->errbuf && obj->ptdoc->errbuf->bp) {
+ RETURN_STRINGL((char*)obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto string tidy_get_output()
+ Return a string representing the parsed tidy markup */
+static PHP_FUNCTION(tidy_get_output)
+{
+ TidyBuffer output;
+ TIDY_FETCH_OBJECT;
+
+ tidyBufInit(&output);
+ tidySaveBuffer(obj->ptdoc->doc, &output);
+ FIX_BUFFER(&output);
+ RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1);
+ tidyBufFree(&output);
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])
+ Parse markup in file or URI */
+static PHP_FUNCTION(tidy_parse_file)
+{
+ char *inputfile, *enc = NULL;
+ int input_len, contents_len, enc_len = 0;
+ zend_bool use_include_path = 0;
+ char *contents;
+ zval **options = NULL;
+
+ PHPTidyObj *obj;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &inputfile, &input_len,
+ &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC);
+ obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
+
+ if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
+ RETURN_FALSE;
+ }
+
+ TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
+
+ if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
+ zval_dtor(return_value);
+ INIT_ZVAL(*return_value);
+ RETVAL_FALSE;
+ }
+
+ efree(contents);
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_clean_repair()
+ Execute configured cleanup and repair operations on parsed markup */
+static PHP_FUNCTION(tidy_clean_repair)
+{
+ TIDY_FETCH_OBJECT;
+
+ if (tidyCleanAndRepair(obj->ptdoc->doc) >= 0) {
+ tidy_doc_update_properties(obj TSRMLS_CC);
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_repair_string(string data [, mixed config_file [, string encoding]])
+ Repair a string using an optionally provided configuration file */
+static PHP_FUNCTION(tidy_repair_string)
+{
+ php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])
+ Repair a file using an optionally provided configuration file */
+static PHP_FUNCTION(tidy_repair_file)
+{
+ php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_diagnose()
+ Run configured diagnostics on parsed and repaired markup. */
+static PHP_FUNCTION(tidy_diagnose)
+{
+ TIDY_FETCH_OBJECT;
+
+ if (obj->ptdoc->initialized && tidyRunDiagnostics(obj->ptdoc->doc) >= 0) {
+ tidy_doc_update_properties(obj TSRMLS_CC);
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string tidy_get_release()
+ Get release date (version) for Tidy library */
+static PHP_FUNCTION(tidy_get_release)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_STRING((char *)tidyReleaseDate(), 1);
+}
+/* }}} */
+
+
+#if HAVE_TIDYOPTGETDOC
+/* {{{ proto string tidy_get_opt_doc(tidy resource, string optname)
+ Returns the documentation for the given option name */
+static PHP_FUNCTION(tidy_get_opt_doc)
+{
+ PHPTidyObj *obj;
+ char *optval, *optname;
+ int optname_len;
+ TidyOption opt;
+
+ TIDY_SET_CONTEXT;
+
+ if (object) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ } else {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
+
+ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
+
+ if (!opt) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname);
+ RETURN_FALSE;
+ }
+
+ if ( (optval = (char *) tidyOptGetDoc(obj->ptdoc->doc, opt)) ) {
+ RETURN_STRING(optval, 1);
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+#endif
+
+
+/* {{{ proto array tidy_get_config()
+ Get current Tidy configuration */
+static PHP_FUNCTION(tidy_get_config)
+{
+ TidyIterator itOpt;
+ char *opt_name;
+ void *opt_value;
+ TidyOptionType optt;
+
+ TIDY_FETCH_OBJECT;
+
+ itOpt = tidyGetOptionList(obj->ptdoc->doc);
+
+ array_init(return_value);
+
+ while (itOpt) {
+ TidyOption opt = tidyGetNextOption(obj->ptdoc->doc, &itOpt);
+
+ opt_name = (char *)tidyOptGetName(opt);
+ opt_value = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC);
+ switch (optt) {
+ case TidyString:
+ add_assoc_string(return_value, opt_name, (char*)opt_value, 0);
+ break;
+
+ case TidyInteger:
+ add_assoc_long(return_value, opt_name, (long)opt_value);
+ break;
+
+ case TidyBoolean:
+ add_assoc_bool(return_value, opt_name, (long)opt_value);
+ break;
+ }
+ }
+
+ return;
+}
+/* }}} */
+
+/* {{{ proto int tidy_get_status()
+ Get status of specfied document. */
+static PHP_FUNCTION(tidy_get_status)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyStatus(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto int tidy_get_html_ver()
+ Get the Detected HTML version for the specified document. */
+static PHP_FUNCTION(tidy_get_html_ver)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyDetectedHtmlVersion(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_is_xhtml()
+ Indicates if the document is a XHTML document. */
+static PHP_FUNCTION(tidy_is_xhtml)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_BOOL(tidyDetectedXhtml(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto boolean tidy_is_xml()
+ Indicates if the document is a generic (non HTML/XHTML) XML document. */
+static PHP_FUNCTION(tidy_is_xml)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_BOOL(tidyDetectedGenericXml(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto int tidy_error_count()
+ Returns the Number of Tidy errors encountered for specified document. */
+static PHP_FUNCTION(tidy_error_count)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyErrorCount(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto int tidy_warning_count()
+ Returns the Number of Tidy warnings encountered for specified document. */
+static PHP_FUNCTION(tidy_warning_count)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyWarningCount(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto int tidy_access_count()
+ Returns the Number of Tidy accessibility warnings encountered for specified document. */
+static PHP_FUNCTION(tidy_access_count)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyAccessWarningCount(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto int tidy_config_count()
+ Returns the Number of Tidy configuration errors encountered for specified document. */
+static PHP_FUNCTION(tidy_config_count)
+{
+ TIDY_FETCH_OBJECT;
+
+ RETURN_LONG(tidyConfigErrorCount(obj->ptdoc->doc));
+}
+/* }}} */
+
+/* {{{ proto mixed tidy_getopt(string option)
+ Returns the value of the specified configuration option for the tidy document. */
+static PHP_FUNCTION(tidy_getopt)
+{
+ PHPTidyObj *obj;
+ char *optname;
+ void *optval;
+ int optname_len;
+ TidyOption opt;
+ TidyOptionType optt;
+
+ TIDY_SET_CONTEXT;
+
+ if (object) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ } else {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
+
+ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
+
+ if (!opt) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname);
+ RETURN_FALSE;
+ }
+
+ optval = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC);
+ switch (optt) {
+ case TidyString:
+ RETURN_STRING((char *)optval, 0);
+ break;
+
+ case TidyInteger:
+ RETURN_LONG((long)optval);
+ break;
+
+ case TidyBoolean:
+ if (optval) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+ break;
+
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of configuration option");
+ break;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+static TIDY_DOC_METHOD(__construct)
+{
+ char *inputfile = NULL, *enc = NULL;
+ int input_len = 0, enc_len = 0, contents_len = 0;
+ zend_bool use_include_path = 0;
+ char *contents;
+ zval **options = NULL;
+
+ PHPTidyObj *obj;
+ TIDY_SET_CONTEXT;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|pZsb", &inputfile, &input_len,
+ &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
+
+ if (inputfile) {
+ if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
+ return;
+ }
+
+ TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
+
+ php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC);
+
+ efree(contents);
+ }
+}
+
+static TIDY_DOC_METHOD(parseFile)
+{
+ char *inputfile, *enc = NULL;
+ int input_len, enc_len = 0, contents_len = 0;
+ zend_bool use_include_path = 0;
+ char *contents;
+ zval **options = NULL;
+ PHPTidyObj *obj;
+
+ TIDY_SET_CONTEXT;
+
+ obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|Zsb", &inputfile, &input_len,
+ &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
+ RETURN_FALSE;
+ }
+
+ TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
+
+ if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
+ RETVAL_FALSE;
+ } else {
+ RETVAL_TRUE;
+ }
+
+ efree(contents);
+}
+
+static TIDY_DOC_METHOD(parseString)
+{
+ char *input, *enc = NULL;
+ int input_len, enc_len = 0;
+ zval **options = NULL;
+ PHPTidyObj *obj;
+
+ TIDY_SET_CONTEXT;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
+
+ TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
+
+ if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) {
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+
+
+/* {{{ proto TidyNode tidy_get_root()
+ Returns a TidyNode Object representing the root of the tidy parse tree */
+static PHP_FUNCTION(tidy_get_root)
+{
+ php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_root_node);
+}
+/* }}} */
+
+/* {{{ proto TidyNode tidy_get_html()
+ Returns a TidyNode Object starting from the <HTML> tag of the tidy parse tree */
+static PHP_FUNCTION(tidy_get_html)
+{
+ php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_html_node);
+}
+/* }}} */
+
+/* {{{ proto TidyNode tidy_get_head()
+ Returns a TidyNode Object starting from the <HEAD> tag of the tidy parse tree */
+static PHP_FUNCTION(tidy_get_head)
+{
+ php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_head_node);
+}
+/* }}} */
+
+/* {{{ proto TidyNode tidy_get_body(resource tidy)
+ Returns a TidyNode Object starting from the <BODY> tag of the tidy parse tree */
+static PHP_FUNCTION(tidy_get_body)
+{
+ php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_body_node);
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::hasChildren()
+ Returns true if this node has children */
+static TIDY_NODE_METHOD(hasChildren)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyGetChild(obj->node)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::hasSiblings()
+ Returns true if this node has siblings */
+static TIDY_NODE_METHOD(hasSiblings)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (obj->node && tidyGetNext(obj->node)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isComment()
+ Returns true if this node represents a comment */
+static TIDY_NODE_METHOD(isComment)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) == TidyNode_Comment) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isHtml()
+ Returns true if this node is part of a HTML document */
+static TIDY_NODE_METHOD(isHtml)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) & (TidyNode_Start | TidyNode_End | TidyNode_StartEnd)) {
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isText()
+ Returns true if this node represents text (no markup) */
+static TIDY_NODE_METHOD(isText)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) == TidyNode_Text) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isJste()
+ Returns true if this node is JSTE */
+static TIDY_NODE_METHOD(isJste)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) == TidyNode_Jste) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isAsp()
+ Returns true if this node is ASP */
+static TIDY_NODE_METHOD(isAsp)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) == TidyNode_Asp) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto boolean tidyNode::isPhp()
+ Returns true if this node is PHP */
+static TIDY_NODE_METHOD(isPhp)
+{
+ TIDY_FETCH_ONLY_OBJECT;
+
+ if (tidyNodeGetType(obj->node) == TidyNode_Php) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto tidyNode tidyNode::getParent()
+ Returns the parent node if available or NULL */
+static TIDY_NODE_METHOD(getParent)
+{
+ TidyNode parent_node;
+ PHPTidyObj *newobj;
+ TIDY_FETCH_ONLY_OBJECT;
+
+ parent_node = tidyGetParent(obj->node);
+ if(parent_node) {
+ tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC);
+ newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
+ newobj->node = parent_node;
+ newobj->type = is_node;
+ newobj->ptdoc = obj->ptdoc;
+ newobj->ptdoc->ref_count++;
+ tidy_add_default_properties(newobj, is_node TSRMLS_CC);
+ } else {
+ ZVAL_NULL(return_value);
+ }
+}
+/* }}} */
+
+
+/* {{{ proto void tidyNode::__construct()
+ __constructor for tidyNode. */
+static TIDY_NODE_METHOD(__construct)
+{
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a tidyNode manually");
+}
+/* }}} */
+
+static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
+{
+ TIDY_NODE_CONST(ROOT, Root);
+ TIDY_NODE_CONST(DOCTYPE, DocType);
+ TIDY_NODE_CONST(COMMENT, Comment);
+ TIDY_NODE_CONST(PROCINS, ProcIns);
+ TIDY_NODE_CONST(TEXT, Text);
+ TIDY_NODE_CONST(START, Start);
+ TIDY_NODE_CONST(END, End);
+ TIDY_NODE_CONST(STARTEND, StartEnd);
+ TIDY_NODE_CONST(CDATA, CDATA);
+ TIDY_NODE_CONST(SECTION, Section);
+ TIDY_NODE_CONST(ASP, Asp);
+ TIDY_NODE_CONST(JSTE, Jste);
+ TIDY_NODE_CONST(PHP, Php);
+ TIDY_NODE_CONST(XMLDECL, XmlDecl);
+}
+
+static void _php_tidy_register_tags(INIT_FUNC_ARGS)
+{
+ TIDY_TAG_CONST(UNKNOWN);
+ TIDY_TAG_CONST(A);
+ TIDY_TAG_CONST(ABBR);
+ TIDY_TAG_CONST(ACRONYM);
+ TIDY_TAG_CONST(ADDRESS);
+ TIDY_TAG_CONST(ALIGN);
+ TIDY_TAG_CONST(APPLET);
+ TIDY_TAG_CONST(AREA);
+ TIDY_TAG_CONST(B);
+ TIDY_TAG_CONST(BASE);
+ TIDY_TAG_CONST(BASEFONT);
+ TIDY_TAG_CONST(BDO);
+ TIDY_TAG_CONST(BGSOUND);
+ TIDY_TAG_CONST(BIG);
+ TIDY_TAG_CONST(BLINK);
+ TIDY_TAG_CONST(BLOCKQUOTE);
+ TIDY_TAG_CONST(BODY);
+ TIDY_TAG_CONST(BR);
+ TIDY_TAG_CONST(BUTTON);
+ TIDY_TAG_CONST(CAPTION);
+ TIDY_TAG_CONST(CENTER);
+ TIDY_TAG_CONST(CITE);
+ TIDY_TAG_CONST(CODE);
+ TIDY_TAG_CONST(COL);
+ TIDY_TAG_CONST(COLGROUP);
+ TIDY_TAG_CONST(COMMENT);
+ TIDY_TAG_CONST(DD);
+ TIDY_TAG_CONST(DEL);
+ TIDY_TAG_CONST(DFN);
+ TIDY_TAG_CONST(DIR);
+ TIDY_TAG_CONST(DIV);
+ TIDY_TAG_CONST(DL);
+ TIDY_TAG_CONST(DT);
+ TIDY_TAG_CONST(EM);
+ TIDY_TAG_CONST(EMBED);
+ TIDY_TAG_CONST(FIELDSET);
+ TIDY_TAG_CONST(FONT);
+ TIDY_TAG_CONST(FORM);
+ TIDY_TAG_CONST(FRAME);
+ TIDY_TAG_CONST(FRAMESET);
+ TIDY_TAG_CONST(H1);
+ TIDY_TAG_CONST(H2);
+ TIDY_TAG_CONST(H3);
+ TIDY_TAG_CONST(H4);
+ TIDY_TAG_CONST(H5);
+ TIDY_TAG_CONST(H6);
+ TIDY_TAG_CONST(HEAD);
+ TIDY_TAG_CONST(HR);
+ TIDY_TAG_CONST(HTML);
+ TIDY_TAG_CONST(I);
+ TIDY_TAG_CONST(IFRAME);
+ TIDY_TAG_CONST(ILAYER);
+ TIDY_TAG_CONST(IMG);
+ TIDY_TAG_CONST(INPUT);
+ TIDY_TAG_CONST(INS);
+ TIDY_TAG_CONST(ISINDEX);
+ TIDY_TAG_CONST(KBD);
+ TIDY_TAG_CONST(KEYGEN);
+ TIDY_TAG_CONST(LABEL);
+ TIDY_TAG_CONST(LAYER);
+ TIDY_TAG_CONST(LEGEND);
+ TIDY_TAG_CONST(LI);
+ TIDY_TAG_CONST(LINK);
+ TIDY_TAG_CONST(LISTING);
+ TIDY_TAG_CONST(MAP);
+ TIDY_TAG_CONST(MARQUEE);
+ TIDY_TAG_CONST(MENU);
+ TIDY_TAG_CONST(META);
+ TIDY_TAG_CONST(MULTICOL);
+ TIDY_TAG_CONST(NOBR);
+ TIDY_TAG_CONST(NOEMBED);
+ TIDY_TAG_CONST(NOFRAMES);
+ TIDY_TAG_CONST(NOLAYER);
+ TIDY_TAG_CONST(NOSAVE);
+ TIDY_TAG_CONST(NOSCRIPT);
+ TIDY_TAG_CONST(OBJECT);
+ TIDY_TAG_CONST(OL);
+ TIDY_TAG_CONST(OPTGROUP);
+ TIDY_TAG_CONST(OPTION);
+ TIDY_TAG_CONST(P);
+ TIDY_TAG_CONST(PARAM);
+ TIDY_TAG_CONST(PLAINTEXT);
+ TIDY_TAG_CONST(PRE);
+ TIDY_TAG_CONST(Q);
+ TIDY_TAG_CONST(RB);
+ TIDY_TAG_CONST(RBC);
+ TIDY_TAG_CONST(RP);
+ TIDY_TAG_CONST(RT);
+ TIDY_TAG_CONST(RTC);
+ TIDY_TAG_CONST(RUBY);
+ TIDY_TAG_CONST(S);
+ TIDY_TAG_CONST(SAMP);
+ TIDY_TAG_CONST(SCRIPT);
+ TIDY_TAG_CONST(SELECT);
+ TIDY_TAG_CONST(SERVER);
+ TIDY_TAG_CONST(SERVLET);
+ TIDY_TAG_CONST(SMALL);
+ TIDY_TAG_CONST(SPACER);
+ TIDY_TAG_CONST(SPAN);
+ TIDY_TAG_CONST(STRIKE);
+ TIDY_TAG_CONST(STRONG);
+ TIDY_TAG_CONST(STYLE);
+ TIDY_TAG_CONST(SUB);
+ TIDY_TAG_CONST(SUP);
+ TIDY_TAG_CONST(TABLE);
+ TIDY_TAG_CONST(TBODY);
+ TIDY_TAG_CONST(TD);
+ TIDY_TAG_CONST(TEXTAREA);
+ TIDY_TAG_CONST(TFOOT);
+ TIDY_TAG_CONST(TH);
+ TIDY_TAG_CONST(THEAD);
+ TIDY_TAG_CONST(TITLE);
+ TIDY_TAG_CONST(TR);
+ TIDY_TAG_CONST(TT);
+ TIDY_TAG_CONST(U);
+ TIDY_TAG_CONST(UL);
+ TIDY_TAG_CONST(VAR);
+ TIDY_TAG_CONST(WBR);
+ TIDY_TAG_CONST(XMP);
+}
+
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/tidy/tidy.dsp b/ext/tidy/tidy.dsp
new file mode 100755
index 0000000..fe44fa7
--- /dev/null
+++ b/ext/tidy/tidy.dsp
@@ -0,0 +1,108 @@
+# Microsoft Developer Studio Project File - Name="tidy" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=tidy - Win32 Debug_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "tidy.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "tidy.mak" CFG="tidy - Win32 Debug_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "tidy - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "tidy - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "tidy - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release_TS"
+# PROP BASE Intermediate_Dir "Release_TS"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TIDY_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\libtidy" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_TIDY" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_TIDY_EXPORTS" /D "HAVE_ZLIB" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 php5ts.lib libtidy.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_tidy.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\release"
+
+!ELSEIF "$(CFG)" == "tidy - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug_TS"
+# PROP BASE Intermediate_Dir "Debug_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TIDY_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\libtidy" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_TIDY" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_TIDY_EXPORTS" /D "HAVE_ZLIB" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 php5ts_debug.lib libtidy.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_tidy.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\release"
+
+!ENDIF
+
+# Begin Target
+
+# Name "tidy - Win32 Release_TS"
+# Name "tidy - Win32 Debug_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\tidy.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_tidy.h
+# End Source File
+# End Group
+# End Target
+# End Project