* Adds code for the Konqueror workaround
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 14 Mar 2001 15:21:12 +0000 (15:21 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 14 Mar 2001 15:21:12 +0000 (15:21 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1195 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index 3b7371140ccb755de0b024b2269ca6826a7bac9b..1cf6be0d74acb36f46161f7e33b6679a68757e63 100644 (file)
    // Auto-detection
    //
    // if $send (the form button's name) contains "\n" as the first char
-   // and the script is compose.php, then trim everything.  Otherwise,
-   // we don't have to worry.
+   // or "\r\n" as the first two (compensating for RedHat's flawed package
+   // and Konqueror, respectively), and the script is compose.php, then
+   // trim everything.  Otherwise, we don't have to worry.
+   //
+   // If RedHat ever gets PHP officially upgraded past package php-4.0.4pl1-3
+   // or if Konqueror and PHP start working together, modify/remove this hack
    global $send, $PHP_SELF;
-   if (isset($send) && substr($send, 0, 1) == "\n" &&
-       substr($PHP_SELF, -12) == "/compose.php")
+   $trimChars = 0;
+   if (isset($send) && substr($PHP_SELF, -12) == "/compose.php")
+   {
+       if (substr($send, 0, 1) == "\n")
+           $trimChars = 1;
+       if (substr($send, 0, 2) == "\r\n")
+           $trimChars = 2;
+   }
+   if ($trimChars)
    {
       if ($REQUEST_METHOD == "POST") {
-         TrimArray($HTTP_POST_VARS);
+         TrimArray($HTTP_POST_VARS, $trimChars);
       } else {
-         TrimArray($HTTP_GET_VARS);
+         TrimArray($HTTP_GET_VARS, $trimChars);
       }
    }
 
    //**************************************************************************
    // Trims every element in the array
    //**************************************************************************
-   function TrimArray(&$array) {
+   function TrimArray(&$array, $trimChars) {
       foreach ($array as $k => $v) {
          global $$k;
          if (is_array($$k)) {
             foreach ($$k as $k2 => $v2) {
-              $$k[$k2] = substr($v2, 1);
+              $$k[$k2] = substr($v2, $trimChars);
             }
          } else {
-            $$k = substr($v, 1);
+            $$k = substr($v, $trimChars);
          }
       }
    }