Move bottomscripts down to just above the </body>, outside of the globalWrapper ...
[lhc/web/wiklou.git] / t / inc / Sanitizer.t
1 #!/usr/bin/env php
2 <?php
3
4 require 't/Test.php';
5
6 plan( 13 );
7
8 define( 'MEDIAWIKI', 1 );
9 require_ok( 'includes/Defines.php' );
10 require_ok( 'includes/GlobalFunctions.php' );
11 require_ok( 'includes/Sanitizer.php' );
12 require_ok( 'includes/normal/UtfNormal.php' );
13 require_ok( 'includes/ProfilerStub.php' ); # For removeHTMLtags
14
15
16 #
17 # decodeCharReferences
18 #
19
20 cmp_ok(
21 Sanitizer::decodeCharReferences( '&eacute;cole' ),
22 '==',
23 "\xc3\xa9cole",
24 'decode named entities'
25 );
26
27 cmp_ok(
28 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&#233;cole!" ),
29 '==',
30 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
31 'decode numeric entities'
32 );
33
34 cmp_ok(
35 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole!" ),
36 '==',
37 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
38 'decode mixed numeric/named entities'
39 );
40
41 cmp_ok(
42 Sanitizer::decodeCharReferences(
43 "&#x108;io bonas dans l'&eacute;cole! (mais pas &amp;#x108;io dans l'&#38;eacute;cole)"
44 ),
45 '==',
46 "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas &#x108;io dans l'&eacute;cole)",
47 'decode mixed complex entities'
48 );
49
50 cmp_ok( Sanitizer::decodeCharReferences( 'a & b' ), '==', 'a & b', 'Invalid ampersand' );
51
52 cmp_ok( Sanitizer::decodeCharReferences( '&foo;' ), '==', '&foo;', 'Invalid named entity' );
53
54 cmp_ok( Sanitizer::decodeCharReferences( "&#88888888888888;" ), '==', UTF8_REPLACEMENT, 'Invalid numbered entity' );
55
56 $wgUseTidy = false;
57 cmp_ok(
58 Sanitizer::removeHTMLtags( '<div>Hello world</div />' ),
59 '==',
60 '<div>Hello world</div>',
61 'Self-closing closing div'
62 );
63
64 /* vim: set filetype=php: */