]> granicus.if.org Git - php/commitdiff
Added the ability to pass options to loadHTML (Chregu, fxmulder at gmail dot com)
authorChristian Stocker <chregu@php.net>
Mon, 11 Jul 2011 15:18:46 +0000 (15:18 +0000)
committerChristian Stocker <chregu@php.net>
Mon, 11 Jul 2011 15:18:46 +0000 (15:18 +0000)
(MFT - Merged from Trunk)

NEWS
ext/dom/document.c
ext/libxml/libxml.c

diff --git a/NEWS b/NEWS
index 859d3dc2e6652f13d76f8fa15d5ac5cc4d0d4788..61e5e0d3a366991238d06fc6bff938f18faa6144 100644 (file)
--- a/NEWS
+++ b/NEWS
   . Added Tokyo Cabinet abstract DB support. (Michael Maclean)
   . Added Berkeley DB 5 support. (Johannes, Chris Jones)
 
+- Improved DOM extension:
+  . Added the ability to pass options to loadHTML (Chregu, fxmulder at gmail dot com)
+
 - Improved filesystem functions:
   . scandir() now accepts SCANDIR_SORT_NONE as a possible sorting_order value.
     FR #53407. (Adam)
index e01e2c34d66876ae7e86fb92945f6cd744f304f4..2b11e7f1c43f41524bcda16420e982d6a3e28390 100644 (file)
@@ -149,10 +149,12 @@ ZEND_END_ARG_INFO();
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_document_loadhtml, 0, 0, 1)
        ZEND_ARG_INFO(0, source)
+       ZEND_ARG_INFO(0, options)
 ZEND_END_ARG_INFO();
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_document_loadhtmlfile, 0, 0, 1)
        ZEND_ARG_INFO(0, source)
+       ZEND_ARG_INFO(0, options)
 ZEND_END_ARG_INFO();
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_document_savehtml, 0, 0, 0)
@@ -2155,12 +2157,12 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
        dom_object *intern;
        dom_doc_propsptr doc_prop;
        char *source;
-       int source_len, refcount, ret;
+       int source_len, refcount, ret, options = 0;
        htmlParserCtxtPtr ctxt;
        
        id = getThis();
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
                return;
        }
 
@@ -2180,6 +2182,10 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
                RETURN_FALSE;
        }
 
+       if (options) {
+               htmlCtxtUseOptions(ctxt, options);
+       }
+
        ctxt->vctxt.error = php_libxml_ctx_error;
        ctxt->vctxt.warning = php_libxml_ctx_warning;
        if (ctxt->sax != NULL) {
index e19075cd263a40faa9f6a049a23965c48cd97696..9518e13cc0a88542432ce8ca798f8f028d256c01 100644 (file)
@@ -618,6 +618,7 @@ static PHP_MINIT_FUNCTION(libxml)
        REGISTER_LONG_CONSTANT("LIBXML_NSCLEAN",        XML_PARSE_NSCLEAN,              CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LIBXML_NOCDATA",        XML_PARSE_NOCDATA,              CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LIBXML_NONET",          XML_PARSE_NONET,                CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("LIBXML_PEDANTIC",       XML_PARSE_PEDANTIC,             CONST_CS | CONST_PERSISTENT);
 #if LIBXML_VERSION >= 20621
        REGISTER_LONG_CONSTANT("LIBXML_COMPACT",        XML_PARSE_COMPACT,              CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LIBXML_NOXMLDECL",      XML_SAVE_NO_DECL,               CONST_CS | CONST_PERSISTENT);
@@ -627,6 +628,15 @@ static PHP_MINIT_FUNCTION(libxml)
 #endif
        REGISTER_LONG_CONSTANT("LIBXML_NOEMPTYTAG",     LIBXML_SAVE_NOEMPTYTAG, CONST_CS | CONST_PERSISTENT);
 
+       /* Additional constants for use with loading html */
+#if LIBXML_VERSION >= 20707
+       REGISTER_LONG_CONSTANT("LIBXML_HTML_NOIMPLIED", HTML_PARSE_NOIMPLIED,           CONST_CS | CONST_PERSISTENT);
+#endif
+
+#if LIBXML_VERSION >= 20708
+       REGISTER_LONG_CONSTANT("LIBXML_HTML_NODEFDTD",  HTML_PARSE_NODEFDTD,            CONST_CS | CONST_PERSISTENT);
+#endif
+
        /* Error levels */
        REGISTER_LONG_CONSTANT("LIBXML_ERR_NONE",               XML_ERR_NONE,           CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LIBXML_ERR_WARNING",    XML_ERR_WARNING,        CONST_CS | CONST_PERSISTENT);