Skip to content

Instantly share code, notes, and snippets.

@do-aki
Last active December 16, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save do-aki/5360466 to your computer and use it in GitHub Desktop.
Save do-aki/5360466 to your computer and use it in GitHub Desktop.
HTML Purifier を使って html を消毒する ref: http://qiita.com/items/b7767b63d6c3d65cd3da
<?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