Jump to content

Sanitizing all input this way


morpheuz

Recommended Posts

I've been reading articles on security and things for awhile now and I wonder if just refusing to allow undersired chars to be submitted through forms via exp is enough for the job, ie. reject: <>|{}[];:' "?/\+=()*&^%$#@!~` and only allow A-Z and 0-9?

If anything submitted contains the above in a $_POST/$_GET, etc. kill the script and force the user to resubmit the data with the undesired removed. I guess a str replace code to compensate for not being able to use punctuation marks in text fields intended for messages would have to be present..but for login, search, urls, etc. I'd want it to stay free of them and the rest.

Is this too much? Not enough? Comments?
Link to comment
https://forums.phpfreaks.com/topic/10919-sanitizing-all-input-this-way/
Share on other sites

[!--quoteo(post=379067:date=Jun 1 2006, 09:03 AM:name=morpheuz)--][div class=\'quotetop\']QUOTE(morpheuz @ Jun 1 2006, 09:03 AM) [snapback]379067[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] bump
[/quote]
Do you mean like this
[code]$never_in_pswd=array(" ","\"","!","@","$","%","^","(",")",":",";",",","|","<",">","=","'");[/code]
Validate like this
[code]$i=0;
while ( $i < strlen($p_word))
{if (in_array($p_word[$i],$never_in_pswd))
    { $e_message="\"$p_word[$i]\" is not allowed in a password";}[/code]
Works for me [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

mind you there is a more code needed, but that just the part you a looking for

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.