Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -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
|
||||
+1
-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')) {
|
||||
|
||||
+1
-1
@@ -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.10.0
|
||||
*
|
||||
* @warning
|
||||
* You must *not* include any other HTML Purifier files before this file,
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
HTML Purifier 4.9.3 - Standards Compliant HTML Filtering
|
||||
HTML Purifier 4.10.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.10.0';
|
||||
|
||||
/**
|
||||
* Constant with version of HTML Purifier.
|
||||
*/
|
||||
const VERSION = '4.9.3';
|
||||
const VERSION = '4.10.0';
|
||||
|
||||
/**
|
||||
* Global configuration object.
|
||||
|
||||
@@ -97,7 +97,7 @@ 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);
|
||||
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
|
||||
|
||||
// If we have Net_IDNA2 support, we can support IRIs by
|
||||
// punycoding them. (This is the most portable thing to do,
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class HTMLPurifier_Config
|
||||
* HTML Purifier's version
|
||||
* @type string
|
||||
*/
|
||||
public $version = '4.9.3';
|
||||
public $version = '4.10.0';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically finalize
|
||||
|
||||
@@ -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
|
||||
|
||||
+7
-5
@@ -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;
|
||||
|
||||
+4
-2
@@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
+47
-10
@@ -126,6 +126,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 (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 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
|
||||
// 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 +209,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 +234,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;
|
||||
}
|
||||
|
||||
|
||||
+39
-28
@@ -1032,7 +1032,7 @@ class CallbackBody extends Callback {
|
||||
$param3 = null) {
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 2);
|
||||
$this->callback = create_function($paramList, $code);
|
||||
//$this->callback = create_function($paramList, $code);
|
||||
$this->params = $params;
|
||||
}
|
||||
}
|
||||
@@ -2083,16 +2083,18 @@ class phpQueryObject
|
||||
break;
|
||||
case 'parent':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node', '
|
||||
function( $node ) {
|
||||
return $node instanceof DOMELEMENT && $node->childNodes->length
|
||||
? $node : null;')
|
||||
? $node : null;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'empty':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node', '
|
||||
function( $node ) {
|
||||
return $node instanceof DOMELEMENT && $node->childNodes->length
|
||||
? null : $node;')
|
||||
? null : $node;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'disabled':
|
||||
@@ -2105,19 +2107,21 @@ class phpQueryObject
|
||||
break;
|
||||
case 'enabled':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node', '
|
||||
return pq($node)->not(":disabled") ? $node : null;')
|
||||
function( $node ) {
|
||||
return pq($node)->not(":disabled") ? $node : null;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'header':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node',
|
||||
'$isHeader = isset($node->tagName) && in_array($node->tagName, array(
|
||||
function( $node ) {
|
||||
$isHeader = isset($node->tagName) && in_array($node->tagName, array(
|
||||
"h1", "h2", "h3", "h4", "h5", "h6", "h7"
|
||||
));
|
||||
return $isHeader
|
||||
? $node
|
||||
: null;')
|
||||
: null;
|
||||
}
|
||||
)->elements;
|
||||
// $this->elements = $this->map(
|
||||
// create_function('$node', '$node = pq($node);
|
||||
@@ -2134,18 +2138,23 @@ class phpQueryObject
|
||||
break;
|
||||
case 'only-child':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node',
|
||||
'return pq($node)->siblings()->size() == 0 ? $node : null;')
|
||||
function( $node ) {
|
||||
return pq($node)->siblings()->size() == 0 ? $node : null;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'first-child':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node', 'return pq($node)->prevAll()->size() == 0 ? $node : null;')
|
||||
function( $node ) {
|
||||
return pq($node)->prevAll()->size() == 0 ? $node : null;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'last-child':
|
||||
$this->elements = $this->map(
|
||||
create_function('$node', 'return pq($node)->nextAll()->size() == 0 ? $node : null;')
|
||||
function( $node ) {
|
||||
return pq($node)->nextAll()->size() == 0 ? $node : null;
|
||||
}
|
||||
)->elements;
|
||||
break;
|
||||
case 'nth-child':
|
||||
@@ -2158,21 +2167,22 @@ class phpQueryObject
|
||||
// :nth-child(index/even/odd/equation)
|
||||
if ($param == 'even' || $param == 'odd')
|
||||
$mapped = $this->map(
|
||||
create_function('$node, $param',
|
||||
'$index = pq($node)->prevAll()->size()+1;
|
||||
function( $node, $param ) {
|
||||
$index = pq($node)->prevAll()->size()+1;
|
||||
if ($param == "even" && ($index%2) == 0)
|
||||
return $node;
|
||||
else if ($param == "odd" && $index%2 == 1)
|
||||
return $node;
|
||||
else
|
||||
return null;'),
|
||||
return null;
|
||||
},
|
||||
new CallbackParam(), $param
|
||||
);
|
||||
else if (mb_strlen($param) > 1 && $param{1} == 'n')
|
||||
// an+b
|
||||
$mapped = $this->map(
|
||||
create_function('$node, $param',
|
||||
'$prevs = pq($node)->prevAll()->size();
|
||||
function( $node, $param ) {
|
||||
$prevs = pq($node)->prevAll()->size();
|
||||
$index = 1+$prevs;
|
||||
$b = mb_strlen($param) > 3
|
||||
? $param{3}
|
||||
@@ -2205,20 +2215,21 @@ class phpQueryObject
|
||||
// return ($index-$b)%$a == 0
|
||||
// ? $node
|
||||
// : null;
|
||||
'),
|
||||
},
|
||||
new CallbackParam(), $param
|
||||
);
|
||||
else
|
||||
// index
|
||||
$mapped = $this->map(
|
||||
create_function('$node, $index',
|
||||
'$prevs = pq($node)->prevAll()->size();
|
||||
function( $node, $index ) {
|
||||
$prevs = pq($node)->prevAll()->size();
|
||||
if ($prevs && $prevs == $index-1)
|
||||
return $node;
|
||||
else if (! $prevs && $index == 1)
|
||||
return $node;
|
||||
else
|
||||
return null;'),
|
||||
return null;
|
||||
},
|
||||
new CallbackParam(), $param
|
||||
);
|
||||
$this->elements = $mapped->elements;
|
||||
@@ -4742,15 +4753,15 @@ abstract class phpQuery {
|
||||
while (preg_match($regex, $content))
|
||||
$content = preg_replace_callback(
|
||||
$regex,
|
||||
create_function('$m',
|
||||
'return $m[1].$m[2].$m[3]."<?php "
|
||||
function( $m ) {
|
||||
return $m[1].$m[2].$m[3]."<?php "
|
||||
.str_replace(
|
||||
array("%20", "%3E", "%09", " ", "	", "%7B", "%24", "%7D", "%22", "%5B", "%5D"),
|
||||
array(" ", ">", " ", "\n", " ", "{", "$", "}", \'"\', "[", "]"),
|
||||
array(" ", ">", " ", "\n", " ", "{", "$", "}", '"', "[", "]"),
|
||||
htmlspecialchars_decode($m[4])
|
||||
)
|
||||
." ?>".$m[5].$m[2];'
|
||||
),
|
||||
." ?>".$m[5].$m[2];
|
||||
},
|
||||
$content
|
||||
);
|
||||
return $content;
|
||||
|
||||
Reference in new issue
Block a user