note 13939 deleted from function.get-magic-quotes-gpc by philip

From: Date: Wed, 10 Oct 2001 00:16:27 +0000
Subject: note 13939 deleted from function.get-magic-quotes-gpc by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-18756@lists.php.net to get a copy of this message
Regarding the post which suggested working around the magic quotes feature by adding some code to the top of each page which edits the $HTTP_GET_VARS, $HTTP_POST_VARS, and $HTTP_COOKIE_VARS arrays: it seems that the code provided would actually create a new problem when fixing the desired one. Say that you are writing a PHP library that you intend for others to include in their code and that you use the provided fix to work around the magic quotes. Also say that somebody else is writing a different PHP library as well and uses the same technique to fix the magic quotes problem. A third programmer will not be able to use both libraries in the same program because both libraries will strip the backslashes from these variables (which will result in legitimate backslashes being removed). I haven't tested this, but I think this could be fixed by adding this line to the code within the if{} statement: ini_set ("magic_quotes_gpc", 0); This should keep other code from attempting the same fix-up. Better yet, why not create a function called getPostVar($varname) (and corresponding functions for GET, cookie, and environment variables) which returns the actual value of the variable (with any slashes that have been added appropriately stripped)? This would also get around the hassle of making a library that works when "track vars" isn't enabled. getPostVar() would return the POST parameter as it was entered by the user without alteration. This would make things more consistent across different configurations and make writing libraries less painful (maybe it should be a core function because predictability in the way that variables are set would be a nice thing).

« previous php.notes (#18756) next »