PHP Patch for loadHTML options
| From: | James Devine | Date: | Wed, 16 Feb 2011 23:57:03 +0000 |
| Subject: | PHP Patch for loadHTML options | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-51452@lists.php.net to get a copy of this message | ||
I've included a patch for review adding the ability to optionally pass
options to the DOMDocument::loadHTML[File] functions
diff -ru php-5.3.5.orig/ext/dom/document.c php-5.3.5.new/ext/dom/document.c
--- php-5.3.5.orig/ext/dom/document.c 2010-04-02 14:08:15.000000000 -0600
+++ php-5.3.5.new/ext/dom/document.c 2011-02-16 16:49:20.000000000 -0700
@@ -149,10 +149,12 @@
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)
@@ -2157,10 +2159,11 @@
char *source;
int source_len, refcount, ret;
htmlParserCtxtPtr ctxt;
+ int options = 0;
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 +2183,9 @@
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) {