Doc #61542 [Ver->Csd]: xml_parse with invalid attribute returns 1; while xmlwf throws an error

From: Date: Wed, 14 Mar 2018 16:17:56 +0000
Subject: Doc #61542 [Ver->Csd]: xml_parse with invalid attribute returns 1; while xmlwf throws an error
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15524@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61542&edit=1 ID: 61542 Updated by: cmb@php.net Reported by: Sjon at hortensius dot net Summary: xml_parse with invalid attribute returns 1; while xmlwf throws an error -Status: Verified +Status: Closed Type: Documentation Problem Package: XML related Operating System: Archlinux PHP Version: 5.3.10 Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2018-03-14 16:17:14] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=344503 Log: Fix #61542: xml_parse with invalid attribute returns 1 ------------------------------------------------------------------------ [2018-03-14 16:02:44] cmb@php.net > For as far as I can see, xml_* is based on expat. Originally, indeed. However, it is usually build against libxml2 nowadays. > Html with an invalid attribute should make xml_parse return 0, > instead of 1 ACK. And it does, if you pass TRUE to the $is_final parameter; otherwise at least the libxml2 based extension still waits for further input, and does not signal an error. So the fixed and enhanced test script would be: <?php $p = xml_parser_create('UTF-8'); $html = '<img src="http://i.mg/" title="a\"b" />'; var_dump(xml_parse($p, $html, true)); var_dump(xml_error_string(xml_get_error_code($p))); The actual result will be: int(0) string(10) "> required" The documentation[1] already states: | Entity errors are reported at the end of the data thus only if | is_final is set and TRUE. This should be generalized wrt. this issue. [1] <http://www.php.net/manual/en/function.xml-parse.php#refsect1-function.xml-parse-returnvalues> ------------------------------------------------------------------------ [2012-03-28 12:21:53] Sjon at hortensius dot net Description: ------------ Html with an invalid attribute should make xml_parse return 0, instead of 1 For as far as I can see, xml_* is based on expat. Expat supplies xmlwf, so I confirmed checked what xmlwf would return for the xml. I found that xmlwf behaves correctly. ------ [sjon@sjon-desktop ~]$ xmlwf <?xml version="1.0" encoding="UTF-8" ?> <img src="http://i.mg/" title="a\"b" /> STDIN:2:34: not well-formed (invalid token) Test script: --------------- $p = xml_parser_create('UTF-8'); $html = '<img src="http://i.mg/" title="a\"b" />'; var_dump(xml_parse($p, $html)); Expected result: ---------------- 0 Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61542&edit=1

« previous php.doc.bugs (#15524) next »