mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
Add sanity check against ze1_compatibility_mode.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
c9e7ffc172
commit
598c5b60c9
1
INSTALL
1
INSTALL
@ -18,6 +18,7 @@ with these contents.
|
||||
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and
|
||||
up. It has no core dependencies with other libraries. PHP
|
||||
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
|
||||
HTML Purifier is not compatible with zend.ze1_compatibility_mode.
|
||||
|
||||
These optional extensions can enhance the capabilities of HTML Purifier:
|
||||
|
||||
|
4
NEWS
4
NEWS
@ -18,6 +18,10 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
- Fix removal of id attributes under certain conditions by ensuring
|
||||
armor attributes are preserved when recreating tags.
|
||||
- Check if schema.ser was corrupted.
|
||||
- Check if zend.ze1_compatibility_mode is on, and error out if it is.
|
||||
This safety check is only done for HTMLPurifier.auto.php; if you
|
||||
are using standalone or the specialized includes files, you're
|
||||
expected to know what you're doing.
|
||||
|
||||
4.2.0, released 2010-09-15
|
||||
! Added %Core.RemoveProcessingInstructions, which lets you remove
|
||||
|
@ -3,6 +3,7 @@
|
||||
/**
|
||||
* @file
|
||||
* Convenience file that registers autoload handler for HTML Purifier.
|
||||
* It also does some sanity checks.
|
||||
*/
|
||||
|
||||
if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
|
||||
@ -18,4 +19,8 @@ if (function_exists('spl_autoload_register') && function_exists('spl_autoload_un
|
||||
}
|
||||
}
|
||||
|
||||
if (ini_get('zend.ze1_compatibility_mode')) {
|
||||
trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
14
tests/HTMLPurifier/PHPT/ze1_compatibility_mode.phpt
Normal file
14
tests/HTMLPurifier/PHPT/ze1_compatibility_mode.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Error with zend.ze1_compatibility_mode test
|
||||
--PRESKIPIF--
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
||||
echo 'skip - ze1_compatibility_mode not present in PHP 5.3 or later';
|
||||
}
|
||||
--INI--
|
||||
zend.ze1_compatibility_mode = 1
|
||||
--FILE--
|
||||
<?php
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
--EXPECTF--
|
||||
Fatal error: HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off in %s
|
36
tests/PHPT/Section/PRESKIPIF.php
Normal file
36
tests/PHPT/Section/PRESKIPIF.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class PHPT_Section_PRESKIPIF implements PHPT_Section_RunnableBefore
|
||||
{
|
||||
private $_data = null;
|
||||
private $_runner_factory = null;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
$this->_runner_factory = new PHPT_CodeRunner_Factory();
|
||||
}
|
||||
|
||||
public function run(PHPT_Case $case)
|
||||
{
|
||||
// @todo refactor this code into PHPT_Util class as its used in multiple places
|
||||
$filename = dirname($case->filename) . '/' . basename($case->filename, '.php') . '.skip.php';
|
||||
|
||||
// @todo refactor to PHPT_CodeRunner
|
||||
file_put_contents($filename, $this->_data);
|
||||
$runner = $this->_runner_factory->factory($case);
|
||||
$runner->ini = "";
|
||||
$response = $runner->run($filename)->output;
|
||||
unlink($filename);
|
||||
|
||||
if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
|
||||
$message = !empty($matches[2]) ? $matches[2] : '';
|
||||
throw new PHPT_Case_VetoException($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPriority()
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user