From: <pdo...@us...> - 2009-05-14 17:03:25
|
Revision: 13701 http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=13701&view=rev Author: pdontthink Date: 2009-05-14 17:03:10 +0000 (Thu, 14 May 2009) Log Message: ----------- Add documentation and default case to catch unknown suffixes to getByteSize() Modified Paths: -------------- trunk/squirrelmail/src/compose.php Modified: trunk/squirrelmail/src/compose.php =================================================================== --- trunk/squirrelmail/src/compose.php 2009-05-14 10:31:37 UTC (rev 13700) +++ trunk/squirrelmail/src/compose.php 2009-05-14 17:03:10 UTC (rev 13701) @@ -1484,7 +1484,21 @@ $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 @@ case 'K': $bytesize = 1024; break; + default: + return FALSE; } return ($bytesize * (int)substr($ini_size, 0, -1)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |