PATH:
home
/
letacommog
/
letaweb
/
admin
/
classes
/
htmlpurifier
/
tests
/
HTMLPurifier
<?php class HTMLPurifier_PercentEncoderTest extends HTMLPurifier_Harness { protected $PercentEncoder; protected $func; public function setUp() { $this->PercentEncoder = new HTMLPurifier_PercentEncoder(); $this->func = ''; } public function assertDecode($string, $expect = true) { if ($expect === true) { $expect = $string; } $this->assertIdentical($this->PercentEncoder->{$this->func}($string), $expect); } public function test_normalize() { $this->func = 'normalize'; $this->assertDecode('Aw.../-$^8'); // no change $this->assertDecode('%41%77%7E%2D%2E%5F', 'Aw~-._'); // decode unreserved chars $this->assertDecode('%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D'); // preserve reserved chars $this->assertDecode('%2b', '%2B'); // normalize to uppercase $this->assertDecode('%2B2B%3A3A'); // extra text $this->assertDecode('%2b2B%4141', '%2B2BA41'); // extra text, with normalization $this->assertDecode('%', '%25'); // normalize stray percent sign $this->assertDecode('%5%25', '%255%25'); // permaturely terminated encoding $this->assertDecode('%GJ', '%25GJ'); // invalid hexadecimal chars // contested behavior, if this changes, we'll also have to have // outbound encoding $this->assertDecode('%FC'); // not reserved or unreserved, preserve } public function assertEncode($string, $expect = true, $preserve = false) { if ($expect === true) { $expect = $string; } $encoder = new HTMLPurifier_PercentEncoder($preserve); $result = $encoder->encode($string); $this->assertIdentical($result, $expect); } public function test_encode_noChange() { $this->assertEncode('abc012-_~.'); } public function test_encode_encode() { $this->assertEncode('>', '%3E'); } public function test_encode_preserve() { $this->assertEncode('<>', '<%3E', '<'); } public function test_encode_low() { $this->assertEncode("\1", '%01'); } } // vim: et sw=4 sts=4
[+]
..
[+]
AttrTransform
[-] HTMLModuleTest.php
[edit]
[-] HTMLModuleManagerTest.php
[edit]
[-] VarParserHarness.php
[edit]
[-] EntityParserTest.php
[edit]
[-] HTMLT.php
[edit]
[-] IDAccumulatorTest.php
[edit]
[-] LengthTest.php
[edit]
[-] ChildDefHarness.php
[edit]
[+]
SimpleTest
[-] ConfigSchemaTest.php
[edit]
[-] Harness.php
[edit]
[-] EntityLookupTest.php
[edit]
[-] URISchemeRegistryTest.php
[edit]
[+]
ConfigSchema
[-] URIDefinitionTest.php
[edit]
[-] ErrorCollectorEMock.php
[edit]
[+]
Filter
[-] ErrorsHarness.php
[edit]
[-] HTMLModuleHarness.php
[edit]
[-] InjectorHarness.php
[edit]
[-] AttrTransformHarness.php
[edit]
[-] URIFilterHarness.php
[edit]
[-] LanguageFactoryTest.php
[edit]
[+]
PHPT
[+]
Injector
[-] UnitConverterTest.php
[edit]
[-] TokenTest.php
[edit]
[-] LexerTest.php
[edit]
[-] GeneratorTest.php
[edit]
[-] DefinitionTestable.php
[edit]
[-] AttrDefTest.php
[edit]
[-] StringHashParserTest.php
[edit]
[+]
AttrDef
[-] HTMLDefinitionTest.php
[edit]
[-] DefinitionCacheTest.php
[edit]
[+]
HTMLT
[-] ConfigTest-loadIni.ini
[edit]
[+]
VarParser
[-] URISchemeTest.php
[edit]
[-] StrategyHarness.php
[edit]
[+]
ChildDef
[-] AttrDefHarness.php
[edit]
[-] AttrTransformTest.php
[edit]
[-] URIParserTest.php
[edit]
[+]
DefinitionCache
[-] DefinitionTest.php
[edit]
[-] TokenFactoryTest.php
[edit]
[-] ElementDefTest.php
[edit]
[-] DefinitionCacheFactoryTest.php
[edit]
[-] StringHashTest.php
[edit]
[-] ContextTest.php
[edit]
[-] URITest.php
[edit]
[-] ConfigTest.php
[edit]
[-] AttrValidator_ErrorsTest.php
[edit]
[-] URIHarness.php
[edit]
[+]
StringHashParser
[+]
HTMLModule
[-] LanguageTest.php
[edit]
[+]
Strategy
[-] DoctypeRegistryTest.php
[edit]
[-] AttrTypesTest.php
[edit]
[-] PercentEncoderTest.php
[edit]
[-] TagTransformTest.php
[edit]
[-] EncoderTest.php
[edit]
[+]
URIFilter
[-] PropertyListTest.php
[edit]
[-] ConfigTest-create.ini
[edit]
[-] ErrorCollectorTest.php
[edit]
[-] ConfigTest-finalize.ini
[edit]
[+]
Lexer
[-] ComplexHarness.php
[edit]
[-] DefinitionCacheHarness.php
[edit]
[-] AttrCollectionsTest.php
[edit]