mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-21 21:11:51 +00:00
Changes to make HipHop compile HTML Purifier.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
63a854ee5d
commit
4f8004f5d3
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,3 +18,6 @@ docs/doxygen*
|
||||
*.phpt.php
|
||||
*.phpt.skip.php
|
||||
*.htmlt.ini
|
||||
|
||||
hphp-cache
|
||||
hphp-out
|
||||
|
2
compile.sh
Executable file
2
compile.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
hphp --log 3 --file-cache hphp-cache --generate-ffi 1 -o hphp-out -k 1 library/HTMLPurifier.stub.php
|
@ -56,10 +56,7 @@ require 'HTMLPurifier/Length.php';
|
||||
require 'HTMLPurifier/Lexer.php';
|
||||
require 'HTMLPurifier/PercentEncoder.php';
|
||||
require 'HTMLPurifier/PropertyList.php';
|
||||
require 'HTMLPurifier/PropertyListIterator.php';
|
||||
require 'HTMLPurifier/Strategy.php';
|
||||
require 'HTMLPurifier/StringHash.php';
|
||||
require 'HTMLPurifier/StringHashParser.php';
|
||||
require 'HTMLPurifier/TagTransform.php';
|
||||
require 'HTMLPurifier/Token.php';
|
||||
require 'HTMLPurifier/TokenFactory.php';
|
||||
@ -207,4 +204,3 @@ require 'HTMLPurifier/URIScheme/mailto.php';
|
||||
require 'HTMLPurifier/URIScheme/news.php';
|
||||
require 'HTMLPurifier/URIScheme/nntp.php';
|
||||
require 'HTMLPurifier/VarParser/Flexible.php';
|
||||
require 'HTMLPurifier/VarParser/Native.php';
|
||||
|
@ -50,10 +50,7 @@ require_once $__dir . '/HTMLPurifier/Length.php';
|
||||
require_once $__dir . '/HTMLPurifier/Lexer.php';
|
||||
require_once $__dir . '/HTMLPurifier/PercentEncoder.php';
|
||||
require_once $__dir . '/HTMLPurifier/PropertyList.php';
|
||||
require_once $__dir . '/HTMLPurifier/PropertyListIterator.php';
|
||||
require_once $__dir . '/HTMLPurifier/Strategy.php';
|
||||
require_once $__dir . '/HTMLPurifier/StringHash.php';
|
||||
require_once $__dir . '/HTMLPurifier/StringHashParser.php';
|
||||
require_once $__dir . '/HTMLPurifier/TagTransform.php';
|
||||
require_once $__dir . '/HTMLPurifier/Token.php';
|
||||
require_once $__dir . '/HTMLPurifier/TokenFactory.php';
|
||||
@ -201,4 +198,3 @@ require_once $__dir . '/HTMLPurifier/URIScheme/mailto.php';
|
||||
require_once $__dir . '/HTMLPurifier/URIScheme/news.php';
|
||||
require_once $__dir . '/HTMLPurifier/URIScheme/nntp.php';
|
||||
require_once $__dir . '/HTMLPurifier/VarParser/Flexible.php';
|
||||
require_once $__dir . '/HTMLPurifier/VarParser/Native.php';
|
||||
|
8
library/HTMLPurifier.stub.php
Normal file
8
library/HTMLPurifier.stub.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier.includes.php';
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
if (isset($argv[1])) $config->loadIni($argv[1]);
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify(file_get_contents('php://stdin'));
|
@ -30,17 +30,6 @@ if (!defined('PHP_EOL')) {
|
||||
class HTMLPurifier_Bootstrap
|
||||
{
|
||||
|
||||
/**
|
||||
* Autoload function for HTML Purifier
|
||||
* @param $class Class to load
|
||||
*/
|
||||
public static function autoload($class) {
|
||||
$file = HTMLPurifier_Bootstrap::getPath($class);
|
||||
if (!$file) return false;
|
||||
require HTMLPURIFIER_PREFIX . '/' . $file;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path for a specific class.
|
||||
*/
|
||||
@ -57,42 +46,6 @@ class HTMLPurifier_Bootstrap
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Pre-registers" our autoloader on the SPL stack.
|
||||
*/
|
||||
public static function registerAutoload() {
|
||||
$autoload = array('HTMLPurifier_Bootstrap', 'autoload');
|
||||
if ( ($funcs = spl_autoload_functions()) === false ) {
|
||||
spl_autoload_register($autoload);
|
||||
} elseif (function_exists('spl_autoload_unregister')) {
|
||||
$compat = version_compare(PHP_VERSION, '5.1.2', '<=') &&
|
||||
version_compare(PHP_VERSION, '5.1.0', '>=');
|
||||
foreach ($funcs as $func) {
|
||||
if (is_array($func)) {
|
||||
// :TRICKY: There are some compatibility issues and some
|
||||
// places where we need to error out
|
||||
$reflector = new ReflectionMethod($func[0], $func[1]);
|
||||
if (!$reflector->isStatic()) {
|
||||
throw new Exception('
|
||||
HTML Purifier autoloader registrar is not compatible
|
||||
with non-static object methods due to PHP Bug #44144;
|
||||
Please do not use HTMLPurifier.autoload.php (or any
|
||||
file that includes this file); instead, place the code:
|
||||
spl_autoload_register(array(\'HTMLPurifier_Bootstrap\', \'autoload\'))
|
||||
after your own autoloaders.
|
||||
');
|
||||
}
|
||||
// Suprisingly, spl_autoload_register supports the
|
||||
// Class::staticMethod callback format, although call_user_func doesn't
|
||||
if ($compat) $func = implode('::', $func);
|
||||
}
|
||||
spl_autoload_unregister($func);
|
||||
}
|
||||
spl_autoload_register($autoload);
|
||||
foreach ($funcs as $func) spl_autoload_register($func);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@ -83,20 +83,6 @@ class HTMLPurifier_Generator
|
||||
$html .= $this->generateFromToken($tokens[$i]);
|
||||
}
|
||||
|
||||
// Tidy cleanup
|
||||
if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) {
|
||||
$tidy = new Tidy;
|
||||
$tidy->parseString($html, array(
|
||||
'indent'=> true,
|
||||
'output-xhtml' => $this->_xhtml,
|
||||
'show-body-only' => true,
|
||||
'indent-spaces' => 2,
|
||||
'wrap' => 68,
|
||||
), 'utf8');
|
||||
$tidy->cleanRepair();
|
||||
$html = (string) $tidy; // explicit cast necessary
|
||||
}
|
||||
|
||||
// Normalize newlines to system defined value
|
||||
$nl = $this->config->get('Output.Newline');
|
||||
if ($nl === null) $nl = PHP_EOL;
|
||||
|
@ -153,7 +153,11 @@ class HTMLPurifier_LanguageFactory
|
||||
$filename = $this->dir . '/Language/messages/en.php';
|
||||
$cache = array();
|
||||
} else {
|
||||
include $filename;
|
||||
if ($code == "en") {
|
||||
include "Language/messages/en.php";
|
||||
} else {
|
||||
trigger_error("unsupported language", E_USER_ERROR);
|
||||
}
|
||||
$cache = compact($this->keys);
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,6 @@ class HTMLPurifier_Lexer
|
||||
case 'DirectLex':
|
||||
$inst = new HTMLPurifier_Lexer_DirectLex();
|
||||
break;
|
||||
case 'PH5P':
|
||||
$inst = new HTMLPurifier_Lexer_PH5P();
|
||||
break;
|
||||
default:
|
||||
throw new HTMLPurifier_Exception("Cannot instantiate unrecognized Lexer type " . htmlspecialchars($lexer));
|
||||
}
|
||||
|
@ -29,7 +29,12 @@ $exclude_dirs = array(
|
||||
$exclude_files = array(
|
||||
'HTMLPurifier/Lexer/PEARSax3.php',
|
||||
'HTMLPurifier/Lexer/PH5P.php',
|
||||
'HTMLPurifier/VarParser/Native.php',
|
||||
'HTMLPurifier/Printer.php',
|
||||
'HTMLPurifier/StringHashParser.php',
|
||||
'HTMLPurifier/StringHash.php',
|
||||
'HTMLPurifier/ConfigSchema/InterchangeBuilder.php',
|
||||
'HTMLPurifier/PropertyListIterator.php',
|
||||
);
|
||||
|
||||
// Determine what files need to be included:
|
||||
|
Loading…
Reference in New Issue
Block a user