Re: Removing security-problematic chars from strings
| From: | Adam i Agnieszka Gasiorowski FNORD | Date: | Fri, 21 Nov 2003 10:38:33 +0000 |
| Subject: | Re: Removing security-problematic chars from strings | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170539@lists.php.net to get a copy of this message | ||
Troy S wrote:
> What is the best way to remove the characters from strings that may
> cause security problems? Namely, `, ', ", <, >, \ and all non-printing
> strings. Did I miss any? Thanks.
Do it the other way, allow only characters
you know are safe and strip the rest. Use, for
example, a preg_replace pattern with negated
character range. Put all the allowed characters
into this range and '' as replace text.
$query = preg_replace('{[^' . preg_quote(ALLOWED_CHARS) . ']}', '',
$query);
, where ALLOWED_CHARS is a constant containing...
allowed characters :8].
--
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info { iWanToDie } WiNoNa ) (
http://szatanowskie-ladacznice.0-700.pl
foReVeR( * )
Poznaj jej zwiewne kształty... http://www.opera.com 007