php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38354 Unwanted reformatting of XML when using AsXML
Submitted: 2006-08-06 08:47 UTC Modified: 2006-08-06 19:40 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rowanjl at gmail dot com Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rowanjl at gmail dot com
New email:
PHP Version: OS:

 

 [2006-08-06 08:47 UTC] rowanjl at gmail dot com
Description:
------------
When using AsXML on an element which contains children, the returned source is different from the original XML source. This prevents any direct comparison between the two.

Reproduce code:
---------------
<?php
	
	Header("Content-type: text/plain");
	
	$XML = SimpleXML_Load_String('<code>
	<a href="javascript:alert(\'1\');"><strong>Item Two</strong></a>
</code>');
	
	foreach ($XML->XPath("//*") as $Element) {
		echo Trim($Element->AsXML()), "\n--------------------\n";
	}
	
?>

Expected result:
----------------
<?xml version="1.0"?>
<code>
	<a href="javascript:alert('1');"><strong>Item Two</strong></a>
</code>
--------------------
<a href="javascript:alert('1');">
  <strong>Item Two</strong>
</a>
--------------------
<strong>Item Two</strong>
--------------------

Actual result:
--------------
<?xml version="1.0"?>
<code>
	<a href="javascript:alert('1');"><strong>Item Two</strong></a>
</code>
--------------------
<a href="javascript:alert('1');"><strong>Item Two</strong></a>
--------------------
<strong>Item Two</strong>
--------------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-06 11:39 UTC] rowanjl at gmail dot com
The expected and actual results are reversed, I'd correct that if I could, sorry for the mix up.
 [2006-08-06 19:40 UTC] chregu@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in HEAD and PHP_5_2 branch
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Feb 01 08:01:29 2025 UTC