#48983 [Opn->Fbk]: DomDocument : saveHTMLFile wrong charset and crash
| From: | jani@php.net | Date: | Mon, 20 Jul 2009 14:53:17 +0000 |
| Subject: | #48983 [Opn->Fbk]: DomDocument : saveHTMLFile wrong charset and crash | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139968@lists.php.net to get a copy of this message | ||
ID: 48983
Updated by: jani@php.net
Reported By: php at bouchery dot fr
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
Operating System: Windows XP
PHP Version: 5.3.0
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-07-20 09:44:27] php at bouchery dot fr
Description:
------------
When using DomDocument to generate HTML. If I'm trying to add the
content-type, and generate a file with "saveHTMLfile", PHP crash and
charset is not correctly defined (Always UTF-8).
With "saveHTML", it works fine.
Reproduce code:
---------------
<?php
$doc = new DOMDocument('1.0','iso-8859-1');
$doc->formatOutput = true;
$root = $doc->createElement('html');
$root = $doc->appendChild($root);
$head = $doc->createElement('head');
$head = $root->appendChild($head);
$title = $doc->createElement('title');
$title = $head->appendChild($title);
$text = $doc->createTextNode('This is the title');
$text = $title->appendChild($text);
$meta = $doc->createElement('meta');
$meta = $head->appendChild($meta);
$meta->setAttribute('http-equiv', 'Content-Type');
$meta->setAttribute('content', 'text/html; charset=ISO-8859-1');
echo $doc->saveHTML();
$doc->saveHTMLFile('result.html');
?>
Expected result:
----------------
No crash, output is :
----
<html><head>
<title>This is the title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
</head></html>
----
And "result.html" must contains :
----
<html><head>
<title>This is the title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
</head></html>
----
Actual result:
--------------
PHP process crash
Output :
----
<html><head>
<title>This is the title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
</head></html>
----
"result.html"
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>This is the title</title>
</head></html>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48983&edit=1