php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37934 Unable to create a new DOMDocument with a bogus encoding parameter
Submitted: 2006-06-27 19:56 UTC Modified: 2006-07-03 14:01 UTC
From: z_rules55 at hotmail dot com Assigned: rrichards (profile)
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.4 OS: Windows XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: z_rules55 at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-06-27 19:56 UTC] z_rules55 at hotmail dot com
Description:
------------
Echoing $dom->saveXML() for a freshly created DOMDocument usually yields an XML declaration, even if the DOMDocument constructor is passed a bogus XML version parameter. However, nothing (not even an error message) is printed if I pass a bogus encoding parameter.

If PHP checks to make sure that the encoding parameter is correct, then shouldn't it also check to make sure the version is correct?

Reproduce code:
---------------
$hi = new DOMDocument();
echo $hi->saveXML();
echo "\n";
$hi = new DOMDocument('1.0', 'utf-8');
echo $hi->saveXML();
echo "\n";
$hi = new DOMDocument('3.14', 'utf-8');
echo $hi->saveXML();
echo "\n";
$hi = new DOMDocument('3.14', 'lkj');
echo $hi->saveXML();
echo "\n";

Expected result:
----------------
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="3.14" encoding="utf-8"?>
<?xml version="3.14" encoding="lkj"?>

Actual result:
--------------
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="3.14" encoding="utf-8"?>
/* Nothing printed for the last line. */

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-03 14:01 UTC] rrichards@php.net
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.

document is created. error occurs when trying to serialize it with bogus encoding. libxml2 bug with its error message - will be fixed there. to see error use libxml_use_internal_errors(TRUE) and inspect the structured errors after trying to save.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC