Match floating point numbers as well
authorTim Düsterhus <timwolla@arcor.de>
Mon, 12 Dec 2011 14:09:17 +0000 (15:09 +0100)
committerTim Düsterhus <timwolla@arcor.de>
Mon, 12 Dec 2011 14:12:08 +0000 (15:12 +0100)
Valid numbers are (when . is the decimal-point):
1024
1.02
.5

wcfsetup/install/files/lib/system/option/FileSizeOptionType.class.php

index 0d20ef10c769d6228ef3fdca28102098d082fa1f..f647c6b71ed99e265401bf758aeb973c541c3142 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\option;
 use wcf\data\option\Option;
+use wcf\system\WCF;
 use wcf\util\FileUtil;
 use wcf\util\StringUtil;
 
@@ -19,7 +20,11 @@ class FileSizeOptionType extends IntegerOptionType {
         * @see wcf\system\option\IOptionType::getData()
         */
        public function getData(Option $option, $newValue) {
-               $number = intval($newValue);
+               $number = StringUtil::replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
+               $d = preg_quote(WCF::getLanguage()->get('wcf.global.decimalPoint'), '~');
+               if (!preg_match('~^(?:\d*)(?:'.$d.')?\d+~', $number, $matches)) return 0;
+               
+               $number = $matches[0];
                if (preg_match('/[kmgt]i?b$/i', $newValue, $multiplier)) {
                        switch (StringUtil::toLowerCase($multiplier[0])) {
                                case 'tb':