$HTTP_*_VARS linked to Smarty, makes problems with stripping slashes
| From: | Joscha Feth | Date: | Thu, 13 Feb 2003 19:07:06 +0000 |
| Subject: | $HTTP_*_VARS linked to Smarty, makes problems with stripping slashes | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7740@lists.php.net to get a copy of this message | ||
Hi,
This is mainly a message to the authors of Smarty, I couldn't find a place
to report bugs and suggestions.
Think of this:
In many machines, magic_quotes_gpc is enabled, if you now pass some data to
a page, it automatically adds slashes (or does not if magic_quotes is
disabled). I wrote a function to have consistency of vars passed to a page,
e.g. the function always makes sure, that the data has "magic" quotes or
not, regardless of magic_quotes_gpc enabled or disabled. You can find this
function here:
http://dev.feth.com/PHP/my_magic_quotes.phps
Comment: Please don't tell me not to change $_* because it is bad coding
style, you have the choice: either you work on $_* or you can fill up the
memory with copies of it :-D
The problem now is, that I apply this function $_POST, but Smarty still
works with the old $HTTP_POST_VARS, so the code:
$_POST = my_magic_quotes($_POST);
changes $_POST but not the $smarty.post value
$_POST["somevar"] and in a template {$smarty.post.somevar} do not have the
same value.
I now use a workaround and do:
$_POST = my_magic_quotes($_POST);
$HTTP_POST_VARS = $_POST; //~ to bad I can not pass a reference e.g.
$HTTP_POST_VARS = &$_POST;
But I think as we are on PHP version 4.3 and not > 4.1 Smarty should use $_*
where available and $HTTP_*_VARS in older versions.
Also it would be fine if the {$smarty.*} would use references instead of
copying it into the own namespace.
If you have questions or did not understand what I mean,please reply!
Greets,
Joscha