? includes/common.test
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.770
diff -u -p -r1.770 common.inc
--- includes/common.inc	30 May 2008 17:41:51 -0000	1.770
+++ includes/common.inc	7 Jun 2008 14:21:34 -0000
@@ -1050,21 +1050,16 @@ function format_plural($count, $singular
  * Parse a given byte count.
  *
  * @param $size
- *   A size expressed as a number of bytes with optional SI size and unit
- *   suffix (e.g. 2, 3K, 5MB, 10G).
+ *   A size expressed as a number of bytes with optional SI or IEC binary unit
+ *   prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8 bytes, 9mbytes).
  * @return
  *   An integer representation of the size.
  */
 function parse_size($size) {
-  $suffixes = array(
-    '' => 1,
-    'k' => 1024,
-    'm' => 1048576, // 1024 * 1024
-    'g' => 1073741824, // 1024 * 1024 * 1024
-  );
-  if (preg_match('/([0-9]+)\s*(k|m|g)?(b?(ytes?)?)/i', $size, $match)) {
-    return $match[1] * $suffixes[drupal_strtolower($match[2])];
-  }
+  $unit = preg_replace('/[0-9\. ]|ilo|iga/i', '', $size);
+  $k = (strcasecmp($unit[1], 'i') === 0) ? 1024 : 1000; // kibibyte or kilobyte?
+  $size = intval($size);
+  return $size * pow($k, stripos('bkmgtpezy', $unit[0]));
 }
 
 /**
