What chars are considered safe?
From: Derek Fountain (nospam_at_example.com)
Date: 02/28/05
- Next message: Adam: "PHP Script - Efficient use of execution time"
- Previous message: Shamrock: "Re: Use of Distinct ?"
- Next in thread: John Dunlop: "Re: What chars are considered safe?"
- Reply: John Dunlop: "Re: What chars are considered safe?"
- Reply: Michael Fesser: "Re: What chars are considered safe?"
- Reply: Chung Leong: "Re: What chars are considered safe?"
- Reply: NC: "Re: What chars are considered safe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Feb 2005 08:13:56 +0800
I was just writing a sanitisation route for a bit of user input. The data is
an English text description of a product, and will go into a DB, then back
out to other user's browsers.
As per normal practise, I was working on the basis of leaving in all
characters that I considered safe and stripping out everything else. This
led me to think of what characters are actually safe, given that the user
will want to be able to use at least basic punctuation, currency symbols
and so on. Avoiding < and > seemed obvious, but most other things have a
use I think.
My current line looks like this:
$data = preg_replace( '/[^\s\w\d@"\'()[]{}:#~!$%&*_-+.,]/', "", $data );
(Note that's a list of chars that are *not* to be replaced.) Are any of
these dangerous? Or have I left out some that are harmless and should be in
there?
-- The email address used to post is a spam pit. Contact me at http://www.derekfountain.org : <a href="http://www.derekfountain.org/">Derek Fountain</a>
- Next message: Adam: "PHP Script - Efficient use of execution time"
- Previous message: Shamrock: "Re: Use of Distinct ?"
- Next in thread: John Dunlop: "Re: What chars are considered safe?"
- Reply: John Dunlop: "Re: What chars are considered safe?"
- Reply: Michael Fesser: "Re: What chars are considered safe?"
- Reply: Chung Leong: "Re: What chars are considered safe?"
- Reply: NC: "Re: What chars are considered safe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|