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

From: Date: Wed, 14 Mar 2018 16:02:47 +0000
Subject: Bug->Doc #61542 [Opn->Ver]: 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-15523@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: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: XML related Operating System: Archlinux PHP Version: 5.3.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > 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> Previous Comments: ------------------------------------------------------------------------ [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 (#15523) next »