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~191^2~2122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be79a1d605ceaa31278ebd44879798073934c6a7;p=php fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) add test --- diff --git a/ext/dom/document.c b/ext/dom/document.c index 2a04666afc..7362e3b802 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1544,7 +1544,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; @@ -1581,7 +1581,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) { @@ -1695,7 +1695,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) { } } - newdoc = dom_document_parser(id, mode, source.s, options TSRMLS_CC); + newdoc = dom_document_parser(id, mode, source.s, source_len, options TSRMLS_CC); if (source_type == IS_UNICODE) { efree(source.s); diff --git a/ext/dom/tests/bug50661.phpt b/ext/dom/tests/bug50661.phpt new file mode 100644 index 0000000000..dcea2c627a --- /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-- + +