[PHP-BUG] Bug #51484 [NEW]: '--' incorrectly allowed inside comments
[email protected] ("ifland at gmail dot com") Mon, 5 Apr 2010 23:48:18 +0200 (CEST)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From:
Operating system: *
PHP version: 5.2.13
Package: XML related
Bug Type: Bug
Bug description:'--' incorrectly allowed inside comments
Description:
------------
According to the XML spec (see
http://www.w3.org/TR/2008/REC-xml-20081126/#sec-comments ), comments in XML
are not allowed to contain two hyphens in a row, which can occasionally
surface when processing poorly-formed HTML documents as input.
No suggestion is given in the spec for how to deal with the situation - we
can't turn the hyphens into entities (those aren't allowed in comments
either), but Firefox and possibly other browsers will fail to parse XML
documents with the double hyphen.
Test script:
---------------
<?php
$doc = new DOMDocument();
$doc->loadHTML("<html><body><!--comment <!--sketchy commented
comment--></body>");
header("Content-type: text/plain");
echo $doc->saveXML();
?>
Expected result:
----------------
Either a catchable error or something like this:
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><!--comment <!- -commented comment--></body></html>
Actual result:
--------------
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><!--comment <!--commented comment--></body></html>
--
Edit bug report at http://bugs.php.net/bug.php?id=51484&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51484&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51484&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51484&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51484&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51484&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51484&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51484&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51484&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51484&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51484&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51484&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51484&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51484&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51484&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51484&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51484&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51484&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51484&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51484&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51484&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51484&r=mysqlcfg