MDL-14898 upgraded html purifier to 3.1.0 in HEAD
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/Generator.php';
|
||||
require_once 'HTMLPurifier/Token.php';
|
||||
require_once 'HTMLPurifier/Encoder.php';
|
||||
|
||||
// OUT OF DATE, NEEDS UPDATING!
|
||||
// USE XMLWRITER!
|
||||
|
||||
class HTMLPurifier_Printer
|
||||
{
|
||||
@@ -12,26 +9,27 @@ class HTMLPurifier_Printer
|
||||
/**
|
||||
* Instance of HTMLPurifier_Generator for HTML generation convenience funcs
|
||||
*/
|
||||
var $generator;
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* Instance of HTMLPurifier_Config, for easy access
|
||||
*/
|
||||
var $config;
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Initialize $generator.
|
||||
*/
|
||||
function HTMLPurifier_Printer() {
|
||||
public function __construct() {
|
||||
$this->generator = new HTMLPurifier_Generator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Give generator necessary configuration if possible
|
||||
*/
|
||||
function prepareGenerator($config) {
|
||||
public function prepareGenerator($config) {
|
||||
// hack for smoketests/configForm.php
|
||||
if (empty($config->conf['HTML'])) return;
|
||||
$all = $config->getAll();
|
||||
if (empty($all['HTML'])) return;
|
||||
$context = new HTMLPurifier_Context();
|
||||
$this->generator->generateFromTokens(array(), $config, $context);
|
||||
}
|
||||
@@ -47,7 +45,7 @@ class HTMLPurifier_Printer
|
||||
* @param $tag Tag name
|
||||
* @param $attr Attribute array
|
||||
*/
|
||||
function start($tag, $attr = array()) {
|
||||
protected function start($tag, $attr = array()) {
|
||||
return $this->generator->generateFromToken(
|
||||
new HTMLPurifier_Token_Start($tag, $attr ? $attr : array())
|
||||
);
|
||||
@@ -57,7 +55,7 @@ class HTMLPurifier_Printer
|
||||
* Returns an end teg
|
||||
* @param $tag Tag name
|
||||
*/
|
||||
function end($tag) {
|
||||
protected function end($tag) {
|
||||
return $this->generator->generateFromToken(
|
||||
new HTMLPurifier_Token_End($tag)
|
||||
);
|
||||
@@ -70,19 +68,19 @@ class HTMLPurifier_Printer
|
||||
* @param $attr Tag attributes
|
||||
* @param $escape Bool whether or not to escape contents
|
||||
*/
|
||||
function element($tag, $contents, $attr = array(), $escape = true) {
|
||||
protected function element($tag, $contents, $attr = array(), $escape = true) {
|
||||
return $this->start($tag, $attr) .
|
||||
($escape ? $this->escape($contents) : $contents) .
|
||||
$this->end($tag);
|
||||
}
|
||||
|
||||
function elementEmpty($tag, $attr = array()) {
|
||||
protected function elementEmpty($tag, $attr = array()) {
|
||||
return $this->generator->generateFromToken(
|
||||
new HTMLPurifier_Token_Empty($tag, $attr)
|
||||
);
|
||||
}
|
||||
|
||||
function text($text) {
|
||||
protected function text($text) {
|
||||
return $this->generator->generateFromToken(
|
||||
new HTMLPurifier_Token_Text($text)
|
||||
);
|
||||
@@ -93,7 +91,7 @@ class HTMLPurifier_Printer
|
||||
* @param $name Key
|
||||
* @param $value Value
|
||||
*/
|
||||
function row($name, $value) {
|
||||
protected function row($name, $value) {
|
||||
if (is_bool($value)) $value = $value ? 'On' : 'Off';
|
||||
return
|
||||
$this->start('tr') . "\n" .
|
||||
@@ -107,7 +105,7 @@ class HTMLPurifier_Printer
|
||||
* Escapes a string for HTML output.
|
||||
* @param $string String to escape
|
||||
*/
|
||||
function escape($string) {
|
||||
protected function escape($string) {
|
||||
$string = HTMLPurifier_Encoder::cleanUTF8($string);
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
|
||||
return $string;
|
||||
@@ -118,7 +116,7 @@ class HTMLPurifier_Printer
|
||||
* @param $array List of strings
|
||||
* @param $polite Bool whether or not to add an end before the last
|
||||
*/
|
||||
function listify($array, $polite = false) {
|
||||
protected function listify($array, $polite = false) {
|
||||
if (empty($array)) return 'None';
|
||||
$ret = '';
|
||||
$i = count($array);
|
||||
@@ -136,7 +134,7 @@ class HTMLPurifier_Printer
|
||||
* @param $obj Object to determine class of
|
||||
* @param $prefix Further prefix to remove
|
||||
*/
|
||||
function getClass($obj, $sec_prefix = '') {
|
||||
protected function getClass($obj, $sec_prefix = '') {
|
||||
static $five = null;
|
||||
if ($five === null) $five = version_compare(PHP_VERSION, '5', '>=');
|
||||
$prefix = 'HTMLPurifier_' . $sec_prefix;
|
||||
@@ -152,14 +150,14 @@ class HTMLPurifier_Printer
|
||||
}
|
||||
$class .= implode(', ', $values);
|
||||
break;
|
||||
case 'composite':
|
||||
case 'css_composite':
|
||||
$values = array();
|
||||
foreach ($obj->defs as $def) {
|
||||
$values[] = $this->getClass($def, $sec_prefix);
|
||||
}
|
||||
$class .= implode(', ', $values);
|
||||
break;
|
||||
case 'multiple':
|
||||
case 'css_multiple':
|
||||
$class .= $this->getClass($obj->single, $sec_prefix) . ', ';
|
||||
$class .= $obj->max;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user