Issue #3156879 by alexpott, Krzysztof Domański: \Drupal\Component\Utility\Bytes::toInt() - ensure $size is a number type
parent
90c7d4c3c3
commit
ff72265395
|
@ -35,7 +35,8 @@ class Bytes {
|
|||
return round($size * pow(self::KILOBYTE, stripos('bkmgtpezy', $unit[0])));
|
||||
}
|
||||
else {
|
||||
return round($size);
|
||||
// Ensure size is a proper number type.
|
||||
return round((float) $size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ class BytesTest extends TestCase {
|
|||
['76MRandomStringThatShouldBeIgnoredByParseSize.', 79691776],
|
||||
// 76.24 GB (with typo).
|
||||
['76.24 Giggabyte', 81862076662],
|
||||
['1.5', 2],
|
||||
['2.4', 2],
|
||||
['', 0],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue