Last active
November 22, 2019 12:10
-
-
Save remoharsono/627857888e7e0bdbb45e9223c41d0ac9 to your computer and use it in GitHub Desktop.
Sample script removing script and applet tag from HTML document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$html = "<!DOCTYPE html><html><head><title>.</title></head><body><h1>Welcome to the jungle</h1><script>var x=10;</script><script>alert('this is an alert');</script></body></html>"; | |
$config = HTMLPurifier_Config::createDefault(); | |
$config->set('HTML.ForbiddenElements', array('script','applet')); | |
$purifier = new HTMLPurifier($config); | |
$clean= $purifier->purify($html); | |
echo $clean; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment