golden hour
/var/www/html/wp-content/plugins/nextgen-gallery/vendor/ezyang/htmlpurifier/library/HTMLPurifier
⬆️ Go Up
Upload
File/Folder
Size
Actions
Arborize.php
2.49 KB
Del
OK
AttrCollections.php
4.75 KB
Del
OK
AttrDef
-
Del
OK
AttrDef.php
5.07 KB
Del
OK
AttrTransform
-
Del
OK
AttrTransform.php
1.94 KB
Del
OK
AttrTypes.php
3.58 KB
Del
OK
AttrValidator.php
6.42 KB
Del
OK
Bootstrap.php
4.5 KB
Del
OK
CSSDefinition.php
18.62 KB
Del
OK
ChildDef
-
Del
OK
ChildDef.php
1.52 KB
Del
OK
Config.php
30.91 KB
Del
OK
ConfigSchema
-
Del
OK
ConfigSchema.php
5.76 KB
Del
OK
ContentSets.php
5.51 KB
Del
OK
Context.php
2.57 KB
Del
OK
Definition.php
1.33 KB
Del
OK
DefinitionCache
-
Del
OK
DefinitionCache.php
3.82 KB
Del
OK
DefinitionCacheFactory.php
3.13 KB
Del
OK
Doctype.php
1.54 KB
Del
OK
DoctypeRegistry.php
4.13 KB
Del
OK
ElementDef.php
7.35 KB
Del
OK
Encoder.php
25.05 KB
Del
OK
EntityLookup
-
Del
OK
EntityLookup.php
1.39 KB
Del
OK
EntityParser.php
9.75 KB
Del
OK
ErrorCollector.php
7.45 KB
Del
OK
ErrorStruct.php
1.85 KB
Del
OK
Exception.php
177 B
Del
OK
Filter
-
Del
OK
Filter.php
1.59 KB
Del
OK
Generator.php
10.01 KB
Del
OK
HTMLDefinition.php
17.33 KB
Del
OK
HTMLModule
-
Del
OK
HTMLModule.php
9.93 KB
Del
OK
HTMLModuleManager.php
15.57 KB
Del
OK
IDAccumulator.php
1.61 KB
Del
OK
Injector
-
Del
OK
Injector.php
8.79 KB
Del
OK
Language
-
Del
OK
Language.php
5.92 KB
Del
OK
LanguageFactory.php
6.46 KB
Del
OK
Length.php
3.78 KB
Del
OK
Lexer
-
Del
OK
Lexer.php
13.12 KB
Del
OK
Node
-
Del
OK
Node.php
1.25 KB
Del
OK
PercentEncoder.php
3.48 KB
Del
OK
Printer
-
Del
OK
Printer.php
5.76 KB
Del
OK
PropertyList.php
2.72 KB
Del
OK
PropertyListIterator.php
865 B
Del
OK
Queue.php
1.51 KB
Del
OK
Strategy
-
Del
OK
Strategy.php
762 B
Del
OK
StringHash.php
1.04 KB
Del
OK
StringHashParser.php
3.56 KB
Del
OK
TagTransform
-
Del
OK
TagTransform.php
1.07 KB
Del
OK
Token
-
Del
OK
Token.php
2.17 KB
Del
OK
TokenFactory.php
3.03 KB
Del
OK
URI.php
10.35 KB
Del
OK
URIDefinition.php
3.35 KB
Del
OK
URIFilter
-
Del
OK
URIFilter.php
2.31 KB
Del
OK
URIParser.php
2.24 KB
Del
OK
URIScheme
-
Del
OK
URIScheme.php
3.4 KB
Del
OK
URISchemeRegistry.php
2.35 KB
Del
OK
UnitConverter.php
9.89 KB
Del
OK
VarParser
-
Del
OK
VarParser.php
5.85 KB
Del
OK
VarParserException.php
157 B
Del
OK
Zipper.php
4.34 KB
Del
OK
Edit: Generator.php
<?php /** * Generates HTML from tokens. * @todo Refactor interface so that configuration/context is determined * upon instantiation, no need for messy generateFromTokens() calls * @todo Make some of the more internal functions protected, and have * unit tests work around that */ class HTMLPurifier_Generator { /** * Whether or not generator should produce XML output. * @type bool */ private $_xhtml = true; /** * :HACK: Whether or not generator should comment the insides of <script> tags. * @type bool */ private $_scriptFix = false; /** * Cache of HTMLDefinition during HTML output to determine whether or * not attributes should be minimized. * @type HTMLPurifier_HTMLDefinition */ private $_def; /** * Cache of %Output.SortAttr. * @type bool */ private $_sortAttr; /** * Cache of %Output.FlashCompat. * @type bool */ private $_flashCompat; /** * Cache of %Output.FixInnerHTML. * @type bool */ private $_innerHTMLFix; /** * Stack for keeping track of object information when outputting IE * compatibility code. * @type array */ private $_flashStack = array(); /** * Configuration for the generator * @type HTMLPurifier_Config */ protected $config; /** * @param HTMLPurifier_Config $config * @param HTMLPurifier_Context $context */ public function __construct($config, $context) { $this->config = $config; $this->_scriptFix = $config->get('Output.CommentScriptContents'); $this->_innerHTMLFix = $config->get('Output.FixInnerHTML'); $this->_sortAttr = $config->get('Output.SortAttr'); $this->_flashCompat = $config->get('Output.FlashCompat'); $this->_def = $config->getHTMLDefinition(); $this->_xhtml = $this->_def->doctype->xml; } /** * Generates HTML from an array of tokens. * @param HTMLPurifier_Token[] $tokens Array of HTMLPurifier_Token * @return string Generated HTML */ public function generateFromTokens($tokens) { if (!$tokens) { return ''; } // Basic algorithm $html = ''; for ($i = 0, $size = count($tokens); $i < $size; $i++) { if ($this->_scriptFix && $tokens[$i]->name === 'script' && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) { // script special case // the contents of the script block must be ONE token // for this to work. $html .= $this->generateFromToken($tokens[$i++]); $html .= $this->generateScriptFromToken($tokens[$i++]); } $html .= $this->generateFromToken($tokens[$i]); } // Tidy cleanup if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) { $tidy = new Tidy; $tidy->parseString( $html, array( 'indent'=> true, 'output-xhtml' => $this->_xhtml, 'show-body-only' => true, 'indent-spaces' => 2, 'wrap' => 68, ), 'utf8' ); $tidy->cleanRepair(); $html = (string) $tidy; // explicit cast necessary } // Normalize newlines to system defined value if ($this->config->get('Core.NormalizeNewlines')) { $nl = $this->config->get('Output.Newline'); if ($nl === null) { $nl = PHP_EOL; } if ($nl !== "\n") { $html = str_replace("\n", $nl, $html); } } return $html; } /** * Generates HTML from a single token. * @param HTMLPurifier_Token $token HTMLPurifier_Token object. * @return string Generated HTML */ public function generateFromToken($token) { if (!$token instanceof HTMLPurifier_Token) { trigger_error('Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING); return ''; } elseif ($token instanceof HTMLPurifier_Token_Start) { $attr = $this->generateAttributes($token->attr, $token->name); if ($this->_flashCompat) { if ($token->name == "object") { $flash = new stdClass(); $flash->attr = $token->attr; $flash->param = array(); $this->_flashStack[] = $flash; } } return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; } elseif ($token instanceof HTMLPurifier_Token_End) { $_extra = ''; if ($this->_flashCompat) { if ($token->name == "object" && !empty($this->_flashStack)) { // doesn't do anything for now } } return $_extra . '</' . $token->name . '>'; } elseif ($token instanceof HTMLPurifier_Token_Empty) { if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) { $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; } $attr = $this->generateAttributes($token->attr, $token->name); return '<' . $token->name . ($attr ? ' ' : '') . $attr . ( $this->_xhtml ? ' /': '' ) // <br /> v. <br> . '>'; } elseif ($token instanceof HTMLPurifier_Token_Text) { return $this->escape($token->data, ENT_NOQUOTES); } elseif ($token instanceof HTMLPurifier_Token_Comment) { return '<!--' . $token->data . '-->'; } else { return ''; } } /** * Special case processor for the contents of script tags * @param HTMLPurifier_Token $token HTMLPurifier_Token object. * @return string * @warning This runs into problems if there's already a literal * --> somewhere inside the script contents. */ public function generateScriptFromToken($token) { if (!$token instanceof HTMLPurifier_Token_Text) { return $this->generateFromToken($token); } // Thanks <http://lachy.id.au/log/2005/05/script-comments> $data = preg_replace('#//\s*$#', '', $token->data); return '<!--//--><![CDATA[//><!--' . "\n" . trim($data) . "\n" . '//--><!]]>'; } /** * Generates attribute declarations from attribute array. * @note This does not include the leading or trailing space. * @param array $assoc_array_of_attributes Attribute array * @param string $element Name of element attributes are for, used to check * attribute minimization. * @return string Generated HTML fragment for insertion. */ public function generateAttributes($assoc_array_of_attributes, $element = '') { $html = ''; if ($this->_sortAttr) { ksort($assoc_array_of_attributes); } foreach ($assoc_array_of_attributes as $key => $value) { if (!$this->_xhtml) { // Remove namespaced attributes if (strpos($key, ':') !== false) { continue; } // Check if we should minimize the attribute: val="val" -> val if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) { $html .= $key . ' '; continue; } } // Workaround for Internet Explorer innerHTML bug. // Essentially, Internet Explorer, when calculating // innerHTML, omits quotes if there are no instances of // angled brackets, quotes or spaces. However, when parsing // HTML (for example, when you assign to innerHTML), it // treats backticks as quotes. Thus, // <img alt="``" /> // becomes // <img alt=`` /> // becomes // <img alt='' /> // Fortunately, all we need to do is trigger an appropriate // quoting style, which we do by adding an extra space. // This also is consistent with the W3C spec, which states // that user agents may ignore leading or trailing // whitespace (in fact, most don't, at least for attributes // like alt, but an extra space at the end is barely // noticeable). Still, we have a configuration knob for // this, since this transformation is not necesary if you // don't process user input with innerHTML or you don't plan // on supporting Internet Explorer. if ($this->_innerHTMLFix) { if (strpos($value, '`') !== false) { // check if correct quoting style would not already be // triggered if (strcspn($value, '"\' <>') === strlen($value)) { // protect! $value .= ' '; } } } $html .= $key.'="'.$this->escape($value).'" '; } return rtrim($html); } /** * Escapes raw text data. * @todo This really ought to be protected, but until we have a facility * for properly generating HTML here w/o using tokens, it stays * public. * @param string $string String data to escape for HTML. * @param int $quote Quoting style, like htmlspecialchars. ENT_NOQUOTES is * permissible for non-attribute output. * @return string escaped data. */ public function escape($string, $quote = null) { // Workaround for APC bug on Mac Leopard reported by sidepodcast // http://htmlpurifier.org/phorum/read.php?3,4823,4846 if ($quote === null) { $quote = ENT_COMPAT; } return htmlspecialchars($string, $quote, 'UTF-8'); } } // vim: et sw=4 sts=4
Save