RE: [PHP] HTMLSpecialchars
| From: | Jason Murray | Date: | Thu, 19 Apr 2001 05:11:49 +0000 |
| Subject: | RE: [PHP] HTMLSpecialchars | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-49322@lists.php.net to get a copy of this message | ||
> I'm having a problem with HTMLspecialchars and nl2br interfearing with
> each other. Obviously, I'm trying to stop malicous HTML/scripts from
> being entered into my guestbook, but I'm also trying to add spacing.
> nl2br adds <br>, but HTMLspecialchars tells it to not show that.
>
> Anyways, I'm sure there is a way around this. All help is welcome, so
> I'm eager for replys. Thank you very, very much!
<?
// Malicious content (don't laugh, I've had this happen!)
$content = "<FRAMESET>\n"
." <FRAME SRC='whee'>\n"
." <FRAME SRC='whee1'>\n"
."</FRAME>";
// Convert < to <, etc
$output = htmlentities($content);
// change newlines to <BR>s
$output = nl2br($output);
?>
Jason