Source for file decodeheader.php

Documentation is available at decodeheader.php

  1. <?php
  2.  
  3. /**
  4.  * SquirrelMail Test Plugin
  5.  *
  6.  * This page tests the decodeHeader function.
  7.  *
  8.  * @copyright 2006-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: decodeheader.php 14840 2020-01-07 07:42:38Z pdontthink $
  11.  * @package plugins
  12.  * @subpackage test
  13.  */
  14.  
  15. define('SM_PATH''../../');
  16. include_once(SM_PATH 'include/validate.php');
  17. include_once(SM_PATH 'functions/mime.php');
  18.  
  19. global $oTemplate$color;
  20.  
  21. displayPageHeader($color'none');
  22.  
  23.  
  24. $header array("< &  \xC3",                   // plain text
  25.                 '=?iso-8859-1?Q?=3C_&__=C3?='// Q encoding
  26.                 '=?iso-8859-1?B?PCAmICDD?=',   // B encoding
  27.                 '=?utf-8?Q?=3C_&__=C3=80?=',   // Q encoding other charset
  28.                 '=?utf-8?B?PCAmICDDgA==?=',    // B encoding other charset
  29. );
  30.  
  31.  
  32. if (sqGetGlobalVar('lossy'$lossySQ_GET)) {
  33.     if ($lossy{
  34.         $lossy_encoding true;
  35.     else {
  36.         if ($default_charset == 'utf-8'
  37.             $default_charset 'iso-8859-1';
  38.         $lossy_encoding false;
  39.     }
  40. }
  41.  
  42.  
  43. echo "<strong>decodeHeader() Test:</strong>\n";
  44.  
  45.  
  46. if ($default_charset == 'utf-8' || $lossy_encoding{
  47.     echo '<p><a href="decodeheader.php?lossy=0">Test with lossy_encoding OFF</a></p>';
  48. else {
  49.     echo '<p><a href="decodeheader.php?lossy=1">Test with lossy_encoding ON</a></p>';
  50. }
  51.  
  52.  
  53. echo '<p>Default charset: ' $default_charset "<br />\n"
  54.    . 'Lossy_encoding: ' ($lossy_encoding 'true' 'false''</p>';
  55.  
  56.  
  57. 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>';
  58.  
  59.  
  60. echo '<pre>';
  61.  
  62.  
  63. echo "(MDN) 000:\n html chars are not encoded,\n space is not encoded,\n 8bit chars are unmodified\n";
  64. foreach ($header as $test{
  65.     echo htmlentities(decodeHeader($testfalsefalsefalse));
  66.     echo "\n";
  67. }
  68. echo "--------\n";
  69.  
  70.  
  71. 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";
  72. foreach ($header as $test{
  73.     echo htmlentities(decodeHeader($testfalsefalsetrue));
  74.     echo "\n";
  75. }
  76. echo "--------\n";
  77.  
  78.  
  79. echo "010\n";
  80. foreach ($header as $test{
  81.     echo htmlentities(decodeHeader($testfalsetruefalse));
  82.     echo "\n";
  83. }
  84. echo "--------\n";
  85.  
  86.  
  87. echo "011\n";
  88. foreach ($header as $test{
  89.     echo htmlentities(decodeHeader($testfalsetruetrue));
  90.     echo "\n";
  91. }
  92. echo "--------\n";
  93.  
  94.  
  95. echo "(download) 100\n";
  96. foreach ($header as $test{
  97.     echo htmlentities(decodeHeader($testtruefalsefalse));
  98.     echo "\n";
  99. }
  100. echo "--------\n";
  101.  
  102.  
  103. echo "101\n";
  104. foreach ($header as $test{
  105.     echo htmlentities(decodeHeader($testtruefalsetrue));
  106.     echo "\n";
  107. }
  108. echo "--------\n";
  109.  
  110.  
  111. echo "(default) 110\n";
  112. foreach ($header as $test{
  113.     echo htmlentities(decodeHeader($testtruetruefalse));
  114.     echo "\n";
  115. }
  116. echo "--------\n";
  117.  
  118.  
  119. echo "111\n";
  120. foreach ($header as $test{
  121.     echo htmlentities(decodeHeader($testtruetruetrue));
  122.     echo "\n";
  123. }
  124. echo "--------\n";
  125.  
  126.  
  127. echo '</pre></body></html>';

Documentation generated on Mon, 13 Jan 2020 04:24:28 +0100 by phpDocumentor 1.4.3