mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
PSR-2 reformatting PHPDoc corrections
With minor corrections. Signed-off-by: Marcus Bointon <marcus@synchromedia.co.uk> Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
committed by
Edward Z. Yang
parent
19eee14899
commit
fac747bdbd
@@ -5,18 +5,21 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
|
||||
protected $_entity_lookup;
|
||||
|
||||
function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
function assertCleanUTF8($string, $expect = null) {
|
||||
public function assertCleanUTF8($string, $expect = null)
|
||||
{
|
||||
if ($expect === null) $expect = $string;
|
||||
$this->assertIdentical(HTMLPurifier_Encoder::cleanUTF8($string), $expect, 'iconv: %s');
|
||||
$this->assertIdentical(HTMLPurifier_Encoder::cleanUTF8($string, true), $expect, 'PHP: %s');
|
||||
}
|
||||
|
||||
function test_cleanUTF8() {
|
||||
public function test_cleanUTF8()
|
||||
{
|
||||
$this->assertCleanUTF8('Normal string.');
|
||||
$this->assertCleanUTF8("Test\tAllowed\nControl\rCharacters");
|
||||
$this->assertCleanUTF8("null byte: \0", 'null byte: ');
|
||||
@@ -29,7 +32,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
$this->assertCleanUTF8("\xED\xB0\x80", '');
|
||||
}
|
||||
|
||||
function test_convertToUTF8_noConvert() {
|
||||
public function test_convertToUTF8_noConvert()
|
||||
{
|
||||
// UTF-8 means that we don't touch it
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
|
||||
@@ -38,7 +42,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertToUTF8_spuriousEncoding() {
|
||||
public function test_convertToUTF8_spuriousEncoding()
|
||||
{
|
||||
if (!HTMLPurifier_Encoder::iconvAvailable()) return;
|
||||
$this->config->set('Core.Encoding', 'utf99');
|
||||
$this->expectError('Invalid encoding utf99');
|
||||
@@ -48,7 +53,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertToUTF8_iso8859_1() {
|
||||
public function test_convertToUTF8_iso8859_1()
|
||||
{
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
|
||||
@@ -56,7 +62,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertToUTF8_withoutIconv() {
|
||||
public function test_convertToUTF8_withoutIconv()
|
||||
{
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->config->set('Test.ForceNoIconv', true);
|
||||
$this->assertIdentical(
|
||||
@@ -66,11 +73,13 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function getZhongWen() {
|
||||
public function getZhongWen()
|
||||
{
|
||||
return "\xE4\xB8\xAD\xE6\x96\x87 (Chinese)";
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_utf8() {
|
||||
public function test_convertFromUTF8_utf8()
|
||||
{
|
||||
// UTF-8 means that we don't touch it
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
|
||||
@@ -78,7 +87,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_iso8859_1() {
|
||||
public function test_convertFromUTF8_iso8859_1()
|
||||
{
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
|
||||
@@ -87,7 +97,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_iconvNoChars() {
|
||||
public function test_convertFromUTF8_iconvNoChars()
|
||||
{
|
||||
if (!HTMLPurifier_Encoder::iconvAvailable()) return;
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->assertIdentical(
|
||||
@@ -96,7 +107,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_phpNormal() {
|
||||
public function test_convertFromUTF8_phpNormal()
|
||||
{
|
||||
// Plain PHP implementation has slightly different behavior
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->config->set('Test.ForceNoIconv', true);
|
||||
@@ -107,7 +119,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_phpNoChars() {
|
||||
public function test_convertFromUTF8_phpNoChars()
|
||||
{
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->config->set('Test.ForceNoIconv', true);
|
||||
$this->assertIdentical(
|
||||
@@ -116,7 +129,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_withProtection() {
|
||||
public function test_convertFromUTF8_withProtection()
|
||||
{
|
||||
// Preserve the characters!
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
$this->config->set('Core.EscapeNonASCIICharacters', true);
|
||||
@@ -126,7 +140,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertFromUTF8_withProtectionButUtf8() {
|
||||
public function test_convertFromUTF8_withProtectionButUtf8()
|
||||
{
|
||||
// Preserve the characters!
|
||||
$this->config->set('Core.EscapeNonASCIICharacters', true);
|
||||
$this->assertIdentical(
|
||||
@@ -135,8 +150,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_convertToASCIIDumbLossless() {
|
||||
|
||||
public function test_convertToASCIIDumbLossless()
|
||||
{
|
||||
// Uppercase thorn letter
|
||||
$this->assertIdentical(
|
||||
HTMLPurifier_Encoder::convertToASCIIDumbLossless("\xC3\x9Eorn"),
|
||||
@@ -156,7 +171,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function assertASCIISupportCheck($enc, $ret) {
|
||||
public function assertASCIISupportCheck($enc, $ret)
|
||||
{
|
||||
$test = HTMLPurifier_Encoder::testEncodingSupportsASCII($enc, true);
|
||||
if ($test === false) return;
|
||||
$this->assertIdentical(
|
||||
@@ -169,7 +185,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_testEncodingSupportsASCII() {
|
||||
public function test_testEncodingSupportsASCII()
|
||||
{
|
||||
if (HTMLPurifier_Encoder::iconvAvailable()) {
|
||||
$this->assertASCIISupportCheck('Shift_JIS', array("\xC2\xA5" => '\\', "\xE2\x80\xBE" => '~'));
|
||||
$this->assertASCIISupportCheck('JOHAB', array("\xE2\x82\xA9" => '\\'));
|
||||
@@ -178,7 +195,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
$this->assertASCIISupportCheck('dontexist', array()); // canary
|
||||
}
|
||||
|
||||
function testShiftJIS() {
|
||||
public function testShiftJIS()
|
||||
{
|
||||
if (!HTMLPurifier_Encoder::iconvAvailable()) return;
|
||||
$this->config->set('Core.Encoding', 'Shift_JIS');
|
||||
// This actually looks like a Yen, but we're going to treat it differently
|
||||
@@ -192,7 +210,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function testIconvTruncateBug() {
|
||||
public function testIconvTruncateBug()
|
||||
{
|
||||
if (!HTMLPurifier_Encoder::iconvAvailable()) return;
|
||||
if (HTMLPurifier_Encoder::testIconvTruncateBug() !== HTMLPurifier_Encoder::ICONV_TRUNCATES) return;
|
||||
$this->config->set('Core.Encoding', 'ISO-8859-1');
|
||||
@@ -202,7 +221,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function testIconvChunking() {
|
||||
public function testIconvChunking()
|
||||
{
|
||||
if (!HTMLPurifier_Encoder::iconvAvailable()) return;
|
||||
if (HTMLPurifier_Encoder::testIconvTruncateBug() !== HTMLPurifier_Encoder::ICONV_TRUNCATES) return;
|
||||
$this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "a\xF3\xA0\x80\xA0b", 4), 'ab');
|
||||
|
Reference in New Issue
Block a user