2003-08-01 08:22:43 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2003-12-14 14:02:33 +08:00
|
|
|
| PHP Version 5 |
|
2003-08-01 08:22:43 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2010-01-03 17:23:27 +08:00
|
|
|
| Copyright (c) 1997-2010 The PHP Group |
|
2003-08-01 08:22:43 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2003-08-01 08:22:43 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2003-08-01 08:22:43 +08:00
|
|
|
| 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"
|
2003-09-22 08:12:54 +08:00
|
|
|
#include "php_tidy.h"
|
2003-12-19 03:59:58 +08:00
|
|
|
|
|
|
|
#if HAVE_TIDY
|
|
|
|
|
2003-08-01 08:22:43 +08:00
|
|
|
#include "php_ini.h"
|
|
|
|
#include "ext/standard/info.h"
|
2004-01-07 06:23:36 +08:00
|
|
|
#include "safe_mode.h"
|
2004-02-23 08:59:29 +08:00
|
|
|
|
2004-02-26 21:22:11 +08:00
|
|
|
#include "tidy.h"
|
|
|
|
#include "buffio.h"
|
2004-02-23 08:59:29 +08:00
|
|
|
|
2006-04-20 05:47:20 +08:00
|
|
|
/* compatibility with older versions of libtidy */
|
|
|
|
#ifndef TIDY_CALL
|
|
|
|
#define TIDY_CALL
|
|
|
|
#endif
|
|
|
|
|
2004-07-14 10:41:53 +08:00
|
|
|
#define PHP_TIDY_MODULE_VERSION "2.0"
|
2004-02-23 08:59:29 +08:00
|
|
|
|
|
|
|
/* {{{ ext/tidy macros
|
|
|
|
*/
|
2010-03-11 18:24:29 +08:00
|
|
|
#define FIX_BUFFER(bptr) do { if ((bptr)->size) { (bptr)->bp[(bptr)->size-1] = '\0'; } } while(0)
|
|
|
|
|
2004-04-12 11:14:19 +08:00
|
|
|
#define TIDY_SET_CONTEXT \
|
2010-03-11 18:24:29 +08:00
|
|
|
zval *object = getThis();
|
2006-09-15 22:33:34 +08:00
|
|
|
|
2004-02-23 08:59:29 +08:00
|
|
|
#define TIDY_FETCH_OBJECT \
|
|
|
|
PHPTidyObj *obj; \
|
2004-04-15 03:01:45 +08:00
|
|
|
TIDY_SET_CONTEXT; \
|
2004-02-23 08:59:29 +08:00
|
|
|
if (object) { \
|
2008-03-11 06:15:36 +08:00
|
|
|
if (zend_parse_parameters_none() == FAILURE) { \
|
|
|
|
return; \
|
2004-02-23 08:59:29 +08:00
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "O", &object, tidy_ce_doc) == FAILURE) { \
|
|
|
|
RETURN_FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
2010-03-11 18:24:29 +08:00
|
|
|
obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
|
2004-02-23 08:59:29 +08:00
|
|
|
|
|
|
|
#define TIDY_FETCH_ONLY_OBJECT \
|
|
|
|
PHPTidyObj *obj; \
|
2004-04-15 03:01:45 +08:00
|
|
|
TIDY_SET_CONTEXT; \
|
2008-03-11 06:15:36 +08:00
|
|
|
if (zend_parse_parameters_none() == FAILURE) { \
|
|
|
|
return; \
|
2004-02-23 08:59:29 +08:00
|
|
|
} \
|
2010-03-11 18:24:29 +08:00
|
|
|
obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
|
2004-02-23 08:59:29 +08:00
|
|
|
|
|
|
|
#define TIDY_APPLY_CONFIG_ZVAL(_doc, _val) \
|
2010-03-11 18:24:29 +08:00
|
|
|
if (_val) { \
|
|
|
|
if (Z_TYPE_PP(_val) == IS_ARRAY) { \
|
|
|
|
_php_tidy_apply_config_array(_doc, HASH_OF(*_val) TSRMLS_CC); \
|
|
|
|
} else if (Z_TYPE_PP(_val) != IS_NULL) { \
|
|
|
|
convert_to_string_ex(_val); \
|
|
|
|
TIDY_SAFE_MODE_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; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
2004-02-23 08:59:29 +08:00
|
|
|
|
2004-05-29 04:32:52 +08:00
|
|
|
#define REGISTER_TIDY_CLASS(classname, name, parent, __flags) \
|
2004-02-23 08:59:29 +08:00
|
|
|
{ \
|
|
|
|
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); \
|
2004-05-29 04:32:52 +08:00
|
|
|
tidy_ce_ ## name->ce_flags |= __flags; \
|
2004-02-23 08:59:29 +08:00
|
|
|
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); \
|
|
|
|
}
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
#define ADD_PROPERTY_STRINGL(_table, _key, _string, _len) \
|
2010-03-11 18:24:29 +08:00
|
|
|
{ \
|
|
|
|
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); \
|
|
|
|
}
|
2005-10-26 02:04:59 +08:00
|
|
|
|
2004-02-23 08:59:29 +08:00
|
|
|
#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); \
|
|
|
|
}
|
|
|
|
|
2005-03-21 11:54:29 +08:00
|
|
|
#define ADD_PROPERTY_BOOL(_table, _key, _bool) \
|
2010-03-11 18:24:29 +08:00
|
|
|
{ \
|
|
|
|
zval *tmp; \
|
|
|
|
MAKE_STD_ZVAL(tmp); \
|
|
|
|
ZVAL_BOOL(tmp, _bool); \
|
|
|
|
zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
|
|
|
|
}
|
2005-03-21 11:54:29 +08:00
|
|
|
|
2004-02-23 08:59:29 +08:00
|
|
|
#define TIDY_SAFE_MODE_CHECK(filename) \
|
2010-03-11 18:24:29 +08:00
|
|
|
if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) { \
|
|
|
|
RETURN_FALSE; \
|
|
|
|
}
|
2004-02-23 08:59:29 +08:00
|
|
|
|
|
|
|
#define TIDY_SET_DEFAULT_CONFIG(_doc) \
|
|
|
|
if (TG(default_config) && TG(default_config)[0]) { \
|
|
|
|
if (tidyLoadConfig(_doc, TG(default_config)) < 0) { \
|
2010-03-11 18:24:29 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load Tidy configuration file at '%s'", TG(default_config)); \
|
2004-02-23 08:59:29 +08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ ext/tidy structs
|
2004-02-23 08:59:29 +08:00
|
|
|
*/
|
|
|
|
typedef struct _PHPTidyDoc PHPTidyDoc;
|
|
|
|
typedef struct _PHPTidyObj PHPTidyObj;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
is_node,
|
2006-09-15 22:33:34 +08:00
|
|
|
is_doc
|
2004-02-23 08:59:29 +08:00
|
|
|
} tidy_obj_type;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
is_root_node,
|
|
|
|
is_html_node,
|
|
|
|
is_head_node,
|
|
|
|
is_body_node
|
|
|
|
} tidy_base_nodetypes;
|
|
|
|
|
|
|
|
struct _PHPTidyDoc {
|
2010-03-11 18:24:29 +08:00
|
|
|
TidyDoc doc;
|
|
|
|
TidyBuffer *errbuf;
|
|
|
|
unsigned int ref_count;
|
2004-02-23 08:59:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _PHPTidyObj {
|
2010-03-11 18:24:29 +08:00
|
|
|
zend_object std;
|
|
|
|
TidyNode node;
|
|
|
|
tidy_obj_type type;
|
|
|
|
PHPTidyDoc *ptdoc;
|
2004-02-23 08:59:29 +08:00
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ ext/tidy prototypes
|
|
|
|
*/
|
2005-10-26 02:04:59 +08:00
|
|
|
static char *php_tidy_file_to_mem(char *, zend_bool, int * TSRMLS_DC);
|
2004-02-23 08:59:29 +08:00
|
|
|
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);
|
2006-05-10 08:00:13 +08:00
|
|
|
static int tidy_doc_cast_handler(zval *, zval *, int TSRMLS_DC);
|
|
|
|
static int tidy_node_cast_handler(zval *, zval *, int TSRMLS_DC);
|
2004-02-23 08:59:29 +08:00
|
|
|
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);
|
2010-03-11 18:24:29 +08:00
|
|
|
static PHP_INI_MH(php_tidy_set_clean_output);
|
|
|
|
static void php_tidy_clean_output_start(zval *name TSRMLS_DC);
|
|
|
|
static php_output_handler *php_tidy_output_handler_init(zval *handler_name, size_t chunk_size, int flags TSRMLS_DC);
|
|
|
|
static int php_tidy_output_handler(void **nothing, php_output_context *output_context);
|
2006-08-15 04:08:18 +08:00
|
|
|
|
|
|
|
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);
|
2007-02-12 00:07:30 +08:00
|
|
|
static TIDY_NODE_METHOD(getParent);
|
2009-12-26 05:24:36 +08:00
|
|
|
static TIDY_NODE_METHOD(__construct);
|
2004-02-23 08:59:29 +08:00
|
|
|
/* }}} */
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
ZEND_DECLARE_MODULE_GLOBALS(tidy)
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
PHP_INI_BEGIN()
|
2010-03-11 18:24:29 +08:00
|
|
|
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)
|
2003-12-14 14:02:33 +08:00
|
|
|
PHP_INI_END()
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2008-07-03 09:55:48 +08:00
|
|
|
/* {{{ 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()
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
ZEND_BEGIN_ARG_INFO(arginfo_tidy_get_error_buffer, 0)
|
2008-07-03 09:55:48 +08:00
|
|
|
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()
|
|
|
|
/* }}} */
|
|
|
|
|
2007-09-28 02:00:48 +08:00
|
|
|
static const zend_function_entry tidy_functions[] = {
|
2008-07-03 09:55:48 +08:00
|
|
|
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)
|
2010-03-11 18:24:29 +08:00
|
|
|
PHP_FE(tidy_get_error_buffer, arginfo_tidy_get_error_buffer)
|
2008-07-03 09:55:48 +08:00
|
|
|
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)
|
2010-03-11 18:24:29 +08:00
|
|
|
PHP_FE(tidy_diagnose, arginfo_tidy_diagnose)
|
2008-07-03 09:55:48 +08:00
|
|
|
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)
|
2010-03-11 18:24:29 +08:00
|
|
|
PHP_FE(tidy_is_xml, arginfo_tidy_is_xml)
|
2008-07-03 09:55:48 +08:00
|
|
|
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)
|
2010-03-11 18:24:29 +08:00
|
|
|
PHP_FE(tidy_config_count, arginfo_tidy_config_count)
|
2005-04-26 04:46:16 +08:00
|
|
|
#if HAVE_TIDYOPTGETDOC
|
2008-07-03 09:55:48 +08:00
|
|
|
PHP_FE(tidy_get_opt_doc, arginfo_tidy_get_opt_doc)
|
2005-04-26 04:46:16 +08:00
|
|
|
#endif
|
2008-07-03 09:55:48 +08:00
|
|
|
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)
|
2003-08-01 08:22:43 +08:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2007-09-28 02:00:48 +08:00
|
|
|
static const zend_function_entry tidy_funcs_doc[] = {
|
2004-01-21 18:19:56 +08:00
|
|
|
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)
|
2003-12-14 14:02:33 +08:00
|
|
|
TIDY_METHOD_MAP(diagnose, tidy_diagnose, NULL)
|
2004-01-21 18:19:56 +08:00
|
|
|
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)
|
2005-04-26 04:46:16 +08:00
|
|
|
#if HAVE_TIDYOPTGETDOC
|
|
|
|
TIDY_METHOD_MAP(getOptDoc, tidy_get_opt_doc, NULL)
|
|
|
|
#endif
|
2004-01-21 18:19:56 +08:00
|
|
|
TIDY_METHOD_MAP(isXhtml, tidy_is_xhtml, NULL)
|
|
|
|
TIDY_METHOD_MAP(isXml, tidy_is_xml, NULL)
|
2003-12-14 14:02:33 +08:00
|
|
|
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)
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_DOC_ME(__construct, NULL)
|
2003-12-14 14:02:33 +08:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
2003-09-22 08:12:54 +08:00
|
|
|
|
2007-09-28 02:00:48 +08:00
|
|
|
static const zend_function_entry tidy_funcs_node[] = {
|
2004-01-21 18:19:56 +08:00
|
|
|
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)
|
2007-02-12 00:07:30 +08:00
|
|
|
TIDY_NODE_ME(getParent, NULL)
|
2009-12-29 01:01:24 +08:00
|
|
|
TIDY_NODE_PRIVATE_ME(__construct, NULL)
|
2003-09-22 08:12:54 +08:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2006-09-05 23:23:26 +08:00
|
|
|
static zend_class_entry *tidy_ce_doc, *tidy_ce_node;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
|
|
|
static zend_object_handlers tidy_object_handlers_doc;
|
|
|
|
static zend_object_handlers tidy_object_handlers_node;
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2008-01-27 23:04:41 +08:00
|
|
|
zend_module_entry tidy_module_entry = {
|
2003-08-01 08:22:43 +08:00
|
|
|
STANDARD_MODULE_HEADER,
|
2003-08-06 08:01:22 +08:00
|
|
|
"tidy",
|
2003-08-01 08:22:43 +08:00
|
|
|
tidy_functions,
|
|
|
|
PHP_MINIT(tidy),
|
2006-05-25 05:22:13 +08:00
|
|
|
PHP_MSHUTDOWN(tidy),
|
2003-12-15 09:43:45 +08:00
|
|
|
PHP_RINIT(tidy),
|
2005-02-08 07:04:00 +08:00
|
|
|
NULL,
|
2003-08-01 08:22:43 +08:00
|
|
|
PHP_MINFO(tidy),
|
2003-12-14 14:02:33 +08:00
|
|
|
PHP_TIDY_MODULE_VERSION,
|
2006-06-16 02:33:09 +08:00
|
|
|
PHP_MODULE_GLOBALS(tidy),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
STANDARD_MODULE_PROPERTIES_EX
|
2003-08-01 08:22:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef COMPILE_DL_TIDY
|
|
|
|
ZEND_GET_MODULE(tidy)
|
|
|
|
#endif
|
|
|
|
|
2006-07-08 08:13:17 +08:00
|
|
|
static void* TIDY_CALL php_tidy_malloc(size_t len)
|
2003-09-21 03:45:32 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
return emalloc(len);
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:13:17 +08:00
|
|
|
static void* TIDY_CALL php_tidy_realloc(void *buf, size_t len)
|
2003-09-21 03:45:32 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
return erealloc(buf, len);
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:13:17 +08:00
|
|
|
static void TIDY_CALL php_tidy_free(void *buf)
|
2003-09-21 03:45:32 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
efree(buf);
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-12-18 00:34:10 +08:00
|
|
|
|
2006-07-08 08:13:17 +08:00
|
|
|
static void TIDY_CALL php_tidy_panic(ctmbstr msg)
|
2003-09-22 03:22:19 +08:00
|
|
|
{
|
2004-11-26 07:44:20 +08:00
|
|
|
TSRMLS_FETCH();
|
2004-04-16 23:46:41 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
|
2004-01-08 08:03:54 +08:00
|
|
|
static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS_DC)
|
2004-01-07 02:24:17 +08:00
|
|
|
{
|
2004-06-08 22:55:14 +08:00
|
|
|
TidyOption opt = tidyGetOptionByName(doc, optname);
|
|
|
|
zval conv = *value;
|
2004-01-07 02:24:17 +08:00
|
|
|
|
|
|
|
if (!opt) {
|
2004-11-26 07:44:20 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname);
|
2004-01-07 02:24:17 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-07 02:24:17 +08:00
|
|
|
if (tidyOptIsReadOnly(opt)) {
|
2004-06-08 22:55:14 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Attempting to set read-only option '%s'", optname);
|
2004-01-07 02:24:17 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(tidyOptGetType(opt)) {
|
|
|
|
case TidyString:
|
2004-06-08 22:55:14 +08:00
|
|
|
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);
|
|
|
|
}
|
2004-01-07 02:24:17 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2004-06-08 22:55:14 +08:00
|
|
|
if (Z_TYPE(conv) != Z_TYPE_P(value)) {
|
|
|
|
zval_dtor(&conv);
|
|
|
|
}
|
2004-01-07 02:24:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TidyInteger:
|
2004-06-08 22:55:14 +08:00
|
|
|
if (Z_TYPE(conv) != IS_LONG) {
|
|
|
|
zval_copy_ctor(&conv);
|
|
|
|
convert_to_long(&conv);
|
|
|
|
}
|
|
|
|
if (tidyOptSetInt(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
|
2004-01-07 02:24:17 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TidyBoolean:
|
2004-06-08 22:55:14 +08:00
|
|
|
if (Z_TYPE(conv) != IS_LONG) {
|
|
|
|
zval_copy_ctor(&conv);
|
|
|
|
convert_to_long(&conv);
|
|
|
|
}
|
2004-11-26 07:44:20 +08:00
|
|
|
if (tidyOptSetBool(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
|
2004-01-07 02:24:17 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of configuration option");
|
2004-01-07 02:24:17 +08:00
|
|
|
break;
|
2010-03-11 18:24:29 +08:00
|
|
|
}
|
2004-06-08 22:55:14 +08:00
|
|
|
|
2004-01-07 02:24:17 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2003-09-25 17:32:55 +08:00
|
|
|
static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file)
|
2003-09-22 03:22:19 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
char *data=NULL, *arg1, *enc = NULL;
|
2005-10-26 02:04:59 +08:00
|
|
|
int arg1_len, enc_len = 0, data_len = 0;
|
2003-09-22 03:22:19 +08:00
|
|
|
zend_bool use_include_path = 0;
|
2004-01-08 17:21:05 +08:00
|
|
|
TidyDoc doc;
|
|
|
|
TidyBuffer *errbuf;
|
2009-01-07 07:45:16 +08:00
|
|
|
zval **config = NULL;
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2006-08-31 21:58:31 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) {
|
2004-01-08 17:21:05 +08:00
|
|
|
RETURN_FALSE;
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2003-09-22 03:22:19 +08:00
|
|
|
if (is_file) {
|
2005-10-26 02:04:59 +08:00
|
|
|
if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) {
|
2003-09-22 03:22:19 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
data = arg1;
|
2005-10-26 02:04:59 +08:00
|
|
|
data_len = arg1_len;
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
doc = tidyCreate();
|
|
|
|
errbuf = emalloc(sizeof(TidyBuffer));
|
|
|
|
tidyBufInit(errbuf);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
if (tidySetErrorBuffer(doc, errbuf) != 0) {
|
2004-05-24 01:22:21 +08:00
|
|
|
tidyBufFree(errbuf);
|
|
|
|
efree(errbuf);
|
|
|
|
tidyRelease(doc);
|
2004-04-16 23:46:41 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
|
2004-01-08 17:21:05 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
tidyOptSetBool(doc, TidyForceOutput, yes);
|
|
|
|
tidyOptSetBool(doc, TidyMark, no);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
TIDY_SET_DEFAULT_CONFIG(doc);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2009-01-07 07:45:16 +08:00
|
|
|
if (config) {
|
2006-07-08 08:13:17 +08:00
|
|
|
TIDY_APPLY_CONFIG_ZVAL(doc, config);
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (enc_len) {
|
2004-01-14 10:43:33 +08:00
|
|
|
if (tidySetCharEncoding(doc, enc) < 0) {
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
|
2004-01-14 10:43:33 +08:00
|
|
|
RETVAL_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2003-09-22 03:22:19 +08:00
|
|
|
if (data) {
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer buf;
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
tidyBufInit(&buf);
|
2010-03-11 18:24:29 +08:00
|
|
|
tidyBufAttach(&buf, (byte *) data, data_len);
|
2007-01-20 02:50:26 +08:00
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
if (tidyParseBuffer(doc, &buf) < 0) {
|
2004-01-08 17:21:05 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf->bp);
|
2003-09-22 03:22:19 +08:00
|
|
|
RETVAL_FALSE;
|
|
|
|
} else {
|
2004-01-08 17:21:05 +08:00
|
|
|
if (tidyCleanAndRepair(doc) >= 0) {
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer output;
|
|
|
|
tidyBufInit(&output);
|
2003-09-22 03:22:19 +08:00
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
tidySaveBuffer (doc, &output);
|
2010-03-11 18:24:29 +08:00
|
|
|
FIX_BUFFER(&output);
|
|
|
|
RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1);
|
2003-09-22 03:22:19 +08:00
|
|
|
tidyBufFree(&output);
|
|
|
|
} else {
|
|
|
|
RETVAL_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_file) {
|
|
|
|
efree(data);
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-08 17:21:05 +08:00
|
|
|
tidyBufFree(errbuf);
|
|
|
|
efree(errbuf);
|
|
|
|
tidyRelease(doc);
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path, int *len TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_stream *stream;
|
|
|
|
char *data = NULL;
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2004-04-21 02:28:09 +08:00
|
|
|
if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE, NULL))) {
|
2003-12-14 14:02:33 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
if ((*len = (int) php_stream_copy_to_mem(stream, (void*) &data, PHP_STREAM_COPY_ALL, 0)) == 0) {
|
2003-12-14 14:02:33 +08:00
|
|
|
data = estrdup("");
|
2005-10-26 02:04:59 +08:00
|
|
|
*len = 0;
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
php_stream_close(stream);
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
return data;
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2004-02-04 19:14:47 +08:00
|
|
|
static void tidy_object_free_storage(void *object TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *intern = (PHPTidyObj *)object;
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2006-03-29 22:28:43 +08:00
|
|
|
zend_object_std_dtor(&intern->std TSRMLS_CC);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-11-14 21:33:59 +08:00
|
|
|
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);
|
|
|
|
}
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
efree(object);
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, zend_object_value *retval, tidy_obj_type objtype TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *intern;
|
|
|
|
zval *tmp;
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
intern = emalloc(sizeof(PHPTidyObj));
|
|
|
|
memset(intern, 0, sizeof(PHPTidyObj));
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2006-03-29 22:28:43 +08:00
|
|
|
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
2003-12-14 14:02:33 +08:00
|
|
|
zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
switch(objtype) {
|
|
|
|
case is_node:
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
case is_doc:
|
2003-12-14 14:02:33 +08:00
|
|
|
intern->ptdoc = emalloc(sizeof(PHPTidyDoc));
|
|
|
|
intern->ptdoc->doc = tidyCreate();
|
|
|
|
intern->ptdoc->ref_count = 1;
|
|
|
|
intern->ptdoc->errbuf = emalloc(sizeof(TidyBuffer));
|
|
|
|
tidyBufInit(intern->ptdoc->errbuf);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
if (tidySetErrorBuffer(intern->ptdoc->doc, intern->ptdoc->errbuf) != 0) {
|
2004-05-24 01:22:21 +08:00
|
|
|
tidyBufFree(intern->ptdoc->errbuf);
|
|
|
|
efree(intern->ptdoc->errbuf);
|
|
|
|
tidyRelease(intern->ptdoc->doc);
|
|
|
|
efree(intern->ptdoc);
|
|
|
|
efree(intern);
|
2004-04-16 23:46:41 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyOptSetBool(intern->ptdoc->doc, TidyForceOutput, yes);
|
|
|
|
tidyOptSetBool(intern->ptdoc->doc, TidyMark, no);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
TIDY_SET_DEFAULT_CONFIG(intern->ptdoc->doc);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-18 19:20:19 +08:00
|
|
|
tidy_add_default_properties(intern, is_doc TSRMLS_CC);
|
2003-12-14 14:02:33 +08:00
|
|
|
break;
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2005-11-15 06:03:02 +08:00
|
|
|
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);
|
2003-12-14 14:02:33 +08:00
|
|
|
retval->handlers = handlers;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
static zend_object_value tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
zend_object_value retval;
|
|
|
|
tidy_object_new(class_type, &tidy_object_handlers_node, &retval, is_node TSRMLS_CC);
|
|
|
|
return retval;
|
|
|
|
}
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
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;
|
|
|
|
}
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
|
|
|
|
{
|
|
|
|
if (!object) {
|
|
|
|
ALLOC_ZVAL(object);
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
Z_TYPE_P(object) = IS_OBJECT;
|
|
|
|
object_init_ex(object, pce);
|
2007-10-07 13:22:07 +08:00
|
|
|
Z_SET_REFCOUNT_P(object, 1);
|
|
|
|
Z_SET_ISREF_P(object);
|
2003-12-14 14:02:33 +08:00
|
|
|
return object;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
|
2006-05-10 08:00:13 +08:00
|
|
|
static int tidy_doc_cast_handler(zval *in, zval *out, int type TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer output;
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
switch(type) {
|
|
|
|
case IS_LONG:
|
|
|
|
ZVAL_LONG(out, 0);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_DOUBLE:
|
|
|
|
ZVAL_DOUBLE(out, 0);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_BOOL:
|
|
|
|
ZVAL_BOOL(out, TRUE);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_STRING:
|
|
|
|
obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
|
2007-01-20 02:50:26 +08:00
|
|
|
tidyBufInit(&output);
|
2003-12-14 14:02:33 +08:00
|
|
|
tidySaveBuffer (obj->ptdoc->doc, &output);
|
2010-03-11 18:24:29 +08:00
|
|
|
ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0, 1);
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyBufFree(&output);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
default:
|
|
|
|
return FAILURE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
return SUCCESS;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
|
2006-05-10 08:00:13 +08:00
|
|
|
static int tidy_node_cast_handler(zval *in, zval *out, int type TSRMLS_DC)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer buf;
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
switch(type) {
|
|
|
|
case IS_LONG:
|
|
|
|
ZVAL_LONG(out, 0);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_DOUBLE:
|
|
|
|
ZVAL_DOUBLE(out, 0);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_BOOL:
|
|
|
|
ZVAL_BOOL(out, TRUE);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case IS_STRING:
|
|
|
|
obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
|
2007-01-20 02:50:26 +08:00
|
|
|
tidyBufInit(&buf);
|
2007-01-20 20:49:35 +08:00
|
|
|
if (obj->ptdoc) {
|
|
|
|
tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
|
2010-03-11 18:24:29 +08:00
|
|
|
ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1, 1);
|
|
|
|
} else {
|
|
|
|
ZVAL_EMPTY_STRING(out);
|
2007-01-20 20:49:35 +08:00
|
|
|
}
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyBufFree(&buf);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
default:
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tidy_doc_update_properties(PHPTidyObj *obj TSRMLS_DC)
|
|
|
|
{
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer output;
|
2004-01-14 10:43:33 +08:00
|
|
|
zval *temp;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2007-01-20 02:50:26 +08:00
|
|
|
tidyBufInit(&output);
|
2004-01-14 10:43:33 +08:00
|
|
|
tidySaveBuffer (obj->ptdoc->doc, &output);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
if (output.size) {
|
|
|
|
MAKE_STD_ZVAL(temp);
|
2010-03-11 18:24:29 +08:00
|
|
|
ZVAL_STRINGL(temp, (char *) output.bp, output.size-1, 1);
|
2004-01-14 10:43:33 +08:00
|
|
|
zend_hash_update(obj->std.properties, "value", sizeof("value"), (void *)&temp, sizeof(zval *), NULL);
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
tidyBufFree(&output);
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
if (obj->ptdoc->errbuf->size) {
|
|
|
|
MAKE_STD_ZVAL(temp);
|
2010-03-11 18:24:29 +08:00
|
|
|
ZVAL_STRINGL(temp, (char *) obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, TRUE);
|
2004-04-21 02:28:09 +08:00
|
|
|
zend_hash_update(obj->std.properties, "errorBuffer", sizeof("errorBuffer"), (void *)&temp, sizeof(zval *), NULL);
|
2004-01-14 10:43:33 +08:00
|
|
|
}
|
2004-01-08 08:03:54 +08:00
|
|
|
}
|
|
|
|
|
2003-12-18 19:20:19 +08:00
|
|
|
static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRMLS_DC)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
TidyBuffer buf;
|
|
|
|
TidyAttr tempattr;
|
|
|
|
TidyNode tempnode;
|
|
|
|
zval *attribute, *children, *temp;
|
|
|
|
PHPTidyObj *newobj;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
switch(type) {
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_node:
|
2007-01-20 02:50:26 +08:00
|
|
|
tidyBufInit(&buf);
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
|
2010-03-11 18:24:29 +08:00
|
|
|
ADD_PROPERTY_STRINGL(obj->std.properties, value, buf.bp, buf.size ? buf.size-1 : 0);
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyBufFree(&buf);
|
|
|
|
|
2003-12-18 19:20:19 +08:00
|
|
|
ADD_PROPERTY_STRING(obj->std.properties, name, tidyNodeGetName(obj->node));
|
|
|
|
ADD_PROPERTY_LONG(obj->std.properties, type, tidyNodeGetType(obj->node));
|
2005-03-21 11:54:29 +08:00
|
|
|
ADD_PROPERTY_LONG(obj->std.properties, line, tidyNodeLine(obj->node));
|
2006-09-15 22:33:34 +08:00
|
|
|
ADD_PROPERTY_LONG(obj->std.properties, column, tidyNodeColumn(obj->node));
|
|
|
|
ADD_PROPERTY_BOOL(obj->std.properties, proprietary, tidyNodeIsProp(obj->ptdoc->doc, obj->node));
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
switch(tidyNodeGetType(obj->node)) {
|
|
|
|
case TidyNode_Root:
|
|
|
|
case TidyNode_DocType:
|
|
|
|
case TidyNode_Text:
|
|
|
|
case TidyNode_Comment:
|
|
|
|
break;
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
default:
|
2003-12-18 19:20:19 +08:00
|
|
|
ADD_PROPERTY_LONG(obj->std.properties, id, tidyNodeGetId(obj->node));
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
tempattr = tidyAttrFirst(obj->node);
|
|
|
|
MAKE_STD_ZVAL(attribute);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
if (tempattr) {
|
2003-12-14 14:02:33 +08:00
|
|
|
char *name, *val;
|
|
|
|
array_init(attribute);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
do {
|
|
|
|
name = (char *)tidyAttrName(tempattr);
|
|
|
|
val = (char *)tidyAttrValue(tempattr);
|
2003-12-15 09:43:45 +08:00
|
|
|
if (name && val) {
|
2003-12-14 14:02:33 +08:00
|
|
|
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);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
tempnode = tidyGetChild(obj->node);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
MAKE_STD_ZVAL(children);
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tempnode) {
|
2003-12-14 14:02:33 +08:00
|
|
|
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++;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-18 19:20:19 +08:00
|
|
|
tidy_add_default_properties(newobj, is_node TSRMLS_CC);
|
2003-12-14 14:02:33 +08:00
|
|
|
add_next_index_zval(children, temp);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
} while((tempnode = tidyGetNext(tempnode)));
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
} else {
|
|
|
|
ZVAL_NULL(children);
|
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
zend_hash_update(obj->std.properties, "child", sizeof("child"), (void *)&children, sizeof(zval *), NULL);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_doc:
|
2004-04-21 02:28:09 +08:00
|
|
|
ADD_PROPERTY_NULL(obj->std.properties, errorBuffer);
|
2003-12-18 19:20:19 +08:00
|
|
|
ADD_PROPERTY_NULL(obj->std.properties, value);
|
2003-12-14 14:02:33 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-09-21 06:25:06 +08:00
|
|
|
static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetypes node_type)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
PHPTidyObj *newobj;
|
2007-09-21 06:25:06 +08:00
|
|
|
TidyNode node;
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2007-09-21 06:25:06 +08:00
|
|
|
switch (node_type) {
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_root_node:
|
2007-09-21 06:25:06 +08:00
|
|
|
node = tidyGetRoot(obj->ptdoc->doc);
|
2003-12-14 14:02:33 +08:00
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_html_node:
|
2007-09-21 06:25:06 +08:00
|
|
|
node = tidyGetHtml(obj->ptdoc->doc);
|
2003-12-14 14:02:33 +08:00
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_head_node:
|
2007-09-21 06:25:06 +08:00
|
|
|
node = tidyGetHead(obj->ptdoc->doc);
|
2003-12-14 14:02:33 +08:00
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
case is_body_node:
|
2007-09-21 06:25:06 +08:00
|
|
|
node = tidyGetBody(obj->ptdoc->doc);
|
2003-12-14 14:02:33 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-09-21 06:25:06 +08:00
|
|
|
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++;
|
|
|
|
|
2003-12-18 19:20:19 +08:00
|
|
|
tidy_add_default_properties(newobj, is_node TSRMLS_CC);
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
|
2004-01-08 08:03:54 +08:00
|
|
|
static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC)
|
2004-01-07 02:24:17 +08:00
|
|
|
{
|
2010-03-11 18:24:29 +08:00
|
|
|
char *opt_name;
|
2004-01-07 02:24:17 +08:00
|
|
|
zval **opt_val;
|
|
|
|
ulong opt_indx;
|
2010-03-11 18:24:29 +08:00
|
|
|
uint opt_name_len;
|
|
|
|
zend_bool clear_str;
|
|
|
|
|
2004-01-07 02:24:17 +08:00
|
|
|
for (zend_hash_internal_pointer_reset(ht_options);
|
2010-03-11 18:24:29 +08:00
|
|
|
zend_hash_get_current_data(ht_options, (void *) &opt_val) == SUCCESS;
|
2004-01-07 02:24:17 +08:00
|
|
|
zend_hash_move_forward(ht_options)) {
|
2010-03-11 18:24:29 +08:00
|
|
|
|
|
|
|
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:
|
2004-04-16 23:46:41 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not retrieve key from option array");
|
2004-01-14 10:43:33 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
_php_tidy_set_tidy_opt(doc, opt_name, *opt_val TSRMLS_CC);
|
|
|
|
if (clear_str) {
|
|
|
|
efree(opt_name);
|
2004-01-07 02:24:17 +08:00
|
|
|
}
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-07 02:24:17 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
static int php_tidy_parse_string(PHPTidyObj *obj, char *string, int len, char *enc TSRMLS_DC)
|
|
|
|
{
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer buf;
|
2010-03-11 18:24:29 +08:00
|
|
|
|
|
|
|
if (enc) {
|
2004-01-14 10:43:33 +08:00
|
|
|
if (tidySetCharEncoding(obj->ptdoc->doc, enc) < 0) {
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
|
2004-01-14 10:43:33 +08:00
|
|
|
return FAILURE;
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2004-01-07 02:24:17 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
tidyBufInit(&buf);
|
2010-03-11 18:24:29 +08:00
|
|
|
tidyBufAttach(&buf, (byte *) string, len);
|
2005-10-26 02:04:59 +08:00
|
|
|
if (tidyParseBuffer(obj->ptdoc->doc, &buf) < 0) {
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", obj->ptdoc->errbuf->bp);
|
2004-01-14 10:43:33 +08:00
|
|
|
return FAILURE;
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2004-01-14 10:43:33 +08:00
|
|
|
tidy_doc_update_properties(obj TSRMLS_CC);
|
2005-10-26 02:04:59 +08:00
|
|
|
|
|
|
|
return SUCCESS;
|
2004-01-14 10:43:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_MINIT_FUNCTION(tidy)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2010-03-11 18:24:29 +08:00
|
|
|
tidySetMallocCall(php_tidy_malloc);
|
|
|
|
tidySetReallocCall(php_tidy_realloc);
|
|
|
|
tidySetFreeCall(php_tidy_free);
|
|
|
|
tidySetPanicCall(php_tidy_panic);
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
REGISTER_INI_ENTRIES();
|
2004-05-29 04:32:52 +08:00
|
|
|
REGISTER_TIDY_CLASS(tidy, doc, NULL, 0);
|
|
|
|
REGISTER_TIDY_CLASS(tidyNode, node, NULL, ZEND_ACC_FINAL_CLASS);
|
2006-09-15 22:33:34 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler;
|
|
|
|
tidy_object_handlers_node.cast_object = tidy_node_cast_handler;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
_php_tidy_register_tags(INIT_FUNC_ARGS_PASSTHRU);
|
|
|
|
_php_tidy_register_nodetypes(INIT_FUNC_ARGS_PASSTHRU);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
PHP_OUTPUT_ALIAS_REGISTER("ob_tidyhandler", php_tidy_output_handler_init);
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_RINIT_FUNCTION(tidy)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2010-03-11 18:24:29 +08:00
|
|
|
zval *name;
|
|
|
|
|
|
|
|
MAKE_STD_ZVAL(name);
|
|
|
|
ZVAL_STRING(name, "ob_tidyhandler", 1);
|
|
|
|
php_tidy_clean_output_start(name TSRMLS_CC);
|
|
|
|
zval_ptr_dtor(&name);
|
2003-12-14 14:02:33 +08:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_MSHUTDOWN_FUNCTION(tidy)
|
2006-05-25 05:22:13 +08:00
|
|
|
{
|
|
|
|
UNREGISTER_INI_ENTRIES();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_MINFO_FUNCTION(tidy)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
|
|
|
php_info_print_table_start();
|
2003-12-15 09:43:45 +08:00
|
|
|
php_info_print_table_header(2, "Tidy support", "enabled");
|
2004-01-14 10:43:33 +08:00
|
|
|
php_info_print_table_row(2, "libTidy Release", (char *)tidyReleaseDate());
|
2003-12-15 09:43:45 +08:00
|
|
|
php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id$)");
|
2003-12-14 14:02:33 +08:00
|
|
|
php_info_print_table_end();
|
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
DISPLAY_INI_ENTRIES();
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
static PHP_INI_MH(php_tidy_set_clean_output)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2010-03-11 18:24:29 +08:00
|
|
|
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);
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (stage == PHP_INI_STAGE_RUNTIME) {
|
|
|
|
status = php_output_get_status(TSRMLS_C);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
status = OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (stage == PHP_INI_STAGE_RUNTIME && value) {
|
|
|
|
zval *tmp;
|
|
|
|
|
|
|
|
MAKE_STD_ZVAL(tmp);
|
|
|
|
ZVAL_STRING(tmp, "ob_tidyhandler", 1);
|
|
|
|
if (!php_output_handler_started(tmp TSRMLS_CC)) {
|
|
|
|
php_tidy_clean_output_start(tmp TSRMLS_CC);
|
|
|
|
}
|
|
|
|
zval_ptr_dtor(&tmp);
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
return status;
|
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/*
|
|
|
|
* NOTE: tidy does not support iterative/cumulative parsing, so chunk-sized output handler is not possible
|
|
|
|
*/
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
static void php_tidy_clean_output_start(zval *name TSRMLS_DC)
|
|
|
|
{
|
|
|
|
php_output_handler *h;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (TG(clean_output) && (h = php_tidy_output_handler_init(name, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC))) {
|
|
|
|
php_output_handler_start(h TSRMLS_CC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static php_output_handler *php_tidy_output_handler_init(zval *handler_name, 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, 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;
|
|
|
|
}
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
|
|
|
tidyRelease(doc);
|
|
|
|
tidyBufFree(&errbuf);
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
return status;
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidy_parse_string(string input [, mixed config_options [, string encoding]]) U
|
2003-12-14 14:02:33 +08:00
|
|
|
Parse a document stored in a string */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_parse_string)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2010-03-11 18:24:29 +08:00
|
|
|
char *input;
|
|
|
|
char *enc = NULL;
|
|
|
|
int input_len, enc_len;
|
2006-08-31 21:58:31 +08:00
|
|
|
zval **options = NULL;
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs&", &input, &input_len, &options, &enc, &enc_len) == FAILURE) {
|
2003-12-15 09:43:45 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC);
|
|
|
|
obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
|
|
|
if (php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == FAILURE) {
|
2004-01-14 10:43:33 +08:00
|
|
|
zval_dtor(return_value);
|
|
|
|
INIT_ZVAL(*return_value);
|
2010-03-11 18:24:29 +08:00
|
|
|
RETVAL_FALSE;
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto string tidy_get_error_buffer()
|
2003-12-14 14:02:33 +08:00
|
|
|
Return warnings and errors which occured parsing the specified document*/
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_error_buffer)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
|
|
|
|
2004-06-24 22:20:59 +08:00
|
|
|
if (obj->ptdoc->errbuf && obj->ptdoc->errbuf->bp) {
|
2010-03-11 18:24:29 +08:00
|
|
|
RETURN_STRINGL((char *) obj->ptdoc->errbuf->bp, obj->ptdoc->errbuf->size-1, 1);
|
2004-06-24 22:20:59 +08:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
/* {{{ proto string tidy_get_output()
|
2003-12-14 14:02:33 +08:00
|
|
|
Return a string representing the parsed tidy markup */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_output)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2007-01-20 02:50:26 +08:00
|
|
|
TidyBuffer output;
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2007-01-20 02:50:26 +08:00
|
|
|
tidyBufInit(&output);
|
2003-12-15 09:43:45 +08:00
|
|
|
tidySaveBuffer(obj->ptdoc->doc, &output);
|
2010-03-11 18:24:29 +08:00
|
|
|
FIX_BUFFER(&output);
|
|
|
|
RETVAL_STRINGL((char *) output.bp, output.size ? output.size-1 : 0, 1);
|
2003-12-14 14:02:33 +08:00
|
|
|
tidyBufFree(&output);
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
/* {{{ proto boolean tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])
|
2003-12-14 14:02:33 +08:00
|
|
|
Parse markup in file or URI */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_parse_file)
|
2003-12-14 14:02:33 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
char *inputfile, *enc = NULL;
|
2005-10-26 02:04:59 +08:00
|
|
|
int input_len, contents_len, enc_len = 0;
|
2004-01-14 10:43:33 +08:00
|
|
|
zend_bool use_include_path = 0;
|
|
|
|
char *contents;
|
2006-08-31 21:58:31 +08:00
|
|
|
zval **options = NULL;
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
PHPTidyObj *obj;
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
|
2004-01-14 10:43:33 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC);
|
|
|
|
obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
|
2010-03-11 18:24:29 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
|
2004-09-27 03:24:18 +08:00
|
|
|
RETURN_FALSE;
|
2004-01-14 10:43:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
|
2004-01-14 10:43:33 +08:00
|
|
|
zval_dtor(return_value);
|
|
|
|
INIT_ZVAL(*return_value);
|
|
|
|
RETVAL_FALSE;
|
|
|
|
}
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
efree(contents);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto boolean tidy_clean_repair()
|
2003-08-01 08:22:43 +08:00
|
|
|
Execute configured cleanup and repair operations on parsed markup */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_clean_repair)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
if (tidyCleanAndRepair(obj->ptdoc->doc) >= 0) {
|
2003-12-18 19:20:19 +08:00
|
|
|
tidy_doc_update_properties(obj TSRMLS_CC);
|
2003-09-21 03:45:32 +08:00
|
|
|
RETURN_TRUE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-08-06 08:01:22 +08:00
|
|
|
RETURN_FALSE;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
/* {{{ proto boolean tidy_repair_string(string data [, mixed config_file [, string encoding]])
|
2003-09-22 03:22:19 +08:00
|
|
|
Repair a string using an optionally provided configuration file */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_repair_string)
|
2003-09-22 03:22:19 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
/* {{{ proto boolean tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])
|
2003-09-22 03:22:19 +08:00
|
|
|
Repair a file using an optionally provided configuration file */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_repair_file)
|
2003-09-22 03:22:19 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
|
2003-09-22 03:22:19 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto boolean tidy_diagnose()
|
2003-12-19 03:59:58 +08:00
|
|
|
Run configured diagnostics on parsed and repaired markup. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_diagnose)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
if (tidyRunDiagnostics(obj->ptdoc->doc) >= 0) {
|
2003-12-18 19:20:19 +08:00
|
|
|
tidy_doc_update_properties(obj TSRMLS_CC);
|
2003-09-21 03:45:32 +08:00
|
|
|
RETURN_TRUE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
RETURN_FALSE;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto string tidy_get_release()
|
2003-12-19 03:59:58 +08:00
|
|
|
Get release date (version) for Tidy library */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_release)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2008-03-11 06:15:36 +08:00
|
|
|
if (zend_parse_parameters_none() == FAILURE) {
|
|
|
|
return;
|
2003-09-21 03:45:32 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
RETURN_STRING((char *)tidyReleaseDate(), 1);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2005-04-26 04:46:16 +08:00
|
|
|
|
|
|
|
#if HAVE_TIDYOPTGETDOC
|
|
|
|
/* {{{ proto string tidy_get_opt_doc(tidy resource, string optname)
|
|
|
|
Returns the documentation for the given option name */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_opt_doc)
|
2005-04-26 04:46:16 +08:00
|
|
|
{
|
|
|
|
PHPTidyObj *obj;
|
2010-03-11 18:24:29 +08:00
|
|
|
char *optval, *optname;
|
2005-04-26 04:46:16 +08:00
|
|
|
int optname_len;
|
|
|
|
TidyOption opt;
|
2006-09-15 22:33:34 +08:00
|
|
|
|
2005-04-26 04:46:16 +08:00
|
|
|
TIDY_SET_CONTEXT;
|
|
|
|
|
|
|
|
if (object) {
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", &optname, &optname_len) == FAILURE) {
|
2005-04-26 04:46:16 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "Os&", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
|
2005-04-26 04:46:16 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-10-12 22:29:26 +08:00
|
|
|
if ( (optval = (char *) tidyOptGetDoc(obj->ptdoc->doc, opt)) ) {
|
2005-04-26 04:46:16 +08:00
|
|
|
RETURN_STRING(optval, 1);
|
2005-10-12 22:29:26 +08:00
|
|
|
}
|
2005-04-26 04:46:16 +08:00
|
|
|
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto array tidy_get_config()
|
2010-03-11 18:24:29 +08:00
|
|
|
Get current Tidy configuration */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_config)
|
2003-09-21 03:45:32 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
TidyIterator itOpt;
|
2003-09-21 03:45:32 +08:00
|
|
|
char *opt_name;
|
|
|
|
void *opt_value;
|
|
|
|
TidyOptionType optt;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
TIDY_FETCH_OBJECT;
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
itOpt = tidyGetOptionList(obj->ptdoc->doc);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
array_init(return_value);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
while (itOpt) {
|
2003-12-14 14:02:33 +08:00
|
|
|
TidyOption opt = tidyGetNextOption(obj->ptdoc->doc, &itOpt);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
opt_name = (char *)tidyOptGetName(opt);
|
2003-12-14 14:02:33 +08:00
|
|
|
opt_value = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC);
|
2003-09-21 03:45:32 +08:00
|
|
|
switch (optt) {
|
|
|
|
case TidyString:
|
2010-03-11 18:24:29 +08:00
|
|
|
add_assoc_string(return_value, opt_name, (char*)opt_value, 1);
|
2003-09-21 03:45:32 +08:00
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
case TidyInteger:
|
|
|
|
add_assoc_long(return_value, opt_name, (long)opt_value);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
case TidyBoolean:
|
|
|
|
add_assoc_bool(return_value, opt_name, (long)opt_value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int tidy_get_status()
|
2003-12-19 03:59:58 +08:00
|
|
|
Get status of specfied document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_status)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_LONG(tidyStatus(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto int tidy_get_html_ver()
|
2003-12-19 03:59:58 +08:00
|
|
|
Get the Detected HTML version for the specified document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_html_ver)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_LONG(tidyDetectedHtmlVersion(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidy_is_xhtml()
|
2003-12-19 03:59:58 +08:00
|
|
|
Indicates if the document is a XHTML document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_is_xhtml)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_BOOL(tidyDetectedXhtml(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidy_is_xml()
|
2003-12-19 03:59:58 +08:00
|
|
|
Indicates if the document is a generic (non HTML/XHTML) XML document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_is_xml)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_BOOL(tidyDetectedGenericXml(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto int tidy_error_count()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns the Number of Tidy errors encountered for specified document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_error_count)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_LONG(tidyErrorCount(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int tidy_warning_count()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns the Number of Tidy warnings encountered for specified document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_warning_count)
|
2003-12-15 09:43:45 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_LONG(tidyWarningCount(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto int tidy_access_count()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns the Number of Tidy accessibility warnings encountered for specified document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_access_count)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
RETURN_LONG(tidyAccessWarningCount(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-21 03:45:32 +08:00
|
|
|
/* {{{ proto int tidy_config_count()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns the Number of Tidy configuration errors encountered for specified document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_config_count)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_FETCH_OBJECT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
RETURN_LONG(tidyConfigErrorCount(obj->ptdoc->doc));
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
/* {{{ proto mixed tidy_getopt(string option)
|
|
|
|
Returns the value of the specified configuration option for the tidy document. */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_getopt)
|
2010-03-11 18:24:29 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2004-01-14 10:43:33 +08:00
|
|
|
char *optname;
|
|
|
|
void *optval;
|
|
|
|
int optname_len;
|
|
|
|
TidyOption opt;
|
|
|
|
TidyOptionType optt;
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-11-26 07:44:20 +08:00
|
|
|
TIDY_SET_CONTEXT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
|
|
|
if (object) {
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", &optname, &optname_len) == FAILURE) {
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "Os&", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
|
2004-11-26 07:44:20 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
if (!opt) {
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname);
|
2003-09-21 03:45:32 +08:00
|
|
|
RETURN_FALSE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
optval = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC);
|
|
|
|
switch (optt) {
|
|
|
|
case TidyString:
|
2010-03-11 18:24:29 +08:00
|
|
|
RETURN_STRING((char *)optval, 1);
|
2004-01-14 10:43:33 +08:00
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
case TidyInteger:
|
|
|
|
RETURN_LONG((long)optval);
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
case TidyBoolean:
|
|
|
|
if (optval) {
|
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
2004-04-18 15:58:19 +08:00
|
|
|
RETURN_FALSE;
|
2004-01-14 10:43:33 +08:00
|
|
|
}
|
|
|
|
break;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
default:
|
2004-04-18 15:58:19 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of configuration option");
|
2004-01-14 10:43:33 +08:00
|
|
|
break;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
RETURN_FALSE;
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_DOC_METHOD(__construct)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-04-17 02:55:19 +08:00
|
|
|
char *inputfile = NULL, *enc = NULL;
|
2005-10-26 02:04:59 +08:00
|
|
|
int input_len = 0, enc_len = 0, contents_len = 0;
|
2004-01-14 10:43:33 +08:00
|
|
|
zend_bool use_include_path = 0;
|
|
|
|
char *contents;
|
2006-08-31 21:58:31 +08:00
|
|
|
zval **options = NULL;
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2010-03-11 18:24:29 +08:00
|
|
|
TIDY_SET_CONTEXT;
|
|
|
|
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sZsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
|
2003-09-21 03:45:32 +08:00
|
|
|
RETURN_FALSE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2004-11-26 07:44:20 +08:00
|
|
|
if (inputfile) {
|
2005-10-26 02:04:59 +08:00
|
|
|
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
|
2010-03-11 18:24:29 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
|
2004-11-26 07:44:20 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
|
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC);
|
2004-11-26 07:44:20 +08:00
|
|
|
|
|
|
|
efree(contents);
|
|
|
|
}
|
2003-12-14 14:02:33 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_DOC_METHOD(parseFile)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
char *inputfile, *enc = NULL;
|
2005-10-26 02:04:59 +08:00
|
|
|
int input_len, enc_len = 0, contents_len = 0;
|
2004-01-14 10:43:33 +08:00
|
|
|
zend_bool use_include_path = 0;
|
|
|
|
char *contents;
|
2006-08-31 21:58:31 +08:00
|
|
|
zval **options = NULL;
|
2004-11-26 07:44:20 +08:00
|
|
|
PHPTidyObj *obj;
|
|
|
|
|
|
|
|
TIDY_SET_CONTEXT;
|
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
|
2004-01-14 10:43:33 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2005-10-26 02:04:59 +08:00
|
|
|
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
|
2010-03-11 18:24:29 +08:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
|
2003-09-21 03:45:32 +08:00
|
|
|
RETURN_FALSE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
|
2004-01-14 10:43:33 +08:00
|
|
|
RETVAL_FALSE;
|
2003-12-14 14:02:33 +08:00
|
|
|
} else {
|
2004-01-14 10:43:33 +08:00
|
|
|
RETVAL_TRUE;
|
2003-08-06 08:01:22 +08:00
|
|
|
}
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
efree(contents);
|
2003-09-22 08:12:54 +08:00
|
|
|
}
|
2003-09-21 03:45:32 +08:00
|
|
|
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_DOC_METHOD(parseString)
|
2003-09-22 08:12:54 +08:00
|
|
|
{
|
2004-01-14 10:43:33 +08:00
|
|
|
char *input, *enc = NULL;
|
|
|
|
int input_len, enc_len = 0;
|
2006-08-31 21:58:31 +08:00
|
|
|
zval **options = NULL;
|
2003-12-14 14:02:33 +08:00
|
|
|
PHPTidyObj *obj;
|
2004-11-26 07:44:20 +08:00
|
|
|
|
|
|
|
TIDY_SET_CONTEXT;
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2006-08-31 21:58:31 +08:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) {
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_FALSE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
|
2003-12-02 06:10:46 +08:00
|
|
|
|
2004-01-14 10:43:33 +08:00
|
|
|
TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
if (php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) {
|
2004-01-14 10:43:33 +08:00
|
|
|
RETURN_TRUE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_FALSE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
2004-01-14 10:43:33 +08:00
|
|
|
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-09-22 08:12:54 +08:00
|
|
|
/* {{{ proto TidyNode tidy_get_root()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns a TidyNode Object representing the root of the tidy parse tree */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_root)
|
2003-09-22 08:12:54 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_root_node);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-09-22 08:12:54 +08:00
|
|
|
/* {{{ proto TidyNode tidy_get_html()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns a TidyNode Object starting from the <HTML> tag of the tidy parse tree */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_html)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_html_node);
|
2003-08-08 01:53:48 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-08-08 01:53:48 +08:00
|
|
|
|
2003-09-22 08:12:54 +08:00
|
|
|
/* {{{ proto TidyNode tidy_get_head()
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns a TidyNode Object starting from the <HEAD> tag of the tidy parse tree */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_head)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_head_node);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2003-09-22 08:12:54 +08:00
|
|
|
/* {{{ proto TidyNode tidy_get_body(resource tidy)
|
2003-12-19 03:59:58 +08:00
|
|
|
Returns a TidyNode Object starting from the <BODY> tag of the tidy parse tree */
|
2006-08-14 23:09:08 +08:00
|
|
|
static PHP_FUNCTION(tidy_get_body)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-14 14:02:33 +08:00
|
|
|
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_body_node);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::hasChildren()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node has children */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(hasChildren)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyGetChild(obj->node)) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-08-01 08:22:43 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::hasSiblings()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node has siblings */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(hasSiblings)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2007-01-20 20:27:18 +08:00
|
|
|
if (obj->node && tidyGetNext(obj->node)) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isComment()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node represents a comment */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isComment)
|
2003-09-23 01:06:45 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) == TidyNode_Comment) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isHtml()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node is part of a HTML document */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isHtml)
|
2003-09-23 01:06:45 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) & (TidyNode_Start | TidyNode_End | TidyNode_StartEnd)) {
|
2003-09-23 02:40:38 +08:00
|
|
|
RETURN_TRUE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2003-09-23 02:40:38 +08:00
|
|
|
RETURN_FALSE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isText()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node represents text (no markup) */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isText)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) == TidyNode_Text) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isJste()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node is JSTE */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isJste)
|
2003-09-23 01:06:45 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) == TidyNode_Jste) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-09-23 02:40:38 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isAsp()
|
2003-09-23 01:06:45 +08:00
|
|
|
Returns true if this node is ASP */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isAsp)
|
2003-09-23 01:06:45 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-12-14 14:02:33 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) == TidyNode_Asp) {
|
2003-09-23 01:06:45 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2003-12-15 09:43:45 +08:00
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
/* {{{ proto bool tidyNode::isPhp()
|
2003-12-15 09:43:45 +08:00
|
|
|
Returns true if this node is PHP */
|
2006-08-14 23:09:08 +08:00
|
|
|
static TIDY_NODE_METHOD(isPhp)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-15 09:43:45 +08:00
|
|
|
TIDY_FETCH_ONLY_OBJECT;
|
2003-09-23 01:06:45 +08:00
|
|
|
|
2003-12-15 09:43:45 +08:00
|
|
|
if (tidyNodeGetType(obj->node) == TidyNode_Php) {
|
2003-12-14 14:02:33 +08:00
|
|
|
RETURN_TRUE;
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
2003-09-23 01:06:45 +08:00
|
|
|
}
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
2003-09-22 08:12:54 +08:00
|
|
|
/* }}} */
|
2003-09-23 02:40:38 +08:00
|
|
|
|
2007-02-12 00:07:30 +08:00
|
|
|
/* {{{ 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);
|
2010-03-11 18:24:29 +08:00
|
|
|
if (parent_node) {
|
2007-02-12 00:07:30 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-03-11 18:24:29 +08:00
|
|
|
|
2009-12-26 05:24:36 +08:00
|
|
|
/* {{{ proto void tidyNode::__construct()
|
2010-03-11 18:24:29 +08:00
|
|
|
__constructor for tidyNode. */
|
2009-12-26 05:24:36 +08:00
|
|
|
static TIDY_NODE_METHOD(__construct)
|
|
|
|
{
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a tidyNode manually");
|
2010-03-11 18:24:29 +08:00
|
|
|
}
|
2009-12-26 05:24:36 +08:00
|
|
|
/* }}} */
|
|
|
|
|
2004-02-23 08:59:29 +08:00
|
|
|
static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-19 03:59:58 +08:00
|
|
|
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);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
|
2004-02-23 08:59:29 +08:00
|
|
|
static void _php_tidy_register_tags(INIT_FUNC_ARGS)
|
2003-08-08 01:53:48 +08:00
|
|
|
{
|
2003-12-19 03:59:58 +08:00
|
|
|
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);
|
2003-08-01 08:22:43 +08:00
|
|
|
}
|
|
|
|
|
2003-12-19 03:59:58 +08:00
|
|
|
#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
|
|
|
|
*/
|