PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Configuration » Config » Bug #2065

Problems with ' when writing PHPArray config in file

Details

Submitted2004-08-05 12:43 UTC
Fromsthibaudeau at sqli dot com
Assignedmansion
StatusClosed
PackageConfig
PHP Version4.3.3
OSWindows
Roadmaps(Not assigned)

Comments

[2004-08-05 12:43 UTC] sthibaudeau at sqli dot com

Description:
------------
I parse a xml file which contains ' characters. When rewriting it as a PHPArray there is a parse error in the generated PHP code.

Using ' doesn't solve the problem.

I solved the problem by adding addslashes call in toString() in file PHPArray.php :

line 146 : ."['".$attr."'] = '".addslashes($val)."';\n";
line 153 : $string .= "'".addslashes($obj->content)."'";
line 169 : ."['".$attr."'] = '".addslashes($val)."';\n";

Reproduce code:
---------------
// sample code
$config = new Config;
$result = $config->parseConfig($xmlFile, 'XML');
$result = $config->writeConfig($cacheFile, 'PHPArray',array('name'=>'conf'));

// xml content
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<test name="look at the ' character">another ' character</test>
</root>

// generated PHP code
<?php
$conf['root']['test']['#'] = 'another ' character';
$conf['root']['test']['@']['name'] = 'look at the ' character';
?>

[2004-08-07 10:22 UTC] bmansion at mamasam dot com

This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pear.php.net.

In case this was a pear.php.net website problem, the change will show
up on the website in short time.

Thank you for the report, and for helping us make PEAR better.