Issue #3156879 by alexpott, Krzysztof Domański: \Drupal\Component\Utility\Bytes::toInt() - ensure $size is a number type

merge-requests/2/head
Lee Rowlands 2020-07-31 11:47:00 +10:00
parent 90c7d4c3c3
commit ff72265395
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
2 changed files with 5 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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],
];
}