* (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
[mediawiki.git] / tests / SanitizerTest.php
blob0322da6c054da758ba7db04b98790d5a3854ce2b
1 <?php
3 class SanitizerTest extends PHPUnit_Framework_TestCase {
4 function testDecodeNamed() {
5 $this->assertEquals(
6 "\xc3\xa9cole",
7 Sanitizer::decodeCharReferences( '&eacute;cole' ) );
10 function testDecodeNumbered() {
11 $this->assertEquals(
12 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
13 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&#233;cole!" ) );
16 function testDecodeMixed() {
17 $this->assertEquals(
18 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
19 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole!" ) );
22 function testDecodeMixedComplex() {
23 $this->assertEquals(
24 "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas &#x108;io dans l'&eacute;cole)",
25 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole! (mais pas &amp;#x108;io dans l'&#38;eacute;cole)" ) );
28 function testDecodeInvalidAmp() {
29 $this->assertEquals(
30 "a & b",
31 Sanitizer::decodeCharReferences( "a & b" ) );
34 function testDecodeInvalidNamed() {
35 $this->assertEquals(
36 "&foo;",
37 Sanitizer::decodeCharReferences( "&foo;" ) );
40 function testDecodeInvalidNumbered() {
41 $this->assertEquals(
42 UTF8_REPLACEMENT,
43 Sanitizer::decodeCharReferences( "&#88888888888888;" ) );
46 /* TODO: many more! */