Last active
December 16, 2015 02:09
-
-
Save do-aki/5360466 to your computer and use it in GitHub Desktop.
HTML Purifier を使って html を消毒する ref: http://qiita.com/items/b7767b63d6c3d65cd3da
This file contains 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_once('$PATH_TO_LIBRARY/HTMLPurifier.includes.php'); | |
use HTMLPurifier; | |
use HTMLPurifier_Config; | |
function sanitize($tainted_html) { | |
$config = HTMLPurifier_Config::createDefault(); | |
$config->set('Cache.SerializerPath', $PATH_TO_TEMPORARY_DIR); | |
$purifier = new HTMLPurifier($config); | |
return $purifier->purify($tainted_html); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment