Re: Blocking Javascript using PHP3
| From: | Chris Moyer | Date: | Tue, 23 May 2000 13:51:34 +0000 |
| Subject: | Re: Blocking Javascript using PHP3 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-353@lists.php.net to get a copy of this message | ||
On Tue, May 23, 2000 at 12:41:00PM +0100, Simon Steed wrote:
> Hi,
> I have a MySQL database backend that I am using as a tips database with the
> admin/searching etc carried out by a PHP3 frontend. As I am allowing the
> users to insert html into the tips to make formatting easier, I want to
> block the use of javascript etc so that malicious code is avoided. How
> would I do this?
>
> Also on a similar note, how would I do the same to block rogue php code?
> The resulting file extension will be .php3 as there is other formatting in
> there.
>
PHP includes a very nice strip_tags() function that allows you to strip
HTML and PHP tags very easily. It will defaultly remove all HTML tags,
but you could specifically allow certain tags, BR, HR, P, LI, etc.
You could also approach from the other direction and do some ereg's to
remove only specific tags, such as SCRIPT.
> Regards
>
> Simon Steed
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
--
Chris Moyer -- cdmoyer@email.com