1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 13:47:24 +02:00

[1.4.0] Make all functions in Encoder static. Affects branches/strict

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@656 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-01-18 22:55:44 +00:00
parent 2816ae535f
commit ad1169c711
4 changed files with 21 additions and 16 deletions

View File

@@ -91,7 +91,6 @@ class HTMLPurifier
$this->lexer = HTMLPurifier_Lexer::create();
$this->strategy = new HTMLPurifier_Strategy_Core();
$this->generator = new HTMLPurifier_Generator();
$this->encoder = new HTMLPurifier_Encoder();
}
@@ -110,7 +109,7 @@ class HTMLPurifier
$config = $config ? HTMLPurifier_Config::create($config) : $this->config;
$context = new HTMLPurifier_Context();
$html = $this->encoder->convertToUTF8($html, $config, $context);
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
// purified HTML
$html =
@@ -127,7 +126,7 @@ class HTMLPurifier
$config, $context
);
$html = $this->encoder->convertFromUTF8($html, $config, $context);
$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
$this->context =& $context;
return $html;
}

View File

@@ -38,10 +38,18 @@ HTMLPurifier_ConfigSchema::define(
/**
* A UTF-8 specific character encoder that handles cleaning and transforming.
* @note All functions in this class should be static.
*/
class HTMLPurifier_Encoder
{
/**
* Constructor throws fatal error if you attempt to instantiate class
*/
function HTMLPurifier_Encoder() {
trigger_error('Cannot instantiate encoder, call methods statically', E_USER_ERROR);
}
/**
* Cleans a UTF-8 string for well-formedness and SGML validity
*
@@ -290,6 +298,7 @@ class HTMLPurifier_Encoder
/**
* Converts a string to UTF-8 based on configuration.
* @static
*/
function convertToUTF8($str, $config, &$context) {
static $iconv = null;
@@ -305,6 +314,7 @@ class HTMLPurifier_Encoder
/**
* Converts a string from UTF-8 based on configuration.
* @static
* @note Currently, this is a lossy conversion, with unexpressable
* characters being omitted.
*/

View File

@@ -56,7 +56,6 @@ class HTMLPurifier_Lexer
{
function HTMLPurifier_Lexer() {
$this->_encoder = new HTMLPurifier_Encoder();
$this->_entity_parser = new HTMLPurifier_EntityParser();
}
@@ -114,8 +113,6 @@ class HTMLPurifier_Lexer
return $string;
}
var $_encoder;
/**
* Lexes an HTML string into tokens.
*
@@ -216,7 +213,7 @@ class HTMLPurifier_Lexer
// clean into wellformed UTF-8 string for an SGML context: this has
// to be done after entity expansion because the entities sometimes
// represent non-SGML characters (horror, horror!)
$html = $this->_encoder->cleanUTF8($html);
$html = HTMLPurifier_Encoder::cleanUTF8($html);
return $html;
}