"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/vendors/htmlpurifier/HTMLPurifier.standalone.php" between
yii-1.1.21.733ac5.tar.gz and yii-1.1.22.bf1d26.tar.gz

About: Yii is a high-performance component-based PHP framework for developing large-scale Web applications. Hint: Yii 1.1 is now in maintenance mode.

HTMLPurifier.standalone.php  (yii-1.1.21.733ac5):HTMLPurifier.standalone.php  (yii-1.1.22.bf1d26)
<?php <?php
/** /**
* @file * @file
* This file was auto-generated by generate-includes.php and includes all of * This file was auto-generated by generate-includes.php and includes all of
* the core files required by HTML Purifier. Use this if performance is a * the core files required by HTML Purifier. Use this if performance is a
* 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.3 * @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,
* because 'require' not 'require_once' is used. * because 'require' not 'require_once' is used.
* *
* @warning * @warning
* This file requires that the include path contains the HTML Purifier * This file requires that the include path contains the HTML Purifier
* library directory; this is not auto-set. * library directory; this is not auto-set.
*/ */
skipping to change at line 40 skipping to change at line 40
* -# Making the tokens well-formed, * -# Making the tokens well-formed,
* -# Fixing the nesting of the nodes, and * -# Fixing the nesting of the nodes, and
* -# Validating attributes of the nodes; and * -# Validating attributes of the nodes; and
* -# Generating HTML from the purified tokens. * -# Generating HTML from the purified tokens.
* *
* However, most users will only need to interface with the HTMLPurifier * However, most users will only need to interface with the HTMLPurifier
* and HTMLPurifier_Config. * and HTMLPurifier_Config.
*/ */
/* /*
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 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
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
skipping to change at line 79 skipping to change at line 79
* @todo We need an easier way to inject strategies using the configuration * @todo We need an easier way to inject strategies using the configuration
* object. * object.
*/ */
class HTMLPurifier class HTMLPurifier
{ {
/** /**
* Version of HTML Purifier. * Version of HTML Purifier.
* @type string * @type string
*/ */
public $version = '4.9.3'; public $version = '4.10.0';
/** /**
* Constant with version of HTML Purifier. * Constant with version of HTML Purifier.
*/ */
const VERSION = '4.9.3'; const VERSION = '4.10.0';
/** /**
* Global configuration object. * Global configuration object.
* @type HTMLPurifier_Config * @type HTMLPurifier_Config
*/ */
public $config; public $config;
/** /**
* Array of extra filter objects to run on HTML, * Array of extra filter objects to run on HTML,
* for backwards compatibility. * for backwards compatibility.
skipping to change at line 1722 skipping to change at line 1722
* *
* @todo Reconsider some of the public member variables * @todo Reconsider some of the public member variables
*/ */
class HTMLPurifier_Config class HTMLPurifier_Config
{ {
/** /**
* HTML Purifier's version * HTML Purifier's version
* @type string * @type string
*/ */
public $version = '4.9.3'; public $version = '4.10.0';
/** /**
* Whether or not to automatically finalize * Whether or not to automatically finalize
* the object if a read operation is done. * the object if a read operation is done.
* @type bool * @type bool
*/ */
public $autoFinalize = true; public $autoFinalize = true;
// protected member variables // protected member variables
skipping to change at line 3860 skipping to change at line 3860
// codepoints. Instead of having to convert back into UTF-8, we've // codepoints. Instead of having to convert back into UTF-8, we've
// decided to directly append valid UTF-8 characters onto a string // decided to directly append valid UTF-8 characters onto a string
// $out once they're done. $char accumulates raw bytes, while $mUcs4 // $out once they're done. $char accumulates raw bytes, while $mUcs4
// turns into the Unicode code point, so there's some redundancy. // turns into the Unicode code point, so there's some redundancy.
$out = ''; $out = '';
$char = ''; $char = '';
$len = strlen($str); $len = strlen($str);
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
$in = ord($str{$i}); $in = ord($str[$i]);
$char .= $str[$i]; // append byte to char $char .= $str[$i]; // append byte to char
if (0 == $mState) { if (0 == $mState) {
// When mState is zero we expect either a US-ASCII character // When mState is zero we expect either a US-ASCII character
// or a multi-octet sequence. // or a multi-octet sequence.
if (0 == (0x80 & ($in))) { if (0 == (0x80 & ($in))) {
// US-ASCII, pass straight through. // US-ASCII, pass straight through.
if (($in <= 31 || $in == 127) && if (($in <= 31 || $in == 127) &&
!($in == 9 || $in == 13 || $in == 10) // save \r\t\n !($in == 9 || $in == 13 || $in == 10) // save \r\t\n
) { ) {
// control characters, remove // control characters, remove
skipping to change at line 6743 skipping to change at line 6743
$parent_token = array_pop($this->currentNesting); $parent_token = array_pop($this->currentNesting);
$this->currentNesting[] = $parent_token; $this->currentNesting[] = $parent_token;
$parent = $this->htmlDefinition->info[$parent_token->name]; $parent = $this->htmlDefinition->info[$parent_token->name];
} else { } else {
$parent = $this->htmlDefinition->info_parent_def; $parent = $this->htmlDefinition->info_parent_def;
} }
if (!isset($parent->child->elements[$name]) || isset($parent->excludes[$ name])) { if (!isset($parent->child->elements[$name]) || isset($parent->excludes[$ name])) {
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];
if (isset($def->excludes[$name])) { if (isset($def->excludes[$name])) {
return false; return false;
} }
} }
}
return true; return true;
} }
/** /**
* Iterator function, which starts with the next token and continues until * Iterator function, which starts with the next token and continues until
* you reach the end of the input tokens. * you reach the end of the input tokens.
* @warning Please prevent previous references from interfering with this * @warning Please prevent previous references from interfering with this
* functions by setting $i = null beforehand! * functions by setting $i = null beforehand!
* @param int $i Current integer index variable for inputTokens * @param int $i Current integer index variable for inputTokens
* @param HTMLPurifier_Token $current Current token variable. * @param HTMLPurifier_Token $current Current token variable.
skipping to change at line 7297 skipping to change at line 7299
*/ */
protected $unit; protected $unit;
/** /**
* Whether or not this length is valid. Null if not calculated yet. * Whether or not this length is valid. Null if not calculated yet.
* @type bool * @type bool
*/ */
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
); );
/** /**
* @param string $n Magnitude * @param string $n Magnitude
* @param bool|string $u Unit * @param bool|string $u Unit
*/ */
public function __construct($n = '0', $u = false) public function __construct($n = '0', $u = false)
{ {
$this->n = (string) $n; $this->n = (string) $n;
$this->unit = $u !== false ? (string) $u : false; $this->unit = $u !== false ? (string) $u : false;
skipping to change at line 12963 skipping to change at line 12967
$toplabel = "$an(?:$and*$an)?"; $toplabel = "$an(?:$and*$an)?";
// hostname = *( domainlabel "." ) toplabel [ "." ] // hostname = *( domainlabel "." ) toplabel [ "." ]
if (preg_match("/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $match es)) { if (preg_match("/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $match es)) {
if (!ctype_digit($matches[1])) { if (!ctype_digit($matches[1])) {
return $string; return $string;
} }
} }
// 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); if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_V
ARIANT_UTS46')) {
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, I
NTL_IDNA_VARIANT_UTS46);
} else {
$string = idn_to_ascii($string);
}
// 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,
// since otherwise we have to assume browsers support // since otherwise we have to assume browsers support
} elseif ($config->get('Core.EnableIDNA')) { } elseif ($config->get('Core.EnableIDNA')) {
$idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => fals e, 'strict' => true)); $idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => fals e, 'strict' => true));
// we need to encode each period separately // we need to encode each period separately
$parts = explode('.', $string); $parts = explode('.', $string);
try { try {
$new_parts = array(); $new_parts = array();
skipping to change at line 14091 skipping to change at line 14099
$this->dtd_regex = $dtd_regex; $this->dtd_regex = $dtd_regex;
$this->_compileRegex(); $this->_compileRegex();
} }
/** /**
* Compiles the PCRE regex from a DTD regex ($dtd_regex to $_pcre_regex) * Compiles the PCRE regex from a DTD regex ($dtd_regex to $_pcre_regex)
*/ */
protected function _compileRegex() protected function _compileRegex()
{ {
$raw = str_replace(' ', '', $this->dtd_regex); $raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') { if ($raw[0] != '(') {
$raw = "($raw)"; $raw = "($raw)";
} }
$el = '[#a-zA-Z0-9_.-]+'; $el = '[#a-zA-Z0-9_.-]+';
$reg = $raw; $reg = $raw;
// COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M // COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M
// DOING! Seriously: if there's problems, please report them. // DOING! Seriously: if there's problems, please report them.
// collect all elements into the $elements array // collect all elements into the $elements array
preg_match_all("/$el/", $reg, $matches); preg_match_all("/$el/", $reg, $matches);
skipping to change at line 15153 skipping to change at line 15161
/** /**
* Prepares the directory that this type stores the serials in * Prepares the directory that this type stores the serials in
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @return bool True if successful * @return bool True if successful
*/ */
private function _prepareDir($config) private function _prepareDir($config)
{ {
$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);
if (!is_dir($base)) { if (!is_dir($base)) {
trigger_error( trigger_error(
'Base directory ' . $base . ' does not exist, 'Base directory ' . $base . ' does not exist,
please create or change using %Cache.SerializerPath', please create or change using %Cache.SerializerPath',
E_USER_WARNING E_USER_WARNING
); );
return false; return false;
} 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
); );
return false; return false;
} }
if (!$this->_testPermissions($directory, $chmod)) { if (!$this->_testPermissions($directory, $chmod)) {
return false; return false;
} }
} elseif (!$this->_testPermissions($directory, $chmod)) { } elseif (!$this->_testPermissions($directory, $chmod)) {
skipping to change at line 18284 skipping to change at line 18297
$level--; $level--;
if ($level && isset($closingNodes[$level])) { if ($level && isset($closingNodes[$level])) {
while ($node = array_pop($closingNodes[$level])) { while ($node = array_pop($closingNodes[$level])) {
$this->createEndNode($node, $tokens); $this->createEndNode($node, $tokens);
} }
} }
} 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 tok ens. * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tok ens.
* @param bool $collect Says whether or start and close are collected, set to * @param bool $collect Says whether or start and close are collected, set to
* false at first recursion because it's the implicit DIV * false at first recursion because it's the implicit DIV
* tag you're dealing with. * tag you're dealing with.
* @return bool if the token needs an endtoken * @return bool if the token needs an endtoken
* @todo data and tagName properties don't seem to exist in DOMNode? * @todo data and tagName properties don't seem to exist in DOMNode?
*/ */
protected function createStartNode($node, &$tokens, $collect, $config) protected function createStartNode($node, &$tokens, $collect, $config)
{ {
// intercept non element nodes. WE MUST catch all of them, // intercept non element nodes. WE MUST catch all of them,
// 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
$last = end($tokens); $last = end($tokens);
$data = $node->data; $data = $node->data;
// (note $node->tagname is already normalized) // (note $node->tagname is already normalized)
if ($last instanceof HTMLPurifier_Token_Start && ($last->name == 'sc ript' || $last->name == 'style')) { if ($last instanceof HTMLPurifier_Token_Start && ($last->name == 'sc ript' || $last->name == 'style')) {
$new_data = trim($data); $new_data = trim($data);
if (substr($new_data, 0, 4) === '<!--') { if (substr($new_data, 0, 4) === '<!--') {
$data = substr($new_data, 4); $data = substr($new_data, 4);
skipping to change at line 18328 skipping to change at line 18378
} elseif ($node->nodeType === XML_COMMENT_NODE) { } elseif ($node->nodeType === XML_COMMENT_NODE) {
// this is code is only invoked for comments in script/style in vers ions // this is code is only invoked for comments in script/style in vers ions
// of libxml pre-2.6.28 (regular comments, of course, are still // of libxml pre-2.6.28 (regular comments, of course, are still
// handled regularly) // handled regularly)
$tokens[] = $this->factory->createComment($node->data); $tokens[] = $this->factory->createComment($node->data);
return false; return false;
} elseif ($node->nodeType !== XML_ELEMENT_NODE) { } elseif ($node->nodeType !== XML_ELEMENT_NODE) {
// 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->attr ibutes) : array(); $attr = $node->hasAttributes() ? $this->transformAttrToAssoc($node->attr ibutes) : array();
$tag_name = $this->getTagName($node); // Handle variable tagName propert
y
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;
} }
} }
/** /**
* @param DOMNode $node * @param DOMNode $node
* @param HTMLPurifier_Token[] $tokens * @param HTMLPurifier_Token[] $tokens
*/ */
protected function createEndNode($node, &$tokens) protected function createEndNode($node, &$tokens)
{ {
$tokens[] = $this->factory->createEnd($node->tagName); $tag_name = $this->getTagName($node); // Handle variable tagName propert
y
$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.
* *
* @param DOMNamedNodeMap $node_map DOMNamedNodeMap of DOMAttr objects. * @param DOMNamedNodeMap $node_map DOMNamedNodeMap of DOMAttr objects.
* @return array Associative array of attributes. * @return array Associative array of attributes.
*/ */
protected function transformAttrToAssoc($node_map) protected function transformAttrToAssoc($node_map)
{ {
skipping to change at line 20319 skipping to change at line 20369
// handle face transform // handle face transform
if (isset($attr['face'])) { if (isset($attr['face'])) {
$prepend_style .= 'font-family:' . $attr['face'] . ';'; $prepend_style .= 'font-family:' . $attr['face'] . ';';
unset($attr['face']); unset($attr['face']);
} }
// handle size transform // handle size transform
if (isset($attr['size'])) { if (isset($attr['size'])) {
// normalize large numbers // normalize large numbers
if ($attr['size'] !== '') { if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size']; $size = (int)$attr['size'];
if ($size < -2) { if ($size < -2) {
$attr['size'] = '-2'; $attr['size'] = '-2';
} }
if ($size > 4) { if ($size > 4) {
$attr['size'] = '+4'; $attr['size'] = '+4';
} }
} else { } else {
$size = (int)$attr['size']; $size = (int)$attr['size'];
if ($size > 7) { if ($size > 7) {
 End of changes. 22 change blocks. 
24 lines changed or deleted 78 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)