mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-03 20:58:11 +02:00
Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a617e55bc6 | ||
|
3060a5606c | ||
|
b4ec8c8036 | ||
|
06b3fc4cf4 | ||
|
c6ca293eab | ||
|
ab2887e423 | ||
|
029d1df5e3 | ||
|
b88fcd180c | ||
|
83ab08bc1a | ||
|
2739fa5462 | ||
|
b91833877a | ||
|
abba77a80b | ||
|
7cfc44654a | ||
|
8c153eef3a | ||
|
524cd08a59 | ||
|
5a90c92d83 | ||
|
f03e1a2c48 | ||
|
a93250f251 | ||
|
5a8e48d672 | ||
|
cb5a742574 | ||
|
ff41146439 | ||
|
aa83689188 | ||
|
3d15f5253b | ||
|
21e32042e9 | ||
|
ce0ccc4bff | ||
|
ab7bbefe8a | ||
|
0f7b138aaf | ||
|
4b6b3b31e8 | ||
|
5a01e6535d | ||
|
b74425bee5 | ||
|
39068e6d08 | ||
|
b81690c17e | ||
|
4005ffd563 | ||
|
89b3fe431e | ||
|
3cb77da11d | ||
|
c1167edbf1 | ||
|
c7b5148c4f | ||
|
f8c830de12 | ||
|
0737a6e916 | ||
|
d85d39da45 | ||
|
f33d1f8e99 | ||
|
6d6d88512a | ||
|
bb7ad66526 | ||
|
64baeda65c | ||
|
67c3798922 | ||
|
df64746caa | ||
|
ab9c9f30fd | ||
|
5988f29583 | ||
|
ce0ede24de | ||
|
17f80cd74b | ||
|
e11f7c9802 | ||
|
d21213e0d3 | ||
|
9b3f856fb9 |
12
.travis.yml
12
.travis.yml
@@ -1,11 +1,17 @@
|
||||
language: php
|
||||
php:
|
||||
- '5.3'
|
||||
- '5.4'
|
||||
- '5.5'
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4snapshot'
|
||||
matrix:
|
||||
include:
|
||||
- php: '5.4'
|
||||
dist: trusty
|
||||
- php: '5.5'
|
||||
dist: trusty
|
||||
before_script:
|
||||
- git clone --depth=50 https://github.com/ezyang/simpletest.git
|
||||
- cp test-settings.travis.php test-settings.php
|
||||
|
2
Doxyfile
2
Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME = HTMLPurifier
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.9.3
|
||||
PROJECT_NUMBER = 4.12.0
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
36
INSTALL
36
INSTALL
@@ -15,7 +15,7 @@ with these contents.
|
||||
---------------------------------------------------------------------------
|
||||
1. Compatibility
|
||||
|
||||
HTML Purifier is PHP 5 and PHP 7, and is actively tested from PHP 5.0.5
|
||||
HTML Purifier is PHP 5 and PHP 7, and is actively tested from PHP 5.3
|
||||
and up. It has no core dependencies with other libraries.
|
||||
|
||||
These optional extensions can enhance the capabilities of HTML Purifier:
|
||||
@@ -101,31 +101,6 @@ Autoload compatibility
|
||||
autoloader, but there are some cases where you will need to change
|
||||
your own code to accomodate HTML Purifier. These are those cases:
|
||||
|
||||
PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload
|
||||
Because spl_autoload_register() doesn't exist in early versions
|
||||
of PHP 5, HTML Purifier has no way of adding itself to the autoload
|
||||
stack. Modify your __autoload function to test
|
||||
HTMLPurifier_Bootstrap::autoload($class)
|
||||
|
||||
For example, suppose your autoload function looks like this:
|
||||
|
||||
function __autoload($class) {
|
||||
require str_replace('_', '/', $class) . '.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
A modified version with HTML Purifier would look like this:
|
||||
|
||||
function __autoload($class) {
|
||||
if (HTMLPurifier_Bootstrap::autoload($class)) return true;
|
||||
require str_replace('_', '/', $class) . '.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
Note that there *is* some custom behavior in our autoloader; the
|
||||
original autoloader in our example would work for 99% of the time,
|
||||
but would fail when including language files.
|
||||
|
||||
AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED
|
||||
spl_autoload_register() has the curious behavior of disabling
|
||||
the existing __autoload() handler. Users need to explicitly
|
||||
@@ -138,11 +113,6 @@ Autoload compatibility
|
||||
|
||||
spl_autoload_register('__autoload')
|
||||
|
||||
Users should also be on guard if they use a version of PHP previous
|
||||
to 5.1.2 without an autoloader--HTML Purifier will define __autoload()
|
||||
for you, which can collide with an autoloader that was added by *you*
|
||||
later.
|
||||
|
||||
|
||||
For better performance
|
||||
----------------------
|
||||
@@ -204,9 +174,7 @@ For advanced users
|
||||
HTMLPurifier.autoload.php
|
||||
Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class).
|
||||
|
||||
You can do these operations by yourself--in fact, you must modify your own
|
||||
autoload handler if you are using a version of PHP earlier than PHP 5.1.2
|
||||
(See "Autoload compatibility" above).
|
||||
You can do these operations by yourself, if you like.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
@@ -11,7 +11,7 @@ pied de page, mais je recommande de lire le document.
|
||||
|
||||
1. Compatibilité
|
||||
|
||||
HTML Purifier fonctionne avec PHP 5. PHP 5.0.5 est la dernière version testée.
|
||||
HTML Purifier fonctionne avec PHP 5. PHP 5.3 est la dernière version testée.
|
||||
Il ne dépend pas d'autres librairies.
|
||||
|
||||
Les extensions optionnelles sont iconv (généralement déjà installée) et tidy
|
||||
|
48
NEWS
48
NEWS
@@ -9,6 +9,54 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
. Internal change
|
||||
==========================
|
||||
|
||||
4.12.0, released 2019-10-27
|
||||
! PHP 7.4 is supported, thank you Witold Wasiczko, Mateuz Turcza and
|
||||
Edi Modrić
|
||||
- PHPDocs for HTMLModule::addElement() and Bool attr are fixed (thanks
|
||||
Mateusz)
|
||||
|
||||
4.11.0, released 2019-07-14
|
||||
# SafeScripting now matches case-sensitively against its whitelist (previously it was
|
||||
case-insensitive.) Thanks Dimitri Gritsajuk <gritsajuk.dimitri@gmail.com>
|
||||
for reporting.
|
||||
! New directive %Core.AllowParseManyTags which allows parsing of many nested tags.
|
||||
Thanks M. Suzuki <msuzuki1986@gmail.com> for contributing the patch.
|
||||
! purifyArray now supports multidimensional arrays. Thanks
|
||||
Sandro Miguel Marques <sandromiguel@sandromiguel.com> for contributing this patch.
|
||||
! initial and inherit settings available for width, height, and the min-/max-
|
||||
versions thereof. Thanks Michael Kliewe <info@phpgansta.de> for contributing
|
||||
this patch.
|
||||
! More color names are supported. Thanks Daijobou for contributing.
|
||||
- Compatibility fixes for PHP 7.3, including new CI for PHP 7.3
|
||||
(thank you Lukas Neumann <lksnmnn@gmail.com>) and removal of
|
||||
reserved words in our constants (thanks Darko Hrgovic <darko@darkodev.com>
|
||||
- Compatibility fixes for HHVM. Thanks Mateusz Turcza for contributing
|
||||
this fix.
|
||||
- HTML Purifier now never defines __autoload, fixing #196. Thanks
|
||||
Michael Kliewe for reporting.
|
||||
- In some situations, Config.php would report an undefined index: class
|
||||
error; this has been fixed. Thanks DiLong Fa for contributing
|
||||
this fix.
|
||||
- We no longer produce <script /> tags; we always explicitly write
|
||||
out the open and close tag. Thanks Dimitri Gritsajuk
|
||||
<gritsajuk.dimitri@gmail.com> for contributing this fix.
|
||||
- Better compatibility when IDNA constants are not present. Thanks
|
||||
Mateusz Turcza <xemlock@gmail.com> for contributing this fix.
|
||||
|
||||
4.10.0, released 2018-02-22
|
||||
# PHP 5.3 is no longer officially supported by HTML Purifier
|
||||
(we did not specifically break support, but we are no longer
|
||||
testing on PHP 5.3)
|
||||
! Relative CSS length units are now supported
|
||||
- A few PHP 7.2 compatibility fixes, thanks John Flatness
|
||||
<john@zerocrates.org>
|
||||
- Improve portability with old versions of libxml which don't
|
||||
support accessing the data of a node
|
||||
- IDNA2008 is now used for converting domains to ASCII, fixing
|
||||
some rather strange bugs with international domains
|
||||
- Fix race condition resulting in E_WARNING when creating
|
||||
directories with Serializer
|
||||
|
||||
4.9.3, released 2017-06-02
|
||||
- Workaround PHP 7.1 infinite loop when opcode cache is enabled.
|
||||
Thanks @Xiphin (#134, #135)
|
||||
|
@@ -2,7 +2,7 @@ HTML Purifier [ and rel="noopener" on links with target attributes,
|
||||
to prevent them from overwriting the original frame.
|
||||
|
||||
4.9.3 works around an infinite loop bug in PHP 7.1 with the opcode
|
||||
cache (and has one other, minor bugfix, avoiding using autoloading
|
||||
when testing for DOMDocument presence). If these bugs do not
|
||||
affect you, you do not need to upgrade.
|
||||
HTML Purifier 4.12.x is a maintenance release which makes
|
||||
compatibility fixes for PHP 7.4.
|
||||
|
@@ -1 +1,7 @@
|
||||
Deny from all
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</ifModule>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"type": "library",
|
||||
"keywords": ["html"],
|
||||
"homepage": "http://htmlpurifier.org/",
|
||||
"license": "LGPL",
|
||||
"license": "LGPL-2.1-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Edward Z. Yang",
|
||||
@@ -16,7 +16,7 @@
|
||||
"php": ">=5.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"simpletest/simpletest": "^1.1"
|
||||
"simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "HTMLPurifier": "library/" },
|
||||
|
@@ -19,37 +19,37 @@
|
||||
</directive>
|
||||
<directive id="CSS.MaxImgLength">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>226</line>
|
||||
<line>240</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.Proprietary">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>323</line>
|
||||
<line>365</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.AllowTricky">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>327</line>
|
||||
<line>369</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.Trusted">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>331</line>
|
||||
<line>373</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.AllowImportant">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>335</line>
|
||||
<line>377</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.AllowedProperties">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>464</line>
|
||||
<line>506</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="CSS.ForbiddenProperties">
|
||||
<file name="HTMLPurifier/CSSDefinition.php">
|
||||
<line>480</line>
|
||||
<line>522</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Cache.DefinitionImpl">
|
||||
@@ -410,7 +410,7 @@
|
||||
</directive>
|
||||
<directive id="Core.EnableIDNA">
|
||||
<file name="HTMLPurifier/AttrDef/URI/Host.php">
|
||||
<line>105</line>
|
||||
<line>109</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Attr.DefaultTextDir">
|
||||
@@ -539,6 +539,11 @@
|
||||
<line>54</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Core.AllowParseManyTags">
|
||||
<file name="HTMLPurifier/Lexer/DOMLex.php">
|
||||
<line>72</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Core.DirectLexLineNumberSyncInterval">
|
||||
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||
<line>84</line>
|
||||
|
@@ -75,6 +75,7 @@ Core is the potpourri of directives, mostly regarding some minor behavioral
|
||||
tweaks for HTML handling abilities.
|
||||
|
||||
AggressivelyFixLt
|
||||
AllowParseManyTags
|
||||
ConvertDocumentToFragment
|
||||
DirectLexLineNumberSyncInterval
|
||||
LexerImpl
|
||||
|
15
extras/HTMLPurifierExtras.autoload-legacy.php
Normal file
15
extras/HTMLPurifierExtras.autoload-legacy.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Legacy autoloader for systems lacking spl_autoload_register
|
||||
*
|
||||
* Must be separate to prevent deprecation warning on PHP 7.2
|
||||
*/
|
||||
|
||||
function __autoload($class)
|
||||
{
|
||||
return HTMLPurifierExtras::autoload($class);
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
@@ -17,10 +17,7 @@ if (function_exists('spl_autoload_register')) {
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
} elseif (!function_exists('__autoload')) {
|
||||
function __autoload($class)
|
||||
{
|
||||
return HTMLPurifierExtras::autoload($class);
|
||||
}
|
||||
require dirname(__FILE__) . '/HTMLPurifierExtras.autoload-legacy.php';
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
15
library/HTMLPurifier.autoload-legacy.php
Normal file
15
library/HTMLPurifier.autoload-legacy.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Legacy autoloader for systems lacking spl_autoload_register
|
||||
*
|
||||
* Must be separate to prevent deprecation warning on PHP 7.2
|
||||
*/
|
||||
|
||||
function __autoload($class)
|
||||
{
|
||||
return HTMLPurifier_Bootstrap::autoload($class);
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
@@ -14,10 +14,7 @@ if (function_exists('spl_autoload_register') && function_exists('spl_autoload_un
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
} elseif (!function_exists('__autoload')) {
|
||||
function __autoload($class)
|
||||
{
|
||||
return HTMLPurifier_Bootstrap::autoload($class);
|
||||
}
|
||||
require dirname(__FILE__) . '/HTMLPurifier.autoload-legacy.php';
|
||||
}
|
||||
|
||||
if (ini_get('zend.ze1_compatibility_mode')) {
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
|
||||
* FILE, changes will be overwritten the next time the script is run.
|
||||
*
|
||||
* @version 4.9.3
|
||||
* @version 4.12.0
|
||||
*
|
||||
* @warning
|
||||
* You must *not* include any other HTML Purifier files before this file,
|
||||
|
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
HTML Purifier 4.9.3 - Standards Compliant HTML Filtering
|
||||
HTML Purifier 4.12.0 - Standards Compliant HTML Filtering
|
||||
Copyright (C) 2006-2008 Edward Z. Yang
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -58,12 +58,12 @@ class HTMLPurifier
|
||||
* Version of HTML Purifier.
|
||||
* @type string
|
||||
*/
|
||||
public $version = '4.9.3';
|
||||
public $version = '4.12.0';
|
||||
|
||||
/**
|
||||
* Constant with version of HTML Purifier.
|
||||
*/
|
||||
const VERSION = '4.9.3';
|
||||
const VERSION = '4.12.0';
|
||||
|
||||
/**
|
||||
* Global configuration object.
|
||||
@@ -240,12 +240,16 @@ class HTMLPurifier
|
||||
public function purifyArray($array_of_html, $config = null)
|
||||
{
|
||||
$context_array = array();
|
||||
foreach ($array_of_html as $key => $html) {
|
||||
$array_of_html[$key] = $this->purify($html, $config);
|
||||
foreach($array_of_html as $key=>$value){
|
||||
if (is_array($value)) {
|
||||
$array[$key] = $this->purifyArray($value, $config);
|
||||
} else {
|
||||
$array[$key] = $this->purify($value, $config);
|
||||
}
|
||||
$context_array[$key] = $this->context;
|
||||
}
|
||||
$this->context = $context_array;
|
||||
return $array_of_html;
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
|
||||
{
|
||||
|
||||
/**
|
||||
* @type bool
|
||||
* @type string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
@@ -17,7 +17,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
|
||||
public $minimized = true;
|
||||
|
||||
/**
|
||||
* @param bool $name
|
||||
* @param bool|string $name
|
||||
*/
|
||||
public function __construct($name = false)
|
||||
{
|
||||
|
@@ -97,7 +97,11 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
|
||||
|
||||
// PHP 5.3 and later support this functionality natively
|
||||
if (function_exists('idn_to_ascii')) {
|
||||
$string = idn_to_ascii($string);
|
||||
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) {
|
||||
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
|
||||
} else {
|
||||
$string = idn_to_ascii($string);
|
||||
}
|
||||
|
||||
// If we have Net_IDNA2 support, we can support IRIs by
|
||||
// punycoding them. (This is the most portable thing to do,
|
||||
|
@@ -220,15 +220,25 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
||||
new HTMLPurifier_AttrDef_Enum(array('auto', 'initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$max = $config->get('CSS.MaxImgLength');
|
||||
|
||||
$this->info['min-width'] =
|
||||
$this->info['max-width'] =
|
||||
$this->info['min-height'] =
|
||||
$this->info['max-height'] =
|
||||
$this->info['width'] =
|
||||
$this->info['height'] =
|
||||
$max === null ?
|
||||
@@ -245,6 +255,38 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
||||
// For everyone else:
|
||||
$trusted_wh
|
||||
);
|
||||
$this->info['min-width'] =
|
||||
$this->info['min-height'] =
|
||||
$max === null ?
|
||||
$trusted_min_wh :
|
||||
new HTMLPurifier_AttrDef_Switch(
|
||||
'img',
|
||||
// For img tags:
|
||||
new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0', $max),
|
||||
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit'))
|
||||
)
|
||||
),
|
||||
// For everyone else:
|
||||
$trusted_min_wh
|
||||
);
|
||||
$this->info['max-width'] =
|
||||
$this->info['max-height'] =
|
||||
$max === null ?
|
||||
$trusted_max_wh :
|
||||
new HTMLPurifier_AttrDef_Switch(
|
||||
'img',
|
||||
// For img tags:
|
||||
new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0', $max),
|
||||
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit'))
|
||||
)
|
||||
),
|
||||
// For everyone else:
|
||||
$trusted_max_wh
|
||||
);
|
||||
|
||||
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration();
|
||||
|
||||
|
@@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
|
||||
protected function _compileRegex()
|
||||
{
|
||||
$raw = str_replace(' ', '', $this->dtd_regex);
|
||||
if ($raw{0} != '(') {
|
||||
if ($raw[0] != '(') {
|
||||
$raw = "($raw)";
|
||||
}
|
||||
$el = '[#a-zA-Z0-9_.-]+';
|
||||
|
@@ -21,7 +21,7 @@ class HTMLPurifier_Config
|
||||
* HTML Purifier's version
|
||||
* @type string
|
||||
*/
|
||||
public $version = '4.9.3';
|
||||
public $version = '4.12.0';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically finalize
|
||||
@@ -890,7 +890,7 @@ class HTMLPurifier_Config
|
||||
// zip(tail(trace), trace) -- but PHP is not Haskell har har
|
||||
for ($i = 0, $c = count($trace); $i < $c - 1; $i++) {
|
||||
// XXX this is not correct on some versions of HTML Purifier
|
||||
if ($trace[$i + 1]['class'] === 'HTMLPurifier_Config') {
|
||||
if (isset($trace[$i + 1]['class']) && $trace[$i + 1]['class'] === 'HTMLPurifier_Config') {
|
||||
continue;
|
||||
}
|
||||
$frame = $trace[$i];
|
||||
|
@@ -100,7 +100,7 @@ class HTMLPurifier_ConfigSchema
|
||||
* @param string $key Name of directive
|
||||
* @param mixed $default Default value of directive
|
||||
* @param string $type Allowed type of the directive. See
|
||||
* HTMLPurifier_DirectiveDef::$type for allowed values
|
||||
* HTMLPurifier_VarParser::$types for allowed values
|
||||
* @param bool $allow_null Whether or not to allow null values
|
||||
*/
|
||||
public function add($key, $default, $type, $allow_null)
|
||||
|
Binary file not shown.
@@ -6,7 +6,7 @@ DEFAULT: false
|
||||
<p>
|
||||
When enabled, HTML Purifier will treat any elements that contain only
|
||||
non-breaking spaces as well as regular whitespace as empty, and remove
|
||||
them when %AutoForamt.RemoveEmpty is enabled.
|
||||
them when %AutoFormat.RemoveEmpty is enabled.
|
||||
</p>
|
||||
<p>
|
||||
See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements
|
||||
|
@@ -0,0 +1,12 @@
|
||||
Core.AllowParseManyTags
|
||||
TYPE: bool
|
||||
DEFAULT: false
|
||||
VERSION: 4.10.1
|
||||
--DESCRIPTION--
|
||||
<p>
|
||||
This directive allows parsing of many nested tags.
|
||||
If you set true, relaxes any hardcoded limit from the parser.
|
||||
However, in that case it may cause a Dos attack.
|
||||
Be careful when enabling it.
|
||||
</p>
|
||||
--# vim: et sw=4 sts=4
|
@@ -3,23 +3,154 @@ TYPE: hash
|
||||
VERSION: 2.0.0
|
||||
--DEFAULT--
|
||||
array (
|
||||
'maroon' => '#800000',
|
||||
'red' => '#FF0000',
|
||||
'orange' => '#FFA500',
|
||||
'yellow' => '#FFFF00',
|
||||
'olive' => '#808000',
|
||||
'purple' => '#800080',
|
||||
'fuchsia' => '#FF00FF',
|
||||
'white' => '#FFFFFF',
|
||||
'lime' => '#00FF00',
|
||||
'green' => '#008000',
|
||||
'navy' => '#000080',
|
||||
'blue' => '#0000FF',
|
||||
'aliceblue' => '#F0F8FF',
|
||||
'antiquewhite' => '#FAEBD7',
|
||||
'aqua' => '#00FFFF',
|
||||
'teal' => '#008080',
|
||||
'aquamarine' => '#7FFFD4',
|
||||
'azure' => '#F0FFFF',
|
||||
'beige' => '#F5F5DC',
|
||||
'bisque' => '#FFE4C4',
|
||||
'black' => '#000000',
|
||||
'silver' => '#C0C0C0',
|
||||
'blanchedalmond' => '#FFEBCD',
|
||||
'blue' => '#0000FF',
|
||||
'blueviolet' => '#8A2BE2',
|
||||
'brown' => '#A52A2A',
|
||||
'burlywood' => '#DEB887',
|
||||
'cadetblue' => '#5F9EA0',
|
||||
'chartreuse' => '#7FFF00',
|
||||
'chocolate' => '#D2691E',
|
||||
'coral' => '#FF7F50',
|
||||
'cornflowerblue' => '#6495ED',
|
||||
'cornsilk' => '#FFF8DC',
|
||||
'crimson' => '#DC143C',
|
||||
'cyan' => '#00FFFF',
|
||||
'darkblue' => '#00008B',
|
||||
'darkcyan' => '#008B8B',
|
||||
'darkgoldenrod' => '#B8860B',
|
||||
'darkgray' => '#A9A9A9',
|
||||
'darkgrey' => '#A9A9A9',
|
||||
'darkgreen' => '#006400',
|
||||
'darkkhaki' => '#BDB76B',
|
||||
'darkmagenta' => '#8B008B',
|
||||
'darkolivegreen' => '#556B2F',
|
||||
'darkorange' => '#FF8C00',
|
||||
'darkorchid' => '#9932CC',
|
||||
'darkred' => '#8B0000',
|
||||
'darksalmon' => '#E9967A',
|
||||
'darkseagreen' => '#8FBC8F',
|
||||
'darkslateblue' => '#483D8B',
|
||||
'darkslategray' => '#2F4F4F',
|
||||
'darkslategrey' => '#2F4F4F',
|
||||
'darkturquoise' => '#00CED1',
|
||||
'darkviolet' => '#9400D3',
|
||||
'deeppink' => '#FF1493',
|
||||
'deepskyblue' => '#00BFFF',
|
||||
'dimgray' => '#696969',
|
||||
'dimgrey' => '#696969',
|
||||
'dodgerblue' => '#1E90FF',
|
||||
'firebrick' => '#B22222',
|
||||
'floralwhite' => '#FFFAF0',
|
||||
'forestgreen' => '#228B22',
|
||||
'fuchsia' => '#FF00FF',
|
||||
'gainsboro' => '#DCDCDC',
|
||||
'ghostwhite' => '#F8F8FF',
|
||||
'gold' => '#FFD700',
|
||||
'goldenrod' => '#DAA520',
|
||||
'gray' => '#808080',
|
||||
'grey' => '#808080',
|
||||
'green' => '#008000',
|
||||
'greenyellow' => '#ADFF2F',
|
||||
'honeydew' => '#F0FFF0',
|
||||
'hotpink' => '#FF69B4',
|
||||
'indianred' => '#CD5C5C',
|
||||
'indigo' => '#4B0082',
|
||||
'ivory' => '#FFFFF0',
|
||||
'khaki' => '#F0E68C',
|
||||
'lavender' => '#E6E6FA',
|
||||
'lavenderblush' => '#FFF0F5',
|
||||
'lawngreen' => '#7CFC00',
|
||||
'lemonchiffon' => '#FFFACD',
|
||||
'lightblue' => '#ADD8E6',
|
||||
'lightcoral' => '#F08080',
|
||||
'lightcyan' => '#E0FFFF',
|
||||
'lightgoldenrodyellow' => '#FAFAD2',
|
||||
'lightgray' => '#D3D3D3',
|
||||
'lightgrey' => '#D3D3D3',
|
||||
'lightgreen' => '#90EE90',
|
||||
'lightpink' => '#FFB6C1',
|
||||
'lightsalmon' => '#FFA07A',
|
||||
'lightseagreen' => '#20B2AA',
|
||||
'lightskyblue' => '#87CEFA',
|
||||
'lightslategray' => '#778899',
|
||||
'lightslategrey' => '#778899',
|
||||
'lightsteelblue' => '#B0C4DE',
|
||||
'lightyellow' => '#FFFFE0',
|
||||
'lime' => '#00FF00',
|
||||
'limegreen' => '#32CD32',
|
||||
'linen' => '#FAF0E6',
|
||||
'magenta' => '#FF00FF',
|
||||
'maroon' => '#800000',
|
||||
'mediumaquamarine' => '#66CDAA',
|
||||
'mediumblue' => '#0000CD',
|
||||
'mediumorchid' => '#BA55D3',
|
||||
'mediumpurple' => '#9370DB',
|
||||
'mediumseagreen' => '#3CB371',
|
||||
'mediumslateblue' => '#7B68EE',
|
||||
'mediumspringgreen' => '#00FA9A',
|
||||
'mediumturquoise' => '#48D1CC',
|
||||
'mediumvioletred' => '#C71585',
|
||||
'midnightblue' => '#191970',
|
||||
'mintcream' => '#F5FFFA',
|
||||
'mistyrose' => '#FFE4E1',
|
||||
'moccasin' => '#FFE4B5',
|
||||
'navajowhite' => '#FFDEAD',
|
||||
'navy' => '#000080',
|
||||
'oldlace' => '#FDF5E6',
|
||||
'olive' => '#808000',
|
||||
'olivedrab' => '#6B8E23',
|
||||
'orange' => '#FFA500',
|
||||
'orangered' => '#FF4500',
|
||||
'orchid' => '#DA70D6',
|
||||
'palegoldenrod' => '#EEE8AA',
|
||||
'palegreen' => '#98FB98',
|
||||
'paleturquoise' => '#AFEEEE',
|
||||
'palevioletred' => '#DB7093',
|
||||
'papayawhip' => '#FFEFD5',
|
||||
'peachpuff' => '#FFDAB9',
|
||||
'peru' => '#CD853F',
|
||||
'pink' => '#FFC0CB',
|
||||
'plum' => '#DDA0DD',
|
||||
'powderblue' => '#B0E0E6',
|
||||
'purple' => '#800080',
|
||||
'rebeccapurple' => '#663399',
|
||||
'red' => '#FF0000',
|
||||
'rosybrown' => '#BC8F8F',
|
||||
'royalblue' => '#4169E1',
|
||||
'saddlebrown' => '#8B4513',
|
||||
'salmon' => '#FA8072',
|
||||
'sandybrown' => '#F4A460',
|
||||
'seagreen' => '#2E8B57',
|
||||
'seashell' => '#FFF5EE',
|
||||
'sienna' => '#A0522D',
|
||||
'silver' => '#C0C0C0',
|
||||
'skyblue' => '#87CEEB',
|
||||
'slateblue' => '#6A5ACD',
|
||||
'slategray' => '#708090',
|
||||
'slategrey' => '#708090',
|
||||
'snow' => '#FFFAFA',
|
||||
'springgreen' => '#00FF7F',
|
||||
'steelblue' => '#4682B4',
|
||||
'tan' => '#D2B48C',
|
||||
'teal' => '#008080',
|
||||
'thistle' => '#D8BFD8',
|
||||
'tomato' => '#FF6347',
|
||||
'turquoise' => '#40E0D0',
|
||||
'violet' => '#EE82EE',
|
||||
'wheat' => '#F5DEB3',
|
||||
'white' => '#FFFFFF',
|
||||
'whitesmoke' => '#F5F5F5',
|
||||
'yellow' => '#FFFF00',
|
||||
'yellowgreen' => '#9ACD32'
|
||||
)
|
||||
--DESCRIPTION--
|
||||
|
||||
|
@@ -217,9 +217,14 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
||||
$directory = $this->generateDirectoryPath($config);
|
||||
$chmod = $config->get('Cache.SerializerPermissions');
|
||||
if ($chmod === null) {
|
||||
// TODO: This races
|
||||
if (is_dir($directory)) return true;
|
||||
return mkdir($directory);
|
||||
if (!@mkdir($directory) && !is_dir($directory)) {
|
||||
trigger_error(
|
||||
'Could not create directory ' . $directory . '',
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!is_dir($directory)) {
|
||||
$base = $this->generateBaseDirectoryPath($config);
|
||||
@@ -233,7 +238,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
||||
} elseif (!$this->_testPermissions($base, $chmod)) {
|
||||
return false;
|
||||
}
|
||||
if (!mkdir($directory, $chmod)) {
|
||||
if (!@mkdir($directory, $chmod) && !is_dir($directory)) {
|
||||
trigger_error(
|
||||
'Could not create directory ' . $directory . '',
|
||||
E_USER_WARNING
|
||||
|
@@ -159,7 +159,7 @@ class HTMLPurifier_Encoder
|
||||
|
||||
$len = strlen($str);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$in = ord($str{$i});
|
||||
$in = ord($str[$i]);
|
||||
$char .= $str[$i]; // append byte to char
|
||||
if (0 == $mState) {
|
||||
// When mState is zero we expect either a US-ASCII character
|
||||
|
@@ -118,7 +118,7 @@ class HTMLPurifier_EntityParser
|
||||
$entity = $matches[0];
|
||||
$hex_part = @$matches[1];
|
||||
$dec_part = @$matches[2];
|
||||
$named_part = empty($matches[3]) ? @$matches[4] : $matches[3];
|
||||
$named_part = empty($matches[3]) ? (empty($matches[4]) ? "" : $matches[4]) : $matches[3];
|
||||
if ($hex_part !== NULL && $hex_part !== "") {
|
||||
return HTMLPurifier_Encoder::unichr(hexdec($hex_part));
|
||||
} elseif ($dec_part !== NULL && $dec_part !== "") {
|
||||
|
@@ -132,9 +132,9 @@ class HTMLPurifier_HTMLModule
|
||||
* @param string $element Name of element to add
|
||||
* @param string|bool $type What content set should element be registered to?
|
||||
* Set as false to skip this step.
|
||||
* @param string $contents Allowed children in form of:
|
||||
* @param string|HTMLPurifier_ChildDef $contents Allowed children in form of:
|
||||
* "$content_model_type: $content_model"
|
||||
* @param array $attr_includes What attribute collections to register to
|
||||
* @param array|string $attr_includes What attribute collections to register to
|
||||
* element?
|
||||
* @param array $attr What unique attributes does the element define?
|
||||
* @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.
|
||||
|
@@ -23,13 +23,13 @@ class HTMLPurifier_HTMLModule_SafeScripting extends HTMLPurifier_HTMLModule
|
||||
$script = $this->addElement(
|
||||
'script',
|
||||
'Inline',
|
||||
'Empty',
|
||||
'Optional:', // Not `Empty` to not allow to autoclose the <script /> tag @see https://www.w3.org/TR/html4/interact/scripts.html
|
||||
null,
|
||||
array(
|
||||
// While technically not required by the spec, we're forcing
|
||||
// it to this value.
|
||||
'type' => 'Enum#text/javascript',
|
||||
'src*' => new HTMLPurifier_AttrDef_Enum(array_keys($allowed))
|
||||
'src*' => new HTMLPurifier_AttrDef_Enum(array_keys($allowed), /*case sensitive*/ true)
|
||||
)
|
||||
);
|
||||
$script->attr_transform_pre[] =
|
||||
|
@@ -157,11 +157,13 @@ abstract class HTMLPurifier_Injector
|
||||
return false;
|
||||
}
|
||||
// check for exclusion
|
||||
for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) {
|
||||
$node = $this->currentNesting[$i];
|
||||
$def = $this->htmlDefinition->info[$node->name];
|
||||
if (isset($def->excludes[$name])) {
|
||||
return false;
|
||||
if (!empty($this->currentNesting)) {
|
||||
for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) {
|
||||
$node = $this->currentNesting[$i];
|
||||
$def = $this->htmlDefinition->info[$node->name];
|
||||
if (isset($def->excludes[$name])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@@ -8,4 +8,6 @@ $messages = array(
|
||||
'HTMLPurifier' => 'HTML Purifier X'
|
||||
);
|
||||
|
||||
$errorNames = array();
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@@ -9,4 +9,6 @@ $messages = array(
|
||||
'HTMLPurifier' => 'HTML Purifier XNone'
|
||||
);
|
||||
|
||||
$errorNames = array();
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@@ -26,12 +26,14 @@ class HTMLPurifier_Length
|
||||
protected $isValid;
|
||||
|
||||
/**
|
||||
* Array Lookup array of units recognized by CSS 2.1
|
||||
* Array Lookup array of units recognized by CSS 3
|
||||
* @type array
|
||||
*/
|
||||
protected static $allowedUnits = array(
|
||||
'em' => true, 'ex' => true, 'px' => true, 'in' => true,
|
||||
'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true
|
||||
'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true,
|
||||
'ch' => true, 'rem' => true, 'vw' => true, 'vh' => true,
|
||||
'vmin' => true, 'vmax' => true
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -68,8 +68,18 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
$doc = new DOMDocument();
|
||||
$doc->encoding = 'UTF-8'; // theoretically, the above has this covered
|
||||
|
||||
$options = 0;
|
||||
if ($config->get('Core.AllowParseManyTags') && defined('LIBXML_PARSEHUGE')) {
|
||||
$options |= LIBXML_PARSEHUGE;
|
||||
}
|
||||
|
||||
set_error_handler(array($this, 'muteErrorHandler'));
|
||||
$doc->loadHTML($html);
|
||||
// loadHTML() fails on PHP 5.3 when second parameter is given
|
||||
if ($options) {
|
||||
$doc->loadHTML($html, $options);
|
||||
} else {
|
||||
$doc->loadHTML($html);
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
$body = $doc->getElementsByTagName('html')->item(0)-> // <html>
|
||||
@@ -126,6 +136,41 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
} while ($level > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Portably retrieve the tag name of a node; deals with older versions
|
||||
* of libxml like 2.7.6
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
protected function getTagName($node)
|
||||
{
|
||||
if (isset($node->tagName)) {
|
||||
return $node->tagName;
|
||||
} else if (isset($node->nodeName)) {
|
||||
return $node->nodeName;
|
||||
} else if (isset($node->localName)) {
|
||||
return $node->localName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portably retrieve the data of a node; deals with older versions
|
||||
* of libxml like 2.7.6
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
protected function getData($node)
|
||||
{
|
||||
if (isset($node->data)) {
|
||||
return $node->data;
|
||||
} else if (isset($node->nodeValue)) {
|
||||
return $node->nodeValue;
|
||||
} else if (isset($node->textContent)) {
|
||||
return $node->textContent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param DOMNode $node DOMNode to be tokenized.
|
||||
* @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens.
|
||||
@@ -141,7 +186,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
// but we're not getting the character reference nodes because
|
||||
// those should have been preprocessed
|
||||
if ($node->nodeType === XML_TEXT_NODE) {
|
||||
$tokens[] = $this->factory->createText($node->data);
|
||||
$data = $this->getData($node); // Handle variable data property
|
||||
if ($data !== null) {
|
||||
$tokens[] = $this->factory->createText($data);
|
||||
}
|
||||
return false;
|
||||
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
|
||||
// undo libxml's special treatment of <script> and <style> tags
|
||||
@@ -171,21 +219,20 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
// not-well tested: there may be other nodes we have to grab
|
||||
return false;
|
||||
}
|
||||
|
||||
$attr = $node->hasAttributes() ? $this->transformAttrToAssoc($node->attributes) : array();
|
||||
|
||||
$tag_name = $this->getTagName($node); // Handle variable tagName property
|
||||
if (empty($tag_name)) {
|
||||
return (bool) $node->childNodes->length;
|
||||
}
|
||||
// We still have to make sure that the element actually IS empty
|
||||
if (!$node->childNodes->length) {
|
||||
if ($collect) {
|
||||
$tokens[] = $this->factory->createEmpty($node->tagName, $attr);
|
||||
$tokens[] = $this->factory->createEmpty($tag_name, $attr);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if ($collect) {
|
||||
$tokens[] = $this->factory->createStart(
|
||||
$tag_name = $node->tagName, // somehow, it get's dropped
|
||||
$attr
|
||||
);
|
||||
$tokens[] = $this->factory->createStart($tag_name, $attr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -197,10 +244,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
*/
|
||||
protected function createEndNode($node, &$tokens)
|
||||
{
|
||||
$tokens[] = $this->factory->createEnd($node->tagName);
|
||||
$tag_name = $this->getTagName($node); // Handle variable tagName property
|
||||
$tokens[] = $this->factory->createEnd($tag_name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.
|
||||
*
|
||||
|
@@ -1507,7 +1507,7 @@ class HTML5
|
||||
$entity = $this->character($start, $this->char);
|
||||
$cond = strlen($e_name) > 0;
|
||||
|
||||
// The rest of the parsing happens bellow.
|
||||
// The rest of the parsing happens below.
|
||||
break;
|
||||
|
||||
// Anything else
|
||||
@@ -1535,7 +1535,7 @@ class HTML5
|
||||
}
|
||||
|
||||
$cond = isset($entity);
|
||||
// The rest of the parsing happens bellow.
|
||||
// The rest of the parsing happens below.
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
|
||||
$this->compress = $compress;
|
||||
// initialize sub-printers
|
||||
$this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();
|
||||
$this->fields[HTMLPurifier_VarParser::BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
|
||||
$this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,7 +339,7 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
if ($type === HTMLPurifier_VarParser::MIXED) {
|
||||
if ($type === HTMLPurifier_VarParser::C_MIXED) {
|
||||
return 'Not supported';
|
||||
$value = serialize($value);
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
|
||||
if (isset($attr['size'])) {
|
||||
// normalize large numbers
|
||||
if ($attr['size'] !== '') {
|
||||
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
|
||||
if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
|
||||
$size = (int)$attr['size'];
|
||||
if ($size < -2) {
|
||||
$attr['size'] = '-2';
|
||||
|
@@ -7,34 +7,34 @@
|
||||
class HTMLPurifier_VarParser
|
||||
{
|
||||
|
||||
const STRING = 1;
|
||||
const C_STRING = 1;
|
||||
const ISTRING = 2;
|
||||
const TEXT = 3;
|
||||
const ITEXT = 4;
|
||||
const INT = 5;
|
||||
const FLOAT = 6;
|
||||
const BOOL = 7;
|
||||
const C_INT = 5;
|
||||
const C_FLOAT = 6;
|
||||
const C_BOOL = 7;
|
||||
const LOOKUP = 8;
|
||||
const ALIST = 9;
|
||||
const HASH = 10;
|
||||
const MIXED = 11;
|
||||
const C_MIXED = 11;
|
||||
|
||||
/**
|
||||
* Lookup table of allowed types. Mainly for backwards compatibility, but
|
||||
* also convenient for transforming string type names to the integer constants.
|
||||
*/
|
||||
public static $types = array(
|
||||
'string' => self::STRING,
|
||||
'string' => self::C_STRING,
|
||||
'istring' => self::ISTRING,
|
||||
'text' => self::TEXT,
|
||||
'itext' => self::ITEXT,
|
||||
'int' => self::INT,
|
||||
'float' => self::FLOAT,
|
||||
'bool' => self::BOOL,
|
||||
'int' => self::C_INT,
|
||||
'float' => self::C_FLOAT,
|
||||
'bool' => self::C_BOOL,
|
||||
'lookup' => self::LOOKUP,
|
||||
'list' => self::ALIST,
|
||||
'hash' => self::HASH,
|
||||
'mixed' => self::MIXED
|
||||
'mixed' => self::C_MIXED
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ class HTMLPurifier_VarParser
|
||||
* allowed value lists.
|
||||
*/
|
||||
public static $stringTypes = array(
|
||||
self::STRING => true,
|
||||
self::C_STRING => true,
|
||||
self::ISTRING => true,
|
||||
self::TEXT => true,
|
||||
self::ITEXT => true,
|
||||
@@ -74,7 +74,7 @@ class HTMLPurifier_VarParser
|
||||
// These are basic checks, to make sure nothing horribly wrong
|
||||
// happened in our implementations.
|
||||
switch ($type) {
|
||||
case (self::STRING):
|
||||
case (self::C_STRING):
|
||||
case (self::ISTRING):
|
||||
case (self::TEXT):
|
||||
case (self::ITEXT):
|
||||
@@ -85,17 +85,17 @@ class HTMLPurifier_VarParser
|
||||
$var = strtolower($var);
|
||||
}
|
||||
return $var;
|
||||
case (self::INT):
|
||||
case (self::C_INT):
|
||||
if (!is_int($var)) {
|
||||
break;
|
||||
}
|
||||
return $var;
|
||||
case (self::FLOAT):
|
||||
case (self::C_FLOAT):
|
||||
if (!is_float($var)) {
|
||||
break;
|
||||
}
|
||||
return $var;
|
||||
case (self::BOOL):
|
||||
case (self::C_BOOL):
|
||||
if (!is_bool($var)) {
|
||||
break;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class HTMLPurifier_VarParser
|
||||
}
|
||||
}
|
||||
return $var;
|
||||
case (self::MIXED):
|
||||
case (self::C_MIXED):
|
||||
return $var;
|
||||
default:
|
||||
$this->errorInconsistent(get_class($this), $type);
|
||||
|
@@ -23,23 +23,23 @@ class HTMLPurifier_VarParser_Flexible extends HTMLPurifier_VarParser
|
||||
// Note: if code "breaks" from the switch, it triggers a generic
|
||||
// exception to be thrown. Specific errors can be specifically
|
||||
// done here.
|
||||
case self::MIXED:
|
||||
case self::C_MIXED:
|
||||
case self::ISTRING:
|
||||
case self::STRING:
|
||||
case self::C_STRING:
|
||||
case self::TEXT:
|
||||
case self::ITEXT:
|
||||
return $var;
|
||||
case self::INT:
|
||||
case self::C_INT:
|
||||
if (is_string($var) && ctype_digit($var)) {
|
||||
$var = (int)$var;
|
||||
}
|
||||
return $var;
|
||||
case self::FLOAT:
|
||||
case self::C_FLOAT:
|
||||
if ((is_string($var) && is_numeric($var)) || is_int($var)) {
|
||||
$var = (float)$var;
|
||||
}
|
||||
return $var;
|
||||
case self::BOOL:
|
||||
case self::C_BOOL:
|
||||
if (is_int($var) && ($var === 0 || $var === 1)) {
|
||||
$var = (bool)$var;
|
||||
} elseif (is_string($var)) {
|
||||
|
@@ -1 +1,7 @@
|
||||
Deny from all
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</ifModule>
|
||||
|
@@ -1080,7 +1080,7 @@ class HTML5
|
||||
$entity = $this->character($start, $this->char);
|
||||
$cond = strlen($e_name) > 0;
|
||||
|
||||
// The rest of the parsing happens bellow.
|
||||
// The rest of the parsing happens below.
|
||||
break;
|
||||
|
||||
// Anything else
|
||||
@@ -1102,7 +1102,7 @@ class HTML5
|
||||
}
|
||||
|
||||
$cond = isset($entity);
|
||||
// The rest of the parsing happens bellow.
|
||||
// The rest of the parsing happens below.
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
require_once 'common.php';
|
||||
assertCli();
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Runs all generation/flush cache scripts to ensure that somewhat volatile
|
||||
* generated files are up-to-date.
|
||||
*/
|
||||
|
||||
function e($cmd)
|
||||
{
|
||||
echo "\$ $cmd\n";
|
||||
passthru($cmd, $status);
|
||||
echo "\n";
|
||||
if ($status) exit($status);
|
||||
}
|
||||
|
||||
$php = empty($_SERVER['argv'][1]) ? 'php' : $_SERVER['argv'][1];
|
||||
|
||||
e($php . ' generate-includes.php');
|
||||
e($php . ' generate-schema-cache.php');
|
||||
e($php . ' flush-definition-cache.php');
|
||||
e($php . ' generate-standalone.php');
|
||||
e($php . ' config-scanner.php');
|
||||
|
||||
// vim: et sw=4 sts=4
|
8
maintenance/flush.sh
Executable file
8
maintenance/flush.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
php "$DIR/generate-includes.php"
|
||||
php "$DIR/generate-schema-cache.php"
|
||||
php "$DIR/flush-definition-cache.php"
|
||||
php "$DIR/generate-standalone.php"
|
||||
php "$DIR/config-scanner.php"
|
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
require_once 'common.php';
|
||||
assertCli();
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Converts all instances of $config->set and $config->get to the new
|
||||
* format, as described by docs/dev-config-bcbreaks.txt
|
||||
*/
|
||||
|
||||
$FS = new FSTools();
|
||||
chdir(dirname(__FILE__) . '/..');
|
||||
$raw_files = $FS->globr('.', '*.php');
|
||||
foreach ($raw_files as $file) {
|
||||
$file = substr($file, 2); // rm leading './'
|
||||
if (strpos($file, 'library/standalone/') === 0) continue;
|
||||
if (strpos($file, 'maintenance/update-config.php') === 0) continue;
|
||||
if (strpos($file, 'test-settings.php') === 0) continue;
|
||||
if (substr_count($file, '.') > 1) continue; // rm meta files
|
||||
// process the file
|
||||
$contents = file_get_contents($file);
|
||||
$contents = preg_replace(
|
||||
"#config->(set|get)\('(.+?)', '(.+?)'#",
|
||||
"config->\\1('\\2.\\3'",
|
||||
$contents
|
||||
);
|
||||
if ($contents === '') continue;
|
||||
file_put_contents($file, $contents);
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
@@ -53,5 +53,6 @@ $config->set('Core.Encoding', $GLOBALS['PHORUM']['DATA']['CHARSET']); // we'll c
|
||||
if (strtolower($GLOBALS['PHORUM']['DATA']['CHARSET']) !== 'utf-8') {
|
||||
$config->set('Core.EscapeNonASCIICharacters', true);
|
||||
}
|
||||
$config->set('Core.AllowParseManyTags', false);
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Tags releases
|
||||
|
||||
if (php_sapi_name() != 'cli') {
|
||||
echo 'Release script cannot be called from web-browser.';
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'svn.php';
|
||||
|
||||
$svn_info = my_svn_info('.');
|
||||
|
||||
$version = trim(file_get_contents('VERSION'));
|
||||
|
||||
$trunk_url = $svn_info['Repository Root'] . '/htmlpurifier/trunk';
|
||||
$trunk_tag_url = $svn_info['Repository Root'] . '/htmlpurifier/tags/' . $version;
|
||||
|
||||
echo "Tagging trunk to tags/$version...";
|
||||
passthru("svn copy --message \"Tag $version release.\" $trunk_url $trunk_tag_url");
|
||||
|
||||
// vim: et sw=4 sts=4
|
@@ -64,8 +64,14 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
|
||||
$this->assertDef('width:-50px;', false);
|
||||
$this->assertDef('min-width:50%;');
|
||||
$this->assertDef('min-width:50px;');
|
||||
$this->assertDef('min-width:auto;');
|
||||
$this->assertDef('min-width:auto;', false);
|
||||
$this->assertDef('min-width:initial;');
|
||||
$this->assertDef('min-width:inherit;');
|
||||
$this->assertDef('min-width:-50px;', false);
|
||||
$this->assertDef('min-width:50ch;');
|
||||
$this->assertDef('min-width:50rem;');
|
||||
$this->assertDef('min-width:50vw;');
|
||||
$this->assertDef('min-width:-50vw;', false);
|
||||
$this->assertDef('text-decoration:underline;');
|
||||
$this->assertDef('font-family:sans-serif;');
|
||||
$this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;");
|
||||
|
@@ -49,6 +49,7 @@ class HTMLPurifier_AttrDef_URI_HostTest extends HTMLPurifier_AttrDefHarness
|
||||
}
|
||||
$this->config->set('Core.EnableIDNA', true);
|
||||
$this->assertDef("\xE4\xB8\xAD\xE6\x96\x87.com.cn", "xn--fiq228c.com.cn");
|
||||
$this->assertDef("faß.de", "xn--fa-hia.de");
|
||||
$this->assertDef("\xe2\x80\x85.com", false); // rejected
|
||||
}
|
||||
|
||||
|
@@ -15,12 +15,12 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
$this->schema->add('Car.Seats', 5, 'int', false);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Car.Seats'], 5);
|
||||
$this->assertIdentical($this->schema->info['Car.Seats']->type, HTMLPurifier_VarParser::INT);
|
||||
$this->assertIdentical($this->schema->info['Car.Seats']->type, HTMLPurifier_VarParser::C_INT);
|
||||
|
||||
$this->schema->add('Car.Age', null, 'int', true);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Car.Age'], null);
|
||||
$this->assertIdentical($this->schema->info['Car.Age']->type, HTMLPurifier_VarParser::INT);
|
||||
$this->assertIdentical($this->schema->info['Car.Age']->type, HTMLPurifier_VarParser::C_INT);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['QuantumNumber.Difficulty'], null);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->type, HTMLPurifier_VarParser::STRING);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->type, HTMLPurifier_VarParser::C_STRING);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allow_null, true);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allowed,
|
||||
array(
|
||||
@@ -70,7 +70,7 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Abbrev.HTH'], 'Happy to Help');
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->type, HTMLPurifier_VarParser::STRING);
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->type, HTMLPurifier_VarParser::C_STRING);
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->allowed,
|
||||
array(
|
||||
'Happy to Help' => true,
|
||||
|
@@ -384,6 +384,21 @@ a[href|title]
|
||||
$this->config->getHTMLDefinition();
|
||||
}
|
||||
|
||||
public function test_manyNestedTags()
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('Core.AllowParseManyTags', true);
|
||||
$purifier = new HTMLPurifier($config);
|
||||
|
||||
$input = 'I am inside a lot of tags';
|
||||
for ($i = 0; $i < 300; $i++) {
|
||||
$input = '<div>' . $input . '</div>';
|
||||
}
|
||||
$output = $purifier->purify($input);
|
||||
|
||||
$this->assertIdentical($input, $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@@ -20,7 +20,15 @@ class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleH
|
||||
public function testGood()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<script type="text/javascript" src="http://localhost/foo.js" />'
|
||||
'<script type="text/javascript" src="http://localhost/foo.js"></script>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testGoodWithAutoclosedTag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<script type="text/javascript" src="http://localhost/foo.js"/>',
|
||||
'<script type="text/javascript" src="http://localhost/foo.js"></script>'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,6 +38,10 @@ class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleH
|
||||
'<script type="text/javascript" src="http://localhost/foobar.js" />',
|
||||
''
|
||||
);
|
||||
$this->assertResult(
|
||||
'<script type="text/javascript" src="http://localhost/FOO.JS" />',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class HTMLPurifier_VarParser_FlexibleTest extends HTMLPurifier_VarParserHarness
|
||||
|
||||
public function testValidate_withMagicNumbers()
|
||||
{
|
||||
$this->assertValid('foobar', HTMLPurifier_VarParser::STRING);
|
||||
$this->assertValid('foobar', HTMLPurifier_VarParser::C_STRING);
|
||||
}
|
||||
|
||||
public function testValidate_null()
|
||||
|
@@ -22,6 +22,16 @@ class HTMLPurifierTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
public function test_purifyArray_nested()
|
||||
{
|
||||
$this->assertIdentical(
|
||||
$this->purifier->purifyArray(
|
||||
array('Good', '<b>Sketchy', 'foo' => array('bar' => '<script>bad</script>'))
|
||||
),
|
||||
array('Good', '<b>Sketchy</b>', 'foo' => array('bar' => ''))
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetInstance()
|
||||
{
|
||||
$purifier = HTMLPurifier::getInstance();
|
||||
|
@@ -7,7 +7,7 @@ if (!defined('HTMLPurifierTest')) {
|
||||
|
||||
// setup our own autoload, checking for HTMLPurifier library if spl_autoload_register
|
||||
// is not allowed
|
||||
function __autoload($class)
|
||||
function test_autoload($class)
|
||||
{
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
if (HTMLPurifier_Bootstrap::autoload($class)) return true;
|
||||
@@ -17,7 +17,7 @@ function __autoload($class)
|
||||
return true;
|
||||
}
|
||||
if (function_exists('spl_autoload_register')) {
|
||||
spl_autoload_register('__autoload');
|
||||
spl_autoload_register('test_autoload');
|
||||
}
|
||||
|
||||
// default settings (protect against register_globals)
|
||||
|
@@ -33,6 +33,10 @@ error_reporting(E_ALL | E_STRICT);
|
||||
// exercises an error condition to detect for it.
|
||||
ini_set('log_errors', false);
|
||||
|
||||
// But make it easier for us to debug if there is some misconfiguration
|
||||
// in the initial setup of the tests.
|
||||
ini_set('display_errors', true);
|
||||
|
||||
define('HTMLPurifierTest', 1);
|
||||
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
||||
chdir(dirname(__FILE__));
|
||||
|
@@ -102,7 +102,7 @@ if (!$c) {
|
||||
}
|
||||
file_put_contents('library/HTMLPurifier/Config.php', $config_c);
|
||||
|
||||
passthru('php maintenance/flush.php');
|
||||
passthru('maintenance/flush.sh');
|
||||
|
||||
if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL;
|
||||
else echo "Numbers updated to dev, no other modifications necessary!";
|
Reference in New Issue
Block a user