Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #2065 Problems with ' when writing PHPArray config in file
Submitted: 2004-08-05 12:43 UTC
From: sthibaudeau at sqli dot com Assigned: mansion
Status: Closed Package: Config
PHP Version: 4.3.3 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [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 &apos; 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'; ?>

Comments

 [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.