mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-13 02:36:19 +02:00
Merge in r657-674, prompted by near release of 1.4.0.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@675 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@ -5,7 +5,7 @@ require_once 'HTMLPurifier/Encoder.php';
|
||||
class HTMLPurifier_EncoderTest extends UnitTestCase
|
||||
{
|
||||
|
||||
var $Encoder;
|
||||
var $_entity_lookup;
|
||||
|
||||
function setUp() {
|
||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||
@ -60,6 +60,9 @@ class HTMLPurifier_EncoderTest extends UnitTestCase
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
// zhong-wen
|
||||
$chinese = "\xE4\xB8\xAD\xE6\x96\x87 (Chinese)";
|
||||
|
||||
// UTF-8 means that we don't touch it
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $config, $context),
|
||||
@ -74,13 +77,55 @@ class HTMLPurifier_EncoderTest extends UnitTestCase
|
||||
"\xF6"
|
||||
);
|
||||
|
||||
$config->set('Test', 'ForceNoIconv', true);
|
||||
if (function_exists('iconv')) {
|
||||
// iconv has it's own way
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8($chinese, $config, $context),
|
||||
" (Chinese)"
|
||||
);
|
||||
}
|
||||
|
||||
// Plain PHP implementation has slightly different behavior
|
||||
$config->set('Test', 'ForceNoIconv', true);
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $config, $context),
|
||||
"\xF6"
|
||||
);
|
||||
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8($chinese, $config, $context),
|
||||
"?? (Chinese)"
|
||||
);
|
||||
|
||||
// Preserve the characters!
|
||||
|
||||
$config->set('Core', 'EscapeNonASCIICharacters', true);
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8($chinese, $config, $context),
|
||||
"中文 (Chinese)"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function test_convertToASCIIDumbLossless() {
|
||||
|
||||
// Uppercase thorn letter
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToASCIIDumbLossless("\xC3\x9Eorn"),
|
||||
"Þorn"
|
||||
);
|
||||
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToASCIIDumbLossless("an"),
|
||||
"an"
|
||||
);
|
||||
|
||||
// test up to four bytes
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToASCIIDumbLossless("\xF3\xA0\x80\xA0"),
|
||||
"󠀠"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user