Skip to content

Commit

Permalink
Additional update for processwire/processwire-issues#1502
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancramerdesign committed Jan 7, 2022
1 parent 85e0501 commit 38506eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.3.8",
"php": ">=5.5",
"ext-gd": "*"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions wire/core/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3927,7 +3927,7 @@ public function float($value, array $options = array()) {
$str = ltrim($str, '-');
}

if(stripos($str, 'E-') && preg_match('/^([0-9., ]+\d)(E\-\d+)/i', $str, $m)) {
if((stripos($str, 'E-') || stripos($str, 'E+')) && preg_match('/^([0-9., ]+\d)(E[-+]\d+)/i', $str, $m)) {
$str = $m[1];
$append = $m[2];
}
Expand Down Expand Up @@ -3984,7 +3984,7 @@ public function float($value, array $options = array()) {

if($options['getString']) {
if($options['precision'] === null) {
$value = strpos($value, 'E-') ? rtrim(sprintf('%.20f', (float) $value), '0') : "$value";
$value = strpos($value, 'E-') || strpos($value, 'E+') ? rtrim(sprintf('%.20f', (float) $value), '0') : "$value";
} else {
$value = sprintf('%.' . $options['precision'] . 'f', (float) $value);
}
Expand Down
2 changes: 1 addition & 1 deletion wire/modules/Inputfield/InputfieldFloat.module
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class InputfieldFloat extends InputfieldInteger {
$attributes['step'] = '.' . ($precision > 1 ? str_repeat('0', $precision - 1) : '') . '1';
}
}
if($attributes && isset($attributes['value']) && strpos($attributes['value'], 'E-')) {
if($attributes && isset($attributes['value']) && stripos($attributes['value'], 'E')) {
$attributes['value'] = $this->wire()->sanitizer->float($attributes['value'], array(
'getString' => true,
));
Expand Down

0 comments on commit 38506eb

Please sign in to comment.