3d708401 |
1 | <?php |
2 | |
3 | /** |
4 | * SquirrelMail Test Plugin |
5 | * |
6 | * This page tests the decodeHeader function. |
7 | * |
1977ab55 |
8 | * @copyright 2006-2010 The SquirrelMail Project Team |
3d708401 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
3656ccef |
10 | * @version $Id$ |
3d708401 |
11 | * @package plugins |
12 | * @subpackage test |
13 | */ |
14 | |
15 | include_once('../../include/init.php'); |
16 | include_once(SM_PATH . 'functions/mime.php'); |
17 | |
18 | global $oTemplate, $color; |
19 | |
a2ecd93e |
20 | displayPageHeader($color, ''); |
3d708401 |
21 | |
22 | |
23 | $header = array("< & \xC3", // plain text |
24 | '=?iso-8859-1?Q?=3C_&__=C3?=', // Q encoding |
25 | '=?iso-8859-1?B?PCAmICDD?=', // B encoding |
26 | '=?utf-8?Q?=3C_&__=C3=80?=', // Q encoding other charset |
27 | '=?utf-8?B?PCAmICDDgA==?=', // B encoding other charset |
28 | ); |
29 | |
30 | |
31 | if (sqGetGlobalVar('lossy', $lossy, SQ_GET)) { |
32 | if ($lossy) { |
33 | $lossy_encoding = true; |
34 | } else { |
35 | if ($default_charset == 'utf-8') |
36 | $default_charset = 'iso-8859-1'; |
37 | $lossy_encoding = false; |
38 | } |
39 | } |
40 | |
41 | |
42 | // NOTE: Not bothering to "templatize" the following output, since |
43 | // this plugin is merely an administrative (and not user-facing) |
44 | // tool. If this is really important to you, please help by |
45 | // submitting the work to the team. |
46 | |
47 | |
48 | echo "<strong>decodeHeader() Test:</strong>\n"; |
49 | |
50 | |
51 | if ($default_charset == 'utf-8' || $lossy_encoding) { |
52 | echo '<p><a href="decodeheader.php?lossy=0">Test with lossy_encoding OFF</a></p>'; |
53 | } else { |
54 | echo '<p><a href="decodeheader.php?lossy=1">Test with lossy_encoding ON</a></p>'; |
55 | } |
56 | |
57 | |
58 | echo '<p>Default charset: ' . $default_charset . "<br />\n" |
59 | . 'Lossy_encoding: ' . ($lossy_encoding ? 'true' : 'false') . '</p>'; |
60 | |
61 | |
62 | echo '<p>The results of this test depend on your current language (translation) selection (see Options==>Display Preferences) (and the character set it employs) and your $lossy_encoding setting (see config/config.php or conf.pl ==> 10 ==> 5).</p>'; |
63 | |
64 | |
65 | echo '<pre>'; |
66 | |
67 | |
68 | echo "(MDN) 000:\n html chars are not encoded,\n space is not encoded,\n 8bit chars are unmodified\n"; |
69 | foreach ($header as $test) { |
70 | echo htmlentities(decodeHeader($test, false, false, false)); |
71 | echo "\n"; |
72 | } |
73 | echo "--------\n"; |
74 | |
75 | |
76 | echo "(compose) 001:\n html chars are not encoded,\n space is not encoded,\n 8bit chars may be converted or not (depends on \$lossy_encoding and \$default_charset)\n"; |
77 | foreach ($header as $test) { |
78 | echo htmlentities(decodeHeader($test, false, false, true)); |
79 | echo "\n"; |
80 | } |
81 | echo "--------\n"; |
82 | |
83 | |
84 | echo "010\n"; |
85 | foreach ($header as $test) { |
86 | echo htmlentities(decodeHeader($test, false, true, false)); |
87 | echo "\n"; |
88 | } |
89 | echo "--------\n"; |
90 | |
91 | |
92 | echo "011\n"; |
93 | foreach ($header as $test) { |
94 | echo htmlentities(decodeHeader($test, false, true, true)); |
95 | echo "\n"; |
96 | } |
97 | echo "--------\n"; |
98 | |
99 | |
100 | echo "(download) 100\n"; |
101 | foreach ($header as $test) { |
102 | echo htmlentities(decodeHeader($test, true, false, false)); |
103 | echo "\n"; |
104 | } |
105 | echo "--------\n"; |
106 | |
107 | |
108 | echo "101\n"; |
109 | foreach ($header as $test) { |
110 | echo htmlentities(decodeHeader($test, true, false, true)); |
111 | echo "\n"; |
112 | } |
113 | echo "--------\n"; |
114 | |
115 | |
116 | echo "(default) 110\n"; |
117 | foreach ($header as $test) { |
118 | echo htmlentities(decodeHeader($test, true, true, false)); |
119 | echo "\n"; |
120 | } |
121 | echo "--------\n"; |
122 | |
123 | |
124 | echo "111\n"; |
125 | foreach ($header as $test) { |
126 | echo htmlentities(decodeHeader($test, true, true, true)); |
127 | echo "\n"; |
128 | } |
129 | echo "--------\n"; |
130 | |
131 | |
132 | echo '</pre>'; |
133 | |
134 | $oTemplate->display('footer.tpl'); |
135 | |
136 | |