Skip to content

Commit 8bddfa4

Browse files
committed
improved bytes conversion method
1 parent 25d9bd2 commit 8bddfa4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Extension/Validator/Util/ServerParams.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ public function getPostMaxSize()
2929
return null;
3030
}
3131

32-
if (preg_match('#^(\d+)([bkmgt])#i', $iniMax, $match)) {
33-
$shift = array('b' => 0, 'k' => 10, 'm' => 20, 'g' => 30, 't' => 40);
34-
$iniMax = ($match[1] * (1 << $shift[strtolower($match[2])]));
32+
if (preg_match('#^\+?(0x?)?([^kmg]*)([KMG]?)#', $iniMax, $match)) {
33+
$shifts = array('' => 0, 'K' => 10, 'M' => 20, 'G' => 30);
34+
$bases = array('' => 10, '0' => 8, '0x' => 16);
35+
36+
return (intval($match[2], $bases[$match[1]]) * (1 << $shifts[$match[3]]));
3537
}
3638

37-
return (int) $iniMax;
39+
return 0;
3840
}
3941

4042
/**

0 commit comments

Comments
 (0)