From: pdontthink Date: Thu, 14 May 2009 17:03:10 +0000 (+0000) Subject: Add documentation and default case to catch unknown suffixes to getByteSize() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5fe7d6831d601d0bdb88d5a117736b1e986dcd07;p=squirrelmail.git Add documentation and default case to catch unknown suffixes to getByteSize() git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13701 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/src/compose.php b/src/compose.php index 1b8dfd73..bd5599f2 100644 --- a/src/compose.php +++ b/src/compose.php @@ -1484,7 +1484,21 @@ function saveAttachedFiles($session) { $composeMessage->initAttachment($type, $name, $localfilename); } -/* parse values like 8M and 2k into bytes */ +/** + * Parse strings such as "8M" and "2k" into their corresponding size in bytes + * + * NOTE: This function only recognizes the suffixes "K", "M" and "G" + * and will probably break very easily if the given size is in + * some completely different format. + * + * @param string $ini_size The input string to be converted + * + * @return mixed Boolean FALSE if something went wrong (the value passed in + * was empty?, the suffix was not recognized?), otherwise, the + * converted size in bytes (just the number (as an integer), + * no unit identifier included) + * + */ function getByteSize($ini_size) { if(!$ini_size) { @@ -1506,6 +1520,8 @@ function getByteSize($ini_size) { case 'K': $bytesize = 1024; break; + default: + return FALSE; } return ($bytesize * (int)substr($ini_size, 0, -1));