From: Rob Richards Date: Wed, 6 Jan 2010 13:13:17 +0000 (+0000) Subject: fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) X-Git-Tag: php-5.4.0alpha1~476 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc1feb90343239d1a2fa2c9035eee712b6c88e32;p=php fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) add test --- diff --git a/NEWS b/NEWS index bb401046bf..8566496367 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ PHP NEWS (Ilia) - Added stream_resolve_include_path(). (Mikko) +- Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16). (Rob) - Fixed bug #50657 (copy() with an empty (zero-byte) HTTP source succeeds but returns false). (Ilia) - Fixed bug #50636 (MySQLi_Result sets values before calling constructor). 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-- + +