Bug #52987 [Opn->Fbk]: Losing amperstamp with xml_parse_into_struct function

From: Date: Thu, 07 Oct 2010 02:13:02 +0000
Subject: Bug #52987 [Opn->Fbk]: Losing amperstamp with xml_parse_into_struct function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154970@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52987&edit=1

 ID:                 52987
 Updated by:         aharvey@php.net
 Reported by:        andre dot boily at mcccf dot gouv dot qc dot ca
 Summary:            Losing amperstamp with xml_parse_into_struct
                     function
-Status:             Open
+Status:             Feedback
 Type:               Bug
-Package:            Systems problem
+Package:            XML related
 Operating System:   Linux - SUSE
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works as expected for me on a current 5.2 build: the relevant bit of
output is:


  [3]=>
  array(4) {
    ["tag"]=>
    string(3) "URL"
    ["type"]=>
    string(8) "complete"
    ["level"]=>
    int(3)
    ["value"]=>
    string(37) "http://www.test.com?param1=1&param2=2"
  }

Note the decoded ampersand in the value.


Previous Comments:
------------------------------------------------------------------------
[2010-10-04 22:05:58] andre dot boily at mcccf dot gouv dot qc dot ca

Description:
------------
Running version: 5.2.14

After a lot of tests and reading, I experimenting a problem since we've
upgraded the PHP version from 5.2.6 to 5.2.14

The problem is when i'm trying to put a xml string in a array, i'm
loosing the amperstamp (&)characters in the output of
xml_parse_into_struct function.

Maybe it's a new features that I can't understand, but it look like a
Bug.

Note: The Bug is in the URL tag in my XML structure.

Test script:
---------------
<?php

$xmlValues  = array();
$xmlIndex   = array();

$parser     = xml_parser_create("");

// Case management option
xml_parser_set_option(
$parser,
XML_OPTION_CASE_FOLDING,
1
);
        
// White space management option
xml_parser_set_option(
$parser,
XML_OPTION_SKIP_WHITE,
            0
);
		
xml_parser_set_option(
$parser,
XML_OPTION_TARGET_ENCODING,
"UTF-8"
);



$data = "<?xml version='1.0'
encoding='utf-8'?><COLLECTION><DOCUMENT><TITRE>Some
Title</TITRE><URL>http://www.test.com?param1=1&amp;param2=2</URL><DATE>1285352820</DATE></DOCUMENT></COLLECTION>";

xml_parse_into_struct(
            $parser,
            $data,
            $xmlValues,
            $xmlIndex
        );
		
var_dump($xmlValues);

?>

Expected result:
----------------
array(6) { [0]=>  array(3) { ["tag"]=>  string(10) "COLLECTION"
["type"]=>  string(4) "open" ["level"]=>  int(1) } [1]=> 
array(3) {
["tag"]=>  string(8) "DOCUMENT" ["type"]=>  string(4)
"open" ["level"]=>
 int(2) } [2]=>  array(4) { ["tag"]=>  string(5) "TITRE"
["type"]=> 
string(8) "complete" ["level"]=>  int(3) ["value"]=>  string(10)
"Some
Title" } [3]=>  array(4) { ["tag"]=>  string(3) "URL"
["type"]=> 
string(8) "complete" ["level"]=>  int(3) ["value"]=>  string(36)
"http://www.test.com?param1=1&amp;param2=2"
} [4]=>  array(3) {
["tag"]=>  string(8) "DOCUMENT" ["type"]=>  string(5)
"close"
["level"]=>  int(2) } [5]=>  array(3) { ["tag"]=>  string(10)
"COLLECTION" ["type"]=>  string(5) "close" ["level"]=>
 int(1) } } 

Actual result:
--------------
array(6) { [0]=>  array(3) { ["tag"]=>  string(10) "COLLECTION"
["type"]=>  string(4) "open" ["level"]=>  int(1) } [1]=> 
array(3) {
["tag"]=>  string(8) "DOCUMENT" ["type"]=>  string(4)
"open" ["level"]=>
 int(2) } [2]=>  array(4) { ["tag"]=>  string(5) "TITRE"
["type"]=> 
string(8) "complete" ["level"]=>  int(3) ["value"]=>  string(10)
"Some
Title" } [3]=>  array(4) { ["tag"]=>  string(3) "URL"
["type"]=> 
string(8) "complete" ["level"]=>  int(3) ["value"]=>  string(36)
"http://www.test.com?param1=1param2=2" }
[4]=>  array(3) { ["tag"]=> 
string(8) "DOCUMENT" ["type"]=>  string(5) "close"
["level"]=>  int(2) }
[5]=>  array(3) { ["tag"]=>  string(10) "COLLECTION"
["type"]=> 
string(5) "close" ["level"]=>  int(1) } } 


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52987&edit=1


Thread (1 message)

  • aharvey@php.net
  • Unknown Message
    • aharvey@php.net
« previous php.bugs (#154970) next »