Re: security in guest book and user forums
| From: | Tularis | Date: | Sat, 04 Jan 2003 18:45:20 +0000 |
| Subject: | Re: security in guest book and user forums | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130246@lists.php.net to get a copy of this message | ||
most forums do this
<?php
htmlentities($input);
--save input
-- get output
if($html == 'on'){
$output = hymlentities_decode($output);
}
print($output);
exit();
?>
Seraphim wrote:
Anders Thoresson wrote:I've seen both guest books and user forums "hacked" by users who enter javascript or other code, and that way redirects vistors to other sites or do other unwelcome things. What expressions should I look for and not allow in my forms?I use the htmlspecialchars() function to disable all html. This function basically puts a '\' in front of eacht html character and thus disables all html. You may not want to do this if you want to allow, for example <b></b> or other friendly html. If so you can use a regex to disable the <script> or </table> tags. Now that I think about it, it might be better to disable all html and later enable <i>,<b> etc (or define your own, like a lot of forums seem to do). -Peter