From: Pierre Joye Date: Wed, 3 Feb 2010 18:41:27 +0000 (+0000) Subject: fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) X-Git-Tag: php-5.3.2RC2~82 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a033ab55f329b8697c15040e864330c5815ee35d;p=php fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) --- diff --git a/ext/dom/document.c b/ext/dom/document.c index 8dac8cfa1b..8b212ed03e 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1542,7 +1542,7 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p } /* }}} */ -static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int options TSRMLS_DC) /* {{{ */ +static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int source_len, int options TSRMLS_DC) /* {{{ */ { xmlDocPtr ret; xmlParserCtxtPtr ctxt = NULL; @@ -1579,7 +1579,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int optio } } else { - ctxt = xmlCreateDocParserCtxt(source); + ctxt = xmlCreateMemoryParserCtxt(source, source_len); } if (ctxt == NULL) { @@ -1682,7 +1682,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) { RETURN_FALSE; } - newdoc = dom_document_parser(id, mode, source, options TSRMLS_CC); + newdoc = dom_document_parser(id, mode, source, source_len, options TSRMLS_CC); if (!newdoc) RETURN_FALSE; diff --git a/ext/dom/tests/bug50661.phpt b/ext/dom/tests/bug50661.phpt new file mode 100644 index 0000000000..3760db9b4e --- /dev/null +++ b/ext/dom/tests/bug50661.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #50661 (DOMDocument::loadXML does not allow UTF-16). +--SKIPIF-- + +--FILE-- +loadXML($data); +echo $dom->saveXML(); + +?> +--EXPECT-- + +