stripslashes() with address book

Thomas -Balu- Walter list+roundcube-dev at b-a-l-u.de
Tue Jan 3 13:20:38 CET 2006


On Fri, Dec 30, 2005 at 08:16:40PM -0700, Justin Frydman wrote:
> Hi all,
> 
> I noticed that if I add a name such as O'Toole in the address book it will
> display as O\'Toole. Not sure if this is specific to my php config or not,
> or it simply needs stripslashes() function applied before outputting.

For what it's worth - I am using the following snippet I found once on
the PHP website in all my projects in a global include that is loaded
before every other action...

// strip magic quotes from Superglobals...
if ((bool) get_magic_quotes_GPC()) { // by "php Pest"
    // Really EGPCSR - Environment $_ENV, GET $_GET , POST $_POST, Cookie $_COOKIE, Server $_SERVER
    // and their HTTP_*_VARS cousins (separate arrays, not references) and $_REQUEST
    $fnStripMagicQuotes = create_function(
        '&$mData, $fnSelf',
        'if (is_array($mData)) { foreach ($mData as $mKey=>$mValue) $fnSelf($mData[$mKey], $fnSelf); return; } '.
        '$mData = stripslashes($mData);'
    );
    $fnStripMagicQuotes($_POST, $fnStripMagicQuotes); // do each set of EGPCSR as you find necessary
    $fnStripMagicQuotes($_GET, $fnStripMagicQuotes);
    $fnStripMagicQuotes($_REQUEST, $fnStripMagicQuotes);
}

magic_quotes is one of the most evil things in PHP - it should've been
dumped in Version 4, but ...

     Balu




More information about the Dev mailing list