Only trim off the last letter in bytesize if it's actually there
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 18 May 2003 11:33:14 +0000 (11:33 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 18 May 2003 11:33:14 +0000 (11:33 +0000)
(ie not really bytes). Thanks E. van Elk. Fixes #730742.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4877 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/compose.php

index a7080c9..35d370d 100644 (file)
@@ -1289,22 +1289,26 @@ function getByteSize($ini_size) {
 
     $ini_size = trim($ini_size);
 
-    switch(strtoupper(substr($ini_size, -1))) {
-        case 'G':
-           $bytesize = 1073741824;
-           break;
-        case 'M':
-           $bytesize = 1048576;
-           break;
-        case 'K':
-           $bytesize = 1024;
-           break;
-        default:
-           $bytesize = 1;
+    // if there's some kind of letter at the end of the string we need to multiply.
+    if(!is_numeric(substr($ini_size, -1))) {
+
+        switch(strtoupper(substr($ini_size, -1))) {
+            case 'G':
+               $bytesize = 1073741824;
+               break;
+            case 'M':
+               $bytesize = 1048576;
+               break;
+            case 'K':
+               $bytesize = 1024;
+               break;
+        }
+
+        $bytesize *= (int)substr($ini_size, 0, -1);
     }
+        
+
 
-    $bytesize *= (int)substr($ini_size, 0, -1);
-       
     return $bytesize;
 }