NYCPHP Meetup

NYPHP.org

[nycphp-talk] Addcslashes bug

Rob Marscher rmarscher at beaffinitive.com
Tue Feb 12 13:54:39 EST 2008


Cliff Hirsch wrote:
> I had a very strange error, catastrophic yesterday.
> PEAR Config writes a PHP array file like so:
>
> <?php
>
> $config = array(
>  param1 => 'value',
>  param2 => 'val'ue2',
>  ...
> );
>
> The writing process is what failed to generate the backslash. The  
> parsing
> happens on subsequent page loads. The strange thing is that I have  
> not been
> able to reproduce the error and I looked the the PEAR Config code,  
> which
> does use addcslashes($val, "\\'").
> addcslashes failed to put a slash in front of a single quote. Can  
> anyone imagine how this could happen? Is it possible it didn’t catch  
> a multi-byte character? Am I back to charset issues?
Yeah... weird.  I'm not terribly familiar with addcslashes or PEAR  
Config... but I do write a config file in a similar way to you...  
except I use smarty to write it and use the {$var|escape:'quotes'}  
modifier.  I'm looking at the code for that modifier and it uses this  
odd regular expression:

preg_replace("%(?<!\\\\)'%", "\\'", $string);

> Unfortunately, I can’t reproduce the error.
You tried a resave of your config with the same exact settings and it  
worked?  I dunno.  Is there anything else that could possible modify  
your config file?  Or anyway that PEAR Config can write something  
without passing it through addcslashes?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080212/8f8dae8f/attachment.html>


More information about the talk mailing list