Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40b547e

Browse filesBrowse files
bug #28540 [Intl] parse numbers terminated with decimal separator (xabbuh)
This PR was merged into the 2.8 branch. Discussion ---------- [Intl] parse numbers terminated with decimal separator | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28500 | License | MIT | Doc PR | Commits ------- 4225f36 parse numbers terminated with decimal separator
2 parents 2c8c6f7 + 4225f36 commit 40b547e
Copy full SHA for 40b547e

File tree

Expand file treeCollapse file tree

2 files changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-1
lines changed

‎src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
516516
$groupSep = $this->getAttribute(self::GROUPING_USED) ? ',' : '';
517517

518518
// Any string before the numeric value causes error in the parsing
519-
if (preg_match("/^-?(?:\.\d++|([\d{$groupSep}]++)(?:\.\d++)?)/", $value, $matches)) {
519+
if (preg_match("/^-?(?:\.\d++|([\d{$groupSep}]++)(?:\.\d*+)?)/", $value, $matches)) {
520520
$value = $matches[0];
521521
$position = \strlen($value);
522522
if ($error = $groupSep && isset($matches[1]) && !preg_match('/^\d{1,3}+(?:(?:,\d{3})++|\d*+)$/', $matches[1])) {

‎src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ public function parseProvider()
654654
array('-123,4567', false, '->parse() does not parse when invalid grouping used.', 9),
655655
array('-123,,456', false, '->parse() does not parse when invalid grouping used.', 4),
656656
array('-123,,456', -123.0, '->parse() parses when grouping is disabled.', 4, false),
657+
array('239.', 239.0, '->parse() parses when string ends with decimal separator.', 4, false),
657658
);
658659
}
659660

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.