summaryrefslogtreecommitdiffstats
path: root/application/helpers
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-02-01 21:49:32 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-02-01 21:49:32 +0100
commit15cbce87704b9f3f1b2aaddb4136d5e76a46a4ce (patch)
treea1df2a2efa8b09424418ce72237a8922cf81dee5 /application/helpers
parent111cd0fe83721506e438b4125a42d6cb0cf28809 (diff)
return_bytes(): Throw exception on unhandled unit type
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers')
-rw-r--r--application/helpers/filebin_helper.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index 05a136eb3..55fdf773d 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -375,7 +375,11 @@ function return_bytes($size_str)
case 'K': case 'k': return (int)$size_str * 1024;
case 'M': case 'm': return (int)$size_str * 1048576;
case 'G': case 'g': return (int)$size_str * 1073741824;
- default: return (int)$size_str;
+ default:
+ if (strlen($size_str) === strlen(intval($size_str))) {
+ return (int)$size_str;
+ }
+ throw new \exceptions\ApiException('filebin-helper/invalid-input-unit', "Input has invalid unit");
}
}