#41339 [Opn->Bgs]: DomDocument->loadHTML eats HTML without error with multiple meta information
| From: | rrichards@php.net | Date: | Wed, 16 May 2007 11:46:16 +0000 |
| Subject: | #41339 [Opn->Bgs]: DomDocument->loadHTML eats HTML without error with multiple meta information | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112677@lists.php.net to get a copy of this message | ||
ID: 41339
Updated by: rrichards@php.net
Reported By: rasch at raschnet dot com
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Ubuntu Linux
PHP Version: 5.2.2
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Not a PHP issue - libxml2 is unable to determine the encoding to use
for output due to the bogus charset
Previous Comments:
------------------------------------------------------------------------
[2007-05-15 02:04:02] rasch at raschnet dot com
I've decided to have one more go at this bug submission. As a bit of
evidence for this bugs validity, I offer that the HTML which causes the
DOMDocument class to return no results in fact validates in the W3C
validator.
Either way, DOMDocument->saveHTML should not return an empty string.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8,
text/html; charset=utf-8"><title>Foo</title></head>
<body><p>Hello</p></body>
</html>
Thanks!
David
------------------------------------------------------------------------
[2007-05-11 01:00:54] rasch at raschnet dot com
If you can, please take another look at this.
I think parsing the HTML would be above and beyond the bug here.. In
fact, the parser _is_ parsing some of the HTML to get the charset out of
the content-type meta tag. Unfortunately, it seems if the content-type
isn't in the expected format, it's returning nothing. It's not
returning the ill-formed HTML back, but nothing.
If one alters the content-type meta tag to include just one
content-type value it will happily return the html.
------------------------------------------------------------------------
[2007-05-09 23:40:56] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The parser provided by libXML is not an HTML tag validator, it only
cares about the syntax of tags being valid.
------------------------------------------------------------------------
[2007-05-09 15:58:57] rasch at raschnet dot com
Description:
------------
In usage of symfony, our code was mistakenly producing a meta tag with
two content types. However, from what I understand it's not invalid,
but either way PHP falls on this, the DOM parser should return an error.
The current behavior is that PHP returns an empty string when calling
'$dom->saveHTML()' in the code sample below.
Reproduce code:
---------------
$dom = new DomDocument("1.0", "utf-8");
$val =$dom->loadHTML('
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8,
text/html; charset=utf-8">
</head>
<body>Hello</body></html>');
var_dump($val);
print $dom->saveHTML();
print "\n^^^ empty string\n";
Expected result:
----------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8,
text/html; charset=utf-8">
</head>
<body><p>Hello</p></body></html>
Actual result:
--------------
bool(true)
// ^^^ empty string
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41339&edit=1