From:             php at bouchery dot fr
Operating system: Windows XP
PHP version:      5.3.0
PHP Bug Type:     DOM XML related
Bug description:  DomDocument : saveHTMLFile wrong charset and crash

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 bug report at http://bugs.php.net/?id=48983&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=48983&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=48983&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=48983&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=48983&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=48983&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48983&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48983&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48983&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48983&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48983&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48983&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48983&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48983&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48983&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48983&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48983&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48983&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48983&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48983&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48983&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48983&r=mysqlcfg

Reply via email to