summaryrefslogtreecommitdiff
path: root/ext/tidy
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
commitce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (patch)
treeacdb9a8816483652a9db1a47db71df5df43707c5 /ext/tidy
parent10f5b47dc7c1cf2b9a00991629f43652710322d3 (diff)
downloadphp-ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61.tar.gz
Imported Upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'ext/tidy')
-rw-r--r--ext/tidy/config.m410
-rw-r--r--ext/tidy/examples/cleanhtml5.php4
-rw-r--r--ext/tidy/examples/dumpit.php93
-rw-r--r--ext/tidy/examples/dumpit5.php4
-rw-r--r--ext/tidy/examples/urlgrab.php62
-rw-r--r--ext/tidy/examples/urlgrab5.php2
-rw-r--r--ext/tidy/php_tidy.def1
-rw-r--r--ext/tidy/php_tidy.h7
-rw-r--r--ext/tidy/tests/010.phpt96
-rw-r--r--ext/tidy/tests/012.phpt168
-rw-r--r--ext/tidy/tests/016.phpt2
-rw-r--r--ext/tidy/tests/018.phpt16
-rw-r--r--ext/tidy/tidy.c171
13 files changed, 396 insertions, 240 deletions
diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4
index 961b54ab8..c962fe6a4 100644
--- a/ext/tidy/config.m4
+++ b/ext/tidy/config.m4
@@ -1,9 +1,9 @@
dnl
-dnl $Id: config.m4,v 1.3 2003/12/18 19:59:58 sniper Exp $
+dnl $Id: config.m4,v 1.5 2005/05/29 23:16:45 sniper Exp $
dnl
PHP_ARG_WITH(tidy,for TIDY support,
-[ --with-tidy[=DIR] Include TIDY support])
+[ --with-tidy[=DIR] Include TIDY support])
if test "$PHP_TIDY" != "no"; then
@@ -32,6 +32,12 @@ if test "$PHP_TIDY" != "no"; then
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,[ ])
diff --git a/ext/tidy/examples/cleanhtml5.php b/ext/tidy/examples/cleanhtml5.php
index c31e36f1f..4dfd7643e 100644
--- a/ext/tidy/examples/cleanhtml5.php
+++ b/ext/tidy/examples/cleanhtml5.php
@@ -23,10 +23,10 @@
$tidy->cleanRepair();
- if(!empty($tidy->error_buf)) {
+ if(!empty($tidy->errorBuffer)) {
echo "\n\nThe following errors or warnings occured:\n";
- echo "{$tidy->error_buf}\n";
+ echo "{$tidy->errorBuffer}\n";
}
diff --git a/ext/tidy/examples/dumpit.php b/ext/tidy/examples/dumpit.php
deleted file mode 100644
index e77b7b932..000000000
--- a/ext/tidy/examples/dumpit.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
- /*
- * dumpit.php
- *
- * a command-line script which dumps the given HTML, PHP, ASP, XHTML, etc.
- * file as it is represented in the document model.
- *
- * By: John Coggeshall <john@php.net>
- *
- * Usage; php dumpit.php <filename>
- */
-
- 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_get_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($node, $indent = 0) {
- if($node) {
- /* 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);
- }
-
- /* Any attributes on this node? */
- if(count($node->attributes())) {
- do_leaf(" |\n", $indent);
- do_leaf(" +---- Attributes\n", $indent);
-
- /* Cycle through the attributes and display them and their values. */
- foreach($node->attributes() as $attrib) {
- do_leaf(" +--{$attrib->name}\n", $indent);
- do_leaf(" | +-- Value: {$attrib->value}\n", $indent);
- }
- }
-
- /* Recurse along the children to generate the remaining nodes */
- if($node->has_children()) {
- foreach($node->children() as $child) {
- dump_tree($child, $indent + 3);
- }
- }
- }
- }
-
- echo tidy_get_output();
-
-?> \ No newline at end of file
diff --git a/ext/tidy/examples/dumpit5.php b/ext/tidy/examples/dumpit5.php
index ad9157f6a..d7aee2d65 100644
--- a/ext/tidy/examples/dumpit5.php
+++ b/ext/tidy/examples/dumpit5.php
@@ -51,7 +51,7 @@
echo $string;
}
- function dump_tree(tidy_node $node, $indent = 0) {
+ function dump_tree(tidyNode $node, $indent = 0) {
/* Put something there if the node name is empty */
$nodename = trim(strtoupper($node->name));
@@ -80,7 +80,7 @@
}
/* Recurse along the children to generate the remaining nodes */
- if($node->has_children()) {
+ if($node->hasChildren()) {
foreach($node->child as $child) {
dump_tree($child, $indent + 3);
}
diff --git a/ext/tidy/examples/urlgrab.php b/ext/tidy/examples/urlgrab.php
deleted file mode 100644
index 9ec4c42ba..000000000
--- a/ext/tidy/examples/urlgrab.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
- /*
- * urlgrab.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 4.3.x, please see urlgrab5.php for tidy for PHP 5
- *
- * By: John Coggeshall <john@php.net>
- *
- * Usage: php urlgrab.php <file>
- *
- */
-
- /* Parse the document */
- tidy_parse_file($_SERVER['argv'][1]);
-
- /* Fix up the document */
- tidy_clean_repair();
-
- /* Get an object representing everything from the <HTML> tag in */
- $html = tidy_get_html();
-
- /* Traverse the document tree */
- print_r(get_links($html));
-
- function get_links($node) {
- $urls = array();
-
- /* Check to see if we are on an <A> tag or not */
- if($node->id == TIDY_TAG_A) {
- /* If we are, find the HREF attribute */
- $attrib = $node->get_attr(TIDY_ATTR_HREF);
- if($attrib) {
- /* Add the value of the HREF attrib to $urls */
- $urls[] = $attrib->value;
- }
-
- }
-
- /* Are there any children? */
- if($node->has_children()) {
-
- /* Traverse down each child recursively */
- foreach($node->children() as $child) {
-
- /* Append the results from recursion to $urls */
- foreach(get_links($child) as $url) {
-
- $urls[] = $url;
-
- }
-
- }
- }
-
- return $urls;
- }
-
-?> \ No newline at end of file
diff --git a/ext/tidy/examples/urlgrab5.php b/ext/tidy/examples/urlgrab5.php
index 8e08322a1..875baf0cf 100644
--- a/ext/tidy/examples/urlgrab5.php
+++ b/ext/tidy/examples/urlgrab5.php
@@ -12,7 +12,7 @@
* Usage: php urlgrab5.php <file>
*
*/
- function dump_nodes(tidy_node $node, &$urls = NULL) {
+ function dump_nodes(tidyNode $node, &$urls = NULL) {
$urls = (is_array($urls)) ? $urls : array();
diff --git a/ext/tidy/php_tidy.def b/ext/tidy/php_tidy.def
index 1c17276de..0caabc01f 100644
--- a/ext/tidy/php_tidy.def
+++ b/ext/tidy/php_tidy.def
@@ -45,6 +45,7 @@ tidyOptGetCategory
tidyOptGetDefault
tidyOptGetDefaultInt
tidyOptGetDefaultBool
+tidyOptGetDoc
tidyOptGetPickList
tidyOptGetNextPick
tidyOptGetValue
diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h
index 6e4c4dba8..3ec290f3a 100644
--- a/ext/tidy/php_tidy.h
+++ b/ext/tidy/php_tidy.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_tidy.h,v 1.22.2.1 2005/02/08 05:29:48 rasmus Exp $ */
+/* $Id: php_tidy.h,v 1.26 2005/08/03 14:08:19 sniper Exp $ */
#ifndef PHP_TIDY_H
#define PHP_TIDY_H
@@ -57,6 +57,9 @@ PHP_FUNCTION(tidy_reset_config);
PHP_FUNCTION(tidy_get_config);
PHP_FUNCTION(tidy_get_status);
PHP_FUNCTION(tidy_get_html_ver);
+#if HAVE_TIDYOPTGETDOC
+PHP_FUNCTION(tidy_get_opt_doc);
+#endif
PHP_FUNCTION(tidy_is_xhtml);
PHP_FUNCTION(tidy_is_xml);
PHP_FUNCTION(tidy_error_count);
diff --git a/ext/tidy/tests/010.phpt b/ext/tidy/tests/010.phpt
index 2bb66d49a..eabbc0391 100644
--- a/ext/tidy/tests/010.phpt
+++ b/ext/tidy/tests/010.phpt
@@ -12,7 +12,7 @@ Accessing root, body, html, and head nodes..
?>
--EXPECT--
-object(tidyNode)#2 (5) {
+object(tidyNode)#2 (8) {
["value"]=>
string(94) "<html>
<head>
@@ -25,12 +25,18 @@ object(tidyNode)#2 (5) {
string(0) ""
["type"]=>
int(0)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
["attribute"]=>
NULL
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#3 (6) {
+ &object(tidyNode)#3 (9) {
["value"]=>
string(94) "<html>
<head>
@@ -43,6 +49,12 @@ object(tidyNode)#2 (5) {
string(4) "html"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(48)
["attribute"]=>
@@ -50,7 +62,7 @@ object(tidyNode)#2 (5) {
["child"]=>
array(2) {
[0]=>
- &object(tidyNode)#4 (6) {
+ &object(tidyNode)#4 (9) {
["value"]=>
string(31) "<head>
<title></title>
@@ -60,6 +72,12 @@ object(tidyNode)#2 (5) {
string(4) "head"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(46)
["attribute"]=>
@@ -67,7 +85,7 @@ object(tidyNode)#2 (5) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#5 (6) {
+ &object(tidyNode)#5 (9) {
["value"]=>
string(16) "<title></title>
"
@@ -75,6 +93,12 @@ object(tidyNode)#2 (5) {
string(5) "title"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(111)
["attribute"]=>
@@ -85,7 +109,7 @@ object(tidyNode)#2 (5) {
}
}
[1]=>
- &object(tidyNode)#6 (6) {
+ &object(tidyNode)#6 (9) {
["value"]=>
string(49) "<body bgcolor="#FFFFFF" alink="#000000">
</body>
@@ -94,6 +118,12 @@ object(tidyNode)#2 (5) {
string(4) "body"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(16)
["attribute"]=>
@@ -110,7 +140,7 @@ object(tidyNode)#2 (5) {
}
}
}
-object(tidyNode)#2 (6) {
+object(tidyNode)#2 (9) {
["value"]=>
string(49) "<body bgcolor="#FFFFFF" alink="#000000">
</body>
@@ -119,6 +149,12 @@ object(tidyNode)#2 (6) {
string(4) "body"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(16)
["attribute"]=>
@@ -131,7 +167,7 @@ object(tidyNode)#2 (6) {
["child"]=>
NULL
}
-object(tidyNode)#2 (6) {
+object(tidyNode)#2 (9) {
["value"]=>
string(94) "<html>
<head>
@@ -144,6 +180,12 @@ object(tidyNode)#2 (6) {
string(4) "html"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(1)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(48)
["attribute"]=>
@@ -151,7 +193,7 @@ object(tidyNode)#2 (6) {
["child"]=>
array(2) {
[0]=>
- &object(tidyNode)#3 (6) {
+ &object(tidyNode)#3 (9) {
["value"]=>
string(31) "<head>
<title></title>
@@ -161,6 +203,12 @@ object(tidyNode)#2 (6) {
string(4) "head"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(46)
["attribute"]=>
@@ -168,7 +216,7 @@ object(tidyNode)#2 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#6 (6) {
+ &object(tidyNode)#6 (9) {
["value"]=>
string(16) "<title></title>
"
@@ -176,6 +224,12 @@ object(tidyNode)#2 (6) {
string(5) "title"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(111)
["attribute"]=>
@@ -186,7 +240,7 @@ object(tidyNode)#2 (6) {
}
}
[1]=>
- &object(tidyNode)#4 (6) {
+ &object(tidyNode)#4 (9) {
["value"]=>
string(49) "<body bgcolor="#FFFFFF" alink="#000000">
</body>
@@ -195,6 +249,12 @@ object(tidyNode)#2 (6) {
string(4) "body"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(16)
["attribute"]=>
@@ -209,7 +269,7 @@ object(tidyNode)#2 (6) {
}
}
}
-object(tidyNode)#2 (6) {
+object(tidyNode)#2 (9) {
["value"]=>
string(31) "<head>
<title></title>
@@ -219,6 +279,12 @@ object(tidyNode)#2 (6) {
string(4) "head"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(46)
["attribute"]=>
@@ -226,7 +292,7 @@ object(tidyNode)#2 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#4 (6) {
+ &object(tidyNode)#4 (9) {
["value"]=>
string(16) "<title></title>
"
@@ -234,6 +300,12 @@ object(tidyNode)#2 (6) {
string(5) "title"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(57)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(111)
["attribute"]=>
diff --git a/ext/tidy/tests/012.phpt b/ext/tidy/tests/012.phpt
index 5cec346b1..43fff38df 100644
--- a/ext/tidy/tests/012.phpt
+++ b/ext/tidy/tests/012.phpt
@@ -32,7 +32,7 @@ Accessing children nodes
?>
--EXPECT--
bool(true)
-object(tidyNode)#3 (6) {
+object(tidyNode)#3 (9) {
["value"]=>
string(31) "<head>
<title></title>
@@ -42,6 +42,12 @@ object(tidyNode)#3 (6) {
string(4) "head"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(46)
["attribute"]=>
@@ -49,7 +55,7 @@ object(tidyNode)#3 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#4 (6) {
+ &object(tidyNode)#4 (9) {
["value"]=>
string(16) "<title></title>
"
@@ -57,6 +63,12 @@ object(tidyNode)#3 (6) {
string(5) "title"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(87)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(111)
["attribute"]=>
@@ -67,7 +79,7 @@ object(tidyNode)#3 (6) {
}
}
bool(true)
-object(tidyNode)#4 (6) {
+object(tidyNode)#4 (9) {
["value"]=>
string(16) "<title></title>
"
@@ -75,6 +87,12 @@ object(tidyNode)#4 (6) {
string(5) "title"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(87)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(111)
["attribute"]=>
@@ -82,7 +100,7 @@ object(tidyNode)#4 (6) {
["child"]=>
NULL
}
-object(tidyNode)#5 (6) {
+object(tidyNode)#5 (9) {
["value"]=>
string(80) "<body bgcolor="#FFFFFF" alink="#000000">
<b>Hi</b><i>Bye<u>Test</u></i>
@@ -92,6 +110,12 @@ object(tidyNode)#5 (6) {
string(4) "body"
["type"]=>
int(5)
+ ["line"]=>
+ int(1)
+ ["column"]=>
+ int(7)
+ ["proprietary"]=>
+ bool(false)
["id"]=>
int(16)
["attribute"]=>
@@ -104,13 +128,19 @@ object(tidyNode)#5 (6) {
["child"]=>
array(2) {
[0]=>
- &object(tidyNode)#6 (6) {
+ &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"]=>
@@ -118,13 +148,19 @@ object(tidyNode)#5 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#7 (5) {
+ &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"]=>
@@ -133,13 +169,19 @@ object(tidyNode)#5 (6) {
}
}
[1]=>
- &object(tidyNode)#8 (6) {
+ &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"]=>
@@ -147,26 +189,38 @@ object(tidyNode)#5 (6) {
["child"]=>
array(2) {
[0]=>
- &object(tidyNode)#9 (5) {
+ &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 (6) {
+ &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"]=>
@@ -174,13 +228,19 @@ object(tidyNode)#5 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#11 (5) {
+ &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"]=>
@@ -193,13 +253,19 @@ object(tidyNode)#5 (6) {
}
}
bool(true)
-object(tidyNode)#6 (6) {
+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"]=>
@@ -207,13 +273,19 @@ object(tidyNode)#6 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#7 (5) {
+ &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"]=>
@@ -222,25 +294,37 @@ object(tidyNode)#6 (6) {
}
}
bool(true)
-object(tidyNode)#7 (5) {
+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 (6) {
+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"]=>
@@ -248,26 +332,38 @@ object(tidyNode)#8 (6) {
["child"]=>
array(2) {
[0]=>
- &object(tidyNode)#9 (5) {
+ &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 (6) {
+ &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"]=>
@@ -275,13 +371,19 @@ object(tidyNode)#8 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#11 (5) {
+ &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"]=>
@@ -292,25 +394,37 @@ object(tidyNode)#8 (6) {
}
}
bool(true)
-object(tidyNode)#9 (5) {
+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 (6) {
+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"]=>
@@ -318,13 +432,19 @@ object(tidyNode)#10 (6) {
["child"]=>
array(1) {
[0]=>
- &object(tidyNode)#11 (5) {
+ &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"]=>
@@ -333,13 +453,19 @@ object(tidyNode)#10 (6) {
}
}
bool(true)
-object(tidyNode)#11 (5) {
+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"]=>
diff --git a/ext/tidy/tests/016.phpt b/ext/tidy/tests/016.phpt
index c2fddce6f..001371aa3 100644
--- a/ext/tidy/tests/016.phpt
+++ b/ext/tidy/tests/016.phpt
@@ -1,5 +1,5 @@
--TEST--
-Passing configuration file through tidy_parse_file()
+Passing configuration file through tidy_parse_file() (may fail with buggy libtidy)
--SKIPIF--
<?php if (!extension_loaded("tidy")) print "skip"; ?>
--FILE--
diff --git a/ext/tidy/tests/018.phpt b/ext/tidy/tests/018.phpt
new file mode 100644
index 000000000..405a46d42
--- /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/tidy.c b/ext/tidy/tidy.c
index 62c3a8ea8..d7f761937 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tidy.c,v 1.56.2.5 2005/02/08 05:29:48 rasmus Exp $ */
+/* $Id: tidy.c,v 1.66.2.3 2005/11/14 22:03:02 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -127,6 +127,18 @@
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; \
@@ -143,6 +155,14 @@
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_SAFE_MODE_CHECK(filename) \
if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) { \
RETURN_FALSE; \
@@ -190,7 +210,7 @@ struct _PHPTidyObj {
/* {{{ ext/tidy prototypes
*/
-static char *php_tidy_file_to_mem(char *, zend_bool TSRMLS_DC);
+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);
@@ -237,6 +257,9 @@ function_entry tidy_functions[] = {
PHP_FE(tidy_warning_count, NULL)
PHP_FE(tidy_access_count, NULL)
PHP_FE(tidy_config_count, NULL)
+#if HAVE_TIDYOPTGETDOC
+ PHP_FE(tidy_get_opt_doc, NULL)
+#endif
PHP_FE(tidy_get_root, NULL)
PHP_FE(tidy_get_head, NULL)
PHP_FE(tidy_get_html, NULL)
@@ -257,6 +280,9 @@ function_entry tidy_funcs_doc[] = {
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)
@@ -391,7 +417,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS
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;
+ int arg1_len, enc_len = 0, data_len = 0;
zend_bool use_include_path = 0;
TidyDoc doc;
TidyBuffer *errbuf;
@@ -404,11 +430,12 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
}
if (is_file) {
- if (!(data = php_tidy_file_to_mem(arg1, use_include_path TSRMLS_CC))) {
+ if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) {
RETURN_FALSE;
}
} else {
data = arg1;
+ data_len = arg1_len;
}
doc = tidyCreate();
@@ -450,7 +477,12 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
}
if (data) {
- if (tidyParseString(doc, data) < 0) {
+ TidyBuffer buf = {0};
+
+ tidyBufInit(&buf);
+ tidyBufAppend(&buf, data, data_len);
+
+ if (tidyParseBuffer(doc, &buf) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf->bp);
RETVAL_FALSE;
} else {
@@ -458,12 +490,14 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
TidyBuffer output = {0};
tidySaveBuffer (doc, &output);
- RETVAL_STRING(output.bp, 1);
+ RETVAL_STRINGL(output.bp, output.size-1, 1);
tidyBufFree(&output);
} else {
RETVAL_FALSE;
}
}
+
+ tidyBufFree(&buf);
}
if (is_file) {
@@ -475,17 +509,17 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
tidyRelease(doc);
}
-static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path TSRMLS_DC)
+static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path, int *len TSRMLS_DC)
{
php_stream *stream;
- int len;
char *data = NULL;
if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE, NULL))) {
return NULL;
}
- if ((len = php_stream_copy_to_mem(stream, &data, PHP_STREAM_COPY_ALL, 0)) == 0) {
+ if ((*len = (int) php_stream_copy_to_mem(stream, &data, PHP_STREAM_COPY_ALL, 0)) == 0) {
data = estrdup("");
+ *len = 0;
}
php_stream_close(stream);
@@ -564,7 +598,7 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *
break;
}
- retval->handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) tidy_object_free_storage, NULL TSRMLS_CC);
+ 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;
}
@@ -633,7 +667,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type, int free TSRMLS_
case IS_STRING:
obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
tidySaveBuffer (obj->ptdoc->doc, &output);
- ZVAL_STRINGL(out, output.bp, output.size, TRUE);
+ ZVAL_STRINGL(out, output.bp, output.size-1, TRUE);
tidyBufFree(&output);
break;
@@ -665,7 +699,7 @@ static int tidy_node_cast_handler(zval *in, zval *out, int type, int free TSRMLS
case IS_STRING:
obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
- ZVAL_STRINGL(out, buf.bp, buf.size, TRUE);
+ ZVAL_STRINGL(out, buf.bp, buf.size-1, TRUE);
tidyBufFree(&buf);
break;
@@ -686,7 +720,7 @@ static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC)
if (output.size) {
MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, output.bp, output.size, TRUE);
+ ZVAL_STRINGL(temp, output.bp, output.size-1, TRUE);
zend_hash_update(obj->std.properties, "value", sizeof("value"), (void *)&temp, sizeof(zval *), NULL);
}
@@ -694,7 +728,7 @@ static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC)
if (obj->ptdoc->errbuf->size) {
MAKE_STD_ZVAL(temp);
- ZVAL_STRINGL(temp, obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size, TRUE);
+ ZVAL_STRINGL(temp, obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, TRUE);
zend_hash_update(obj->std.properties, "errorBuffer", sizeof("errorBuffer"), (void *)&temp, sizeof(zval *), NULL);
}
}
@@ -714,12 +748,14 @@ static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRM
memset(&buf, 0, sizeof(buf));
tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
- buf.bp[buf.size-1] = '\0';
- ADD_PROPERTY_STRING(obj->std.properties, value, buf.bp);
+ ADD_PROPERTY_STRINGL(obj->std.properties, value, buf.bp, buf.size-1);
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:
@@ -874,8 +910,10 @@ static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRML
return SUCCESS;
}
-static int php_tidy_parse_string(PHPTidyObj *obj, char *string, char *enc TSRMLS_DC)
-{
+static int php_tidy_parse_string(PHPTidyObj *obj, char *string, int len, char *enc TSRMLS_DC)
+{
+ TidyBuffer buf = {0};
+
if(enc) {
if (tidySetCharEncoding(obj->ptdoc->doc, enc) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
@@ -883,18 +921,18 @@ static int php_tidy_parse_string(PHPTidyObj *obj, char *string, char *enc TSRMLS
}
}
- if (tidyParseString(obj->ptdoc->doc, string) < 0) {
+ tidyBufInit(&buf);
+ tidyBufAppend(&buf, string, len);
+ if (tidyParseBuffer(obj->ptdoc->doc, &buf) < 0) {
+ tidyBufFree(&buf);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", obj->ptdoc->errbuf->bp);
return FAILURE;
- } else {
- tidy_doc_update_properties(obj TSRMLS_CC);
-
- return SUCCESS;
}
-
+ tidyBufFree(&buf);
tidy_doc_update_properties(obj TSRMLS_CC);
-
+
+ return SUCCESS;
}
static void tidy_globals_ctor(void *global TSRMLS_DC)
@@ -945,7 +983,7 @@ 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: tidy.c,v 1.56.2.5 2005/02/08 05:29:48 rasmus Exp $)");
+ php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c,v 1.66.2.3 2005/11/14 22:03:02 tony2001 Exp $)");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
@@ -979,7 +1017,12 @@ PHP_FUNCTION(ob_tidyhandler)
TIDY_SET_DEFAULT_CONFIG(doc);
if (input_len > 1) {
- if (tidyParseString(doc, input) < 0 || tidyCleanAndRepair(doc) < 0) {
+ TidyBuffer buf = {0};
+
+ tidyBufInit(&buf);
+ tidyBufAppend(&buf, input, input_len);
+
+ if (tidyParseBuffer(doc, &buf) < 0 || tidyCleanAndRepair(doc) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf.bp);
RETVAL_NULL();
} else {
@@ -987,10 +1030,12 @@ PHP_FUNCTION(ob_tidyhandler)
tidyBufInit(&output);
tidySaveBuffer(doc, &output);
- RETVAL_STRING(output.bp, 1);
+ RETVAL_STRINGL(output.bp, output.size-1, 1);
tidyBufFree(&output);
}
+
+ tidyBufFree(&buf);
} else {
RETVAL_NULL();
}
@@ -1020,7 +1065,7 @@ PHP_FUNCTION(tidy_parse_string)
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
- if(php_tidy_parse_string(obj, input, enc TSRMLS_CC) == FAILURE) {
+ if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
INIT_ZVAL(*return_value);
RETURN_FALSE;
@@ -1036,7 +1081,7 @@ PHP_FUNCTION(tidy_get_error_buffer)
TIDY_FETCH_OBJECT;
if (obj->ptdoc->errbuf && obj->ptdoc->errbuf->bp) {
- RETURN_STRING(obj->ptdoc->errbuf->bp, 1);
+ RETURN_STRINGL(obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, 1);
} else {
RETURN_FALSE;
}
@@ -1052,7 +1097,7 @@ PHP_FUNCTION(tidy_get_output)
tidySaveBuffer(obj->ptdoc->doc, &output);
- RETVAL_STRING(output.bp, 1);
+ RETVAL_STRINGL(output.bp, output.size-1, 1);
tidyBufFree(&output);
}
@@ -1063,7 +1108,7 @@ PHP_FUNCTION(tidy_get_output)
PHP_FUNCTION(tidy_parse_file)
{
char *inputfile, *enc = NULL;
- int input_len, enc_len = 0;
+ int input_len, contents_len, enc_len = 0;
zend_bool use_include_path = 0;
char *contents;
zval *options = NULL;
@@ -1079,14 +1124,14 @@ PHP_FUNCTION(tidy_parse_file)
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 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, enc TSRMLS_CC) == FAILURE) {
+ if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
INIT_ZVAL(*return_value);
RETVAL_FALSE;
@@ -1158,6 +1203,48 @@ PHP_FUNCTION(tidy_get_release)
}
/* }}} */
+
+#if HAVE_TIDYOPTGETDOC
+/* {{{ proto string tidy_get_opt_doc(tidy resource, string optname)
+ Returns the documentation for the given option name */
+PHP_FUNCTION(tidy_get_opt_doc)
+{
+ PHPTidyObj *obj;
+ char *optname, *optval;
+ 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 configuarion */
PHP_FUNCTION(tidy_get_config)
@@ -1339,7 +1426,7 @@ PHP_FUNCTION(tidy_getopt)
TIDY_DOC_METHOD(__construct)
{
char *inputfile = NULL, *enc = NULL;
- int input_len = 0, enc_len = 0;
+ int input_len = 0, enc_len = 0, contents_len = 0;
zend_bool use_include_path = 0;
char *contents;
zval *options = NULL;
@@ -1355,14 +1442,14 @@ TIDY_DOC_METHOD(__construct)
obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
if (inputfile) {
- if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path 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;
}
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
- php_tidy_parse_string(obj, contents, enc TSRMLS_CC);
+ php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC);
efree(contents);
}
@@ -1371,7 +1458,7 @@ TIDY_DOC_METHOD(__construct)
TIDY_DOC_METHOD(parseFile)
{
char *inputfile, *enc = NULL;
- int input_len, enc_len = 0;
+ int input_len, enc_len = 0, contents_len = 0;
zend_bool use_include_path = 0;
char *contents;
zval *options = NULL;
@@ -1386,14 +1473,14 @@ TIDY_DOC_METHOD(parseFile)
RETURN_FALSE;
}
- if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path 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, enc TSRMLS_CC) == FAILURE) {
+ if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
RETVAL_FALSE;
} else {
RETVAL_TRUE;
@@ -1419,7 +1506,7 @@ TIDY_DOC_METHOD(parseString)
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
- if(php_tidy_parse_string(obj, input, enc TSRMLS_CC) == SUCCESS) {
+ if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
}