mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 22:26:31 +02:00
Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d85d39da45 | ||
|
f33d1f8e99 | ||
|
6d6d88512a | ||
|
bb7ad66526 | ||
|
64baeda65c | ||
|
67c3798922 | ||
|
df64746caa | ||
|
ab9c9f30fd | ||
|
5988f29583 | ||
|
ce0ede24de | ||
|
17f80cd74b | ||
|
e11f7c9802 | ||
|
d21213e0d3 | ||
|
9b3f856fb9 | ||
|
95e1bae318 | ||
|
ff16ed3de4 | ||
|
1df505296f | ||
|
b9bc1039da | ||
|
cb4871f446 | ||
|
65d5cdee50 | ||
|
b45c6f5363 |
@@ -1,11 +1,11 @@
|
|||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- '5.3'
|
|
||||||
- '5.4'
|
- '5.4'
|
||||||
- '5.5'
|
- '5.5'
|
||||||
- '5.6'
|
- '5.6'
|
||||||
- '7.0'
|
- '7.0'
|
||||||
- '7.1'
|
- '7.1'
|
||||||
|
- '7.2'
|
||||||
before_script:
|
before_script:
|
||||||
- git clone --depth=50 https://github.com/ezyang/simpletest.git
|
- git clone --depth=50 https://github.com/ezyang/simpletest.git
|
||||||
- cp test-settings.travis.php test-settings.php
|
- 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
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 4.9.2
|
PROJECT_NUMBER = 4.10.0
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||||
# base path where the generated documentation will be put.
|
# base path where the generated documentation will be put.
|
||||||
|
22
NEWS
22
NEWS
@@ -9,6 +9,28 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
. Internal change
|
. Internal change
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
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)
|
||||||
|
- Don't use autoloader when testing for DOMDocument. Hypothetically,
|
||||||
|
this could cause your install to start using DirectLex if you had
|
||||||
|
previously been monkeypatching in a custom, autoloaded implementation
|
||||||
|
of DOMDocument. Don't do that. Thanks @Izumi-kun (#130)
|
||||||
|
|
||||||
4.9.2, released 2017-03-12
|
4.9.2, released 2017-03-12
|
||||||
- Fixes PHP 5.3 compatibility
|
- Fixes PHP 5.3 compatibility
|
||||||
- Fix breakage when decoding decimal entities. Thanks @rybakit (#129)
|
- Fix breakage when decoding decimal entities. Thanks @rybakit (#129)
|
||||||
|
@@ -2,7 +2,7 @@ HTML Purifier [ and rel="noopener" on links with target attributes,
|
in URLs) and rel="noopener" on links with target attributes,
|
||||||
to prevent them from overwriting the original frame.
|
to prevent them from overwriting the original frame.
|
||||||
|
|
||||||
4.9.0 was skipped due to a packaging problem; 4.9.2 fixes two
|
4.9.3 works around an infinite loop bug in PHP 7.1 with the opcode
|
||||||
major regressions in PHP 5.3 support and entity decoding; no
|
cache (and has one other, minor bugfix, avoiding using autoloading
|
||||||
other functional changes were applied.
|
when testing for DOMDocument presence). If these bugs do not
|
||||||
|
affect you, you do not need to upgrade.
|
||||||
|
@@ -228,7 +228,7 @@ Test.Example</pre>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>mixed</td>
|
<td>mixed</td>
|
||||||
<td>new stdclass</td>
|
<td>new stdClass</td>
|
||||||
<td>Any PHP variable is fine</td>
|
<td>Any PHP variable is fine</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
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');
|
spl_autoload_register('__autoload');
|
||||||
}
|
}
|
||||||
} elseif (!function_exists('__autoload')) {
|
} elseif (!function_exists('__autoload')) {
|
||||||
function __autoload($class)
|
require dirname(__FILE__) . '/HTMLPurifierExtras.autoload-legacy.php';
|
||||||
{
|
|
||||||
return HTMLPurifierExtras::autoload($class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: et sw=4 sts=4
|
// 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');
|
spl_autoload_register('__autoload');
|
||||||
}
|
}
|
||||||
} elseif (!function_exists('__autoload')) {
|
} elseif (!function_exists('__autoload')) {
|
||||||
function __autoload($class)
|
require dirname(__FILE__) . '/HTMLPurifier.autoload-legacy.php';
|
||||||
{
|
|
||||||
return HTMLPurifier_Bootstrap::autoload($class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ini_get('zend.ze1_compatibility_mode')) {
|
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
|
* 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.
|
* FILE, changes will be overwritten the next time the script is run.
|
||||||
*
|
*
|
||||||
* @version 4.9.2
|
* @version 4.10.0
|
||||||
*
|
*
|
||||||
* @warning
|
* @warning
|
||||||
* You must *not* include any other HTML Purifier files before this file,
|
* You must *not* include any other HTML Purifier files before this file,
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
HTML Purifier 4.9.2 - Standards Compliant HTML Filtering
|
HTML Purifier 4.10.0 - Standards Compliant HTML Filtering
|
||||||
Copyright (C) 2006-2008 Edward Z. Yang
|
Copyright (C) 2006-2008 Edward Z. Yang
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
@@ -58,12 +58,12 @@ class HTMLPurifier
|
|||||||
* Version of HTML Purifier.
|
* Version of HTML Purifier.
|
||||||
* @type string
|
* @type string
|
||||||
*/
|
*/
|
||||||
public $version = '4.9.2';
|
public $version = '4.10.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant with version of HTML Purifier.
|
* Constant with version of HTML Purifier.
|
||||||
*/
|
*/
|
||||||
const VERSION = '4.9.2';
|
const VERSION = '4.10.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global configuration object.
|
* Global configuration object.
|
||||||
|
@@ -97,7 +97,7 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
// PHP 5.3 and later support this functionality natively
|
// PHP 5.3 and later support this functionality natively
|
||||||
if (function_exists('idn_to_ascii')) {
|
if (function_exists('idn_to_ascii')) {
|
||||||
$string = idn_to_ascii($string);
|
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
|
||||||
|
|
||||||
// If we have Net_IDNA2 support, we can support IRIs by
|
// If we have Net_IDNA2 support, we can support IRIs by
|
||||||
// punycoding them. (This is the most portable thing to do,
|
// punycoding them. (This is the most portable thing to do,
|
||||||
|
@@ -50,7 +50,7 @@ class HTMLPurifier_ChildDef_List extends HTMLPurifier_ChildDef
|
|||||||
// a little sanity check to make sure it's not ALL whitespace
|
// a little sanity check to make sure it's not ALL whitespace
|
||||||
$all_whitespace = true;
|
$all_whitespace = true;
|
||||||
|
|
||||||
$current_li = false;
|
$current_li = null;
|
||||||
|
|
||||||
foreach ($children as $node) {
|
foreach ($children as $node) {
|
||||||
if (!empty($node->is_whitespace)) {
|
if (!empty($node->is_whitespace)) {
|
||||||
@@ -71,7 +71,7 @@ class HTMLPurifier_ChildDef_List extends HTMLPurifier_ChildDef
|
|||||||
// to handle non-list elements; non-list elements should
|
// to handle non-list elements; non-list elements should
|
||||||
// not be appended to an existing li; only li created
|
// not be appended to an existing li; only li created
|
||||||
// for non-list. This distinction is not currently made.
|
// for non-list. This distinction is not currently made.
|
||||||
if ($current_li === false) {
|
if ($current_li === null) {
|
||||||
$current_li = new HTMLPurifier_Node_Element('li');
|
$current_li = new HTMLPurifier_Node_Element('li');
|
||||||
$result[] = $current_li;
|
$result[] = $current_li;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ class HTMLPurifier_Config
|
|||||||
* HTML Purifier's version
|
* HTML Purifier's version
|
||||||
* @type string
|
* @type string
|
||||||
*/
|
*/
|
||||||
public $version = '4.9.2';
|
public $version = '4.10.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to automatically finalize
|
* Whether or not to automatically finalize
|
||||||
@@ -333,7 +333,7 @@ class HTMLPurifier_Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Raw type might be negative when using the fully optimized form
|
// Raw type might be negative when using the fully optimized form
|
||||||
// of stdclass, which indicates allow_null == true
|
// of stdClass, which indicates allow_null == true
|
||||||
$rtype = is_int($def) ? $def : $def->type;
|
$rtype = is_int($def) ? $def : $def->type;
|
||||||
if ($rtype < 0) {
|
if ($rtype < 0) {
|
||||||
$type = -$rtype;
|
$type = -$rtype;
|
||||||
|
@@ -24,11 +24,11 @@ class HTMLPurifier_ConfigSchema
|
|||||||
*
|
*
|
||||||
* array(
|
* array(
|
||||||
* 'Namespace' => array(
|
* 'Namespace' => array(
|
||||||
* 'Directive' => new stdclass(),
|
* 'Directive' => new stdClass(),
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* The stdclass may have the following properties:
|
* The stdClass may have the following properties:
|
||||||
*
|
*
|
||||||
* - If isAlias isn't set:
|
* - If isAlias isn't set:
|
||||||
* - type: Integer type of directive, see HTMLPurifier_VarParser for definitions
|
* - type: Integer type of directive, see HTMLPurifier_VarParser for definitions
|
||||||
@@ -39,8 +39,8 @@ class HTMLPurifier_ConfigSchema
|
|||||||
* - namespace: Namespace this directive aliases to
|
* - namespace: Namespace this directive aliases to
|
||||||
* - name: Directive name this directive aliases to
|
* - name: Directive name this directive aliases to
|
||||||
*
|
*
|
||||||
* In certain degenerate cases, stdclass will actually be an integer. In
|
* In certain degenerate cases, stdClass will actually be an integer. In
|
||||||
* that case, the value is equivalent to an stdclass with the type
|
* that case, the value is equivalent to an stdClass with the type
|
||||||
* property set to the integer. If the integer is negative, type is
|
* property set to the integer. If the integer is negative, type is
|
||||||
* equal to the absolute value of integer, and allow_null is true.
|
* equal to the absolute value of integer, and allow_null is true.
|
||||||
*
|
*
|
||||||
@@ -105,7 +105,7 @@ class HTMLPurifier_ConfigSchema
|
|||||||
*/
|
*/
|
||||||
public function add($key, $default, $type, $allow_null)
|
public function add($key, $default, $type, $allow_null)
|
||||||
{
|
{
|
||||||
$obj = new stdclass();
|
$obj = new stdClass();
|
||||||
$obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
|
$obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
|
||||||
if ($allow_null) {
|
if ($allow_null) {
|
||||||
$obj->allow_null = true;
|
$obj->allow_null = true;
|
||||||
@@ -152,14 +152,14 @@ class HTMLPurifier_ConfigSchema
|
|||||||
*/
|
*/
|
||||||
public function addAlias($key, $new_key)
|
public function addAlias($key, $new_key)
|
||||||
{
|
{
|
||||||
$obj = new stdclass;
|
$obj = new stdClass;
|
||||||
$obj->key = $new_key;
|
$obj->key = $new_key;
|
||||||
$obj->isAlias = true;
|
$obj->isAlias = true;
|
||||||
$this->info[$key] = $obj;
|
$this->info[$key] = $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces any stdclass that only has the type property with type integer.
|
* Replaces any stdClass that only has the type property with type integer.
|
||||||
*/
|
*/
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
|
@@ -217,9 +217,14 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
$directory = $this->generateDirectoryPath($config);
|
$directory = $this->generateDirectoryPath($config);
|
||||||
$chmod = $config->get('Cache.SerializerPermissions');
|
$chmod = $config->get('Cache.SerializerPermissions');
|
||||||
if ($chmod === null) {
|
if ($chmod === null) {
|
||||||
// TODO: This races
|
if (!@mkdir($directory) && !is_dir($directory)) {
|
||||||
if (is_dir($directory)) return true;
|
trigger_error(
|
||||||
return mkdir($directory);
|
'Could not create directory ' . $directory . '',
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
$base = $this->generateBaseDirectoryPath($config);
|
$base = $this->generateBaseDirectoryPath($config);
|
||||||
@@ -233,7 +238,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
} elseif (!$this->_testPermissions($base, $chmod)) {
|
} elseif (!$this->_testPermissions($base, $chmod)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!mkdir($directory, $chmod)) {
|
if (!@mkdir($directory, $chmod) && !is_dir($directory)) {
|
||||||
trigger_error(
|
trigger_error(
|
||||||
'Could not create directory ' . $directory . '',
|
'Could not create directory ' . $directory . '',
|
||||||
E_USER_WARNING
|
E_USER_WARNING
|
||||||
|
@@ -146,7 +146,7 @@ class HTMLPurifier_Generator
|
|||||||
$attr = $this->generateAttributes($token->attr, $token->name);
|
$attr = $this->generateAttributes($token->attr, $token->name);
|
||||||
if ($this->_flashCompat) {
|
if ($this->_flashCompat) {
|
||||||
if ($token->name == "object") {
|
if ($token->name == "object") {
|
||||||
$flash = new stdclass();
|
$flash = new stdClass();
|
||||||
$flash->attr = $token->attr;
|
$flash->attr = $token->attr;
|
||||||
$flash->param = array();
|
$flash->param = array();
|
||||||
$this->_flashStack[] = $flash;
|
$this->_flashStack[] = $flash;
|
||||||
|
@@ -157,6 +157,7 @@ abstract class HTMLPurifier_Injector
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check for exclusion
|
// check for exclusion
|
||||||
|
if (!empty($this->currentNesting)) {
|
||||||
for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) {
|
for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) {
|
||||||
$node = $this->currentNesting[$i];
|
$node = $this->currentNesting[$i];
|
||||||
$def = $this->htmlDefinition->info[$node->name];
|
$def = $this->htmlDefinition->info[$node->name];
|
||||||
@@ -164,6 +165,7 @@ abstract class HTMLPurifier_Injector
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,12 +26,14 @@ class HTMLPurifier_Length
|
|||||||
protected $isValid;
|
protected $isValid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array Lookup array of units recognized by CSS 2.1
|
* Array Lookup array of units recognized by CSS 3
|
||||||
* @type array
|
* @type array
|
||||||
*/
|
*/
|
||||||
protected static $allowedUnits = array(
|
protected static $allowedUnits = array(
|
||||||
'em' => true, 'ex' => true, 'px' => true, 'in' => true,
|
'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
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -96,7 +96,7 @@ class HTMLPurifier_Lexer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('DOMDocument') &&
|
if (class_exists('DOMDocument', false) &&
|
||||||
method_exists('DOMDocument', 'loadHTML') &&
|
method_exists('DOMDocument', 'loadHTML') &&
|
||||||
!extension_loaded('domxml')
|
!extension_loaded('domxml')
|
||||||
) {
|
) {
|
||||||
|
@@ -126,6 +126,41 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
|||||||
} while ($level > 0);
|
} 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 (property_exists($node, 'tagName')) {
|
||||||
|
return $node->tagName;
|
||||||
|
} else if (property_exists($node, 'nodeName')) {
|
||||||
|
return $node->nodeName;
|
||||||
|
} else if (property_exists($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 (property_exists($node, 'data')) {
|
||||||
|
return $node->data;
|
||||||
|
} else if (property_exists($node, 'nodeValue')) {
|
||||||
|
return $node->nodeValue;
|
||||||
|
} else if (property_exists($node, 'textContent')) {
|
||||||
|
return $node->textContent;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DOMNode $node DOMNode to be tokenized.
|
* @param DOMNode $node DOMNode to be tokenized.
|
||||||
* @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens.
|
* @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens.
|
||||||
@@ -141,7 +176,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
|||||||
// but we're not getting the character reference nodes because
|
// but we're not getting the character reference nodes because
|
||||||
// those should have been preprocessed
|
// those should have been preprocessed
|
||||||
if ($node->nodeType === XML_TEXT_NODE) {
|
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;
|
return false;
|
||||||
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
|
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
|
||||||
// undo libxml's special treatment of <script> and <style> tags
|
// undo libxml's special treatment of <script> and <style> tags
|
||||||
@@ -171,21 +209,20 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
|||||||
// not-well tested: there may be other nodes we have to grab
|
// not-well tested: there may be other nodes we have to grab
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$attr = $node->hasAttributes() ? $this->transformAttrToAssoc($node->attributes) : array();
|
$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
|
// We still have to make sure that the element actually IS empty
|
||||||
if (!$node->childNodes->length) {
|
if (!$node->childNodes->length) {
|
||||||
if ($collect) {
|
if ($collect) {
|
||||||
$tokens[] = $this->factory->createEmpty($node->tagName, $attr);
|
$tokens[] = $this->factory->createEmpty($tag_name, $attr);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if ($collect) {
|
if ($collect) {
|
||||||
$tokens[] = $this->factory->createStart(
|
$tokens[] = $this->factory->createStart($tag_name, $attr);
|
||||||
$tag_name = $node->tagName, // somehow, it get's dropped
|
|
||||||
$attr
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -197,10 +234,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
|||||||
*/
|
*/
|
||||||
protected function createEndNode($node, &$tokens)
|
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.
|
* Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.
|
||||||
*
|
*
|
||||||
|
@@ -1507,7 +1507,7 @@ class HTML5
|
|||||||
$entity = $this->character($start, $this->char);
|
$entity = $this->character($start, $this->char);
|
||||||
$cond = strlen($e_name) > 0;
|
$cond = strlen($e_name) > 0;
|
||||||
|
|
||||||
// The rest of the parsing happens bellow.
|
// The rest of the parsing happens below.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Anything else
|
// Anything else
|
||||||
@@ -1535,7 +1535,7 @@ class HTML5
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cond = isset($entity);
|
$cond = isset($entity);
|
||||||
// The rest of the parsing happens bellow.
|
// The rest of the parsing happens below.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1080,7 +1080,7 @@ class HTML5
|
|||||||
$entity = $this->character($start, $this->char);
|
$entity = $this->character($start, $this->char);
|
||||||
$cond = strlen($e_name) > 0;
|
$cond = strlen($e_name) > 0;
|
||||||
|
|
||||||
// The rest of the parsing happens bellow.
|
// The rest of the parsing happens below.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Anything else
|
// Anything else
|
||||||
@@ -1102,7 +1102,7 @@ class HTML5
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cond = isset($entity);
|
$cond = isset($entity);
|
||||||
// The rest of the parsing happens bellow.
|
// The rest of the parsing happens below.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
Type.mixed
|
Type.mixed
|
||||||
TYPE: mixed
|
TYPE: mixed
|
||||||
DEFAULT: new stdclass()
|
DEFAULT: new stdClass()
|
||||||
DESCRIPTION: The mixed type allows any type, and is not form-editable.
|
DESCRIPTION: The mixed type allows any type, and is not form-editable.
|
||||||
--# vim: et sw=4 sts=4
|
--# vim: et sw=4 sts=4
|
||||||
|
@@ -66,6 +66,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
|
|||||||
$this->assertDef('min-width:50px;');
|
$this->assertDef('min-width:50px;');
|
||||||
$this->assertDef('min-width:auto;');
|
$this->assertDef('min-width:auto;');
|
||||||
$this->assertDef('min-width:-50px;', false);
|
$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('text-decoration:underline;');
|
||||||
$this->assertDef('font-family:sans-serif;');
|
$this->assertDef('font-family:sans-serif;');
|
||||||
$this->assertDef("font-family:Gill, 'Times New Roman', 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->config->set('Core.EnableIDNA', true);
|
||||||
$this->assertDef("\xE4\xB8\xAD\xE6\x96\x87.com.cn", "xn--fiq228c.com.cn");
|
$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
|
$this->assertDef("\xe2\x80\x85.com", false); // rejected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user