Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Form] fix parsing invalid floating point numbers#24460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.7fromxabbuh:pr-22586
Oct 10, 2017

Conversation

@xabbuh
Copy link
Member

@xabbuhxabbuh commentedOct 6, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#19854,#22586
LicenseMIT
Doc PR

Should make AppVeyor builds pass again. Code borrowed fromNumberToLocalizedStringTransformer.

}

return$value;
if (function_exists('mb_detect_encoding') &&false !==$encoding =mb_detect_encoding($value,null,true)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

function_exists should be fully qualified to benefit from PHP 7 compile-time evaluation


return$value;
if (function_exists('mb_detect_encoding') &&false !==$encoding =mb_detect_encoding($value,null,true)) {
$length =mb_strlen($value,$encoding);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Are you sure about it ?NumberFormatter::parse is documented as setting the offset in the string on php.net. This offset will be based on bytes, not on characters, so you should not be usingmb_strlen

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nope, I just adapted the code from theNumberToLocalizedStringTransformer. Seems this was done on purpose in#7902.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I looked at the tests for theNumberToLocalizedStringTransformer and copied over some of them. They prove that we indeed need to use the mbstring extension (for example, the exception message intestReverseTransformDisallowsCenteredExtraCharactersMultibyte() would not match otherwise).

$remainder =trim($remainder,"\t\n\r\0\x0b\xc2\xa0");

if ('' !==$remainder) {
thrownewTransformationFailedException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need tests reaching this new exception

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

PercentToLocalizedStringTransformerTest ::testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() is failing without this change on the3.4 branch on AppVeyor:https://ci.appveyor.com/project/fabpot/symfony/build/1.0.28085#L1537

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It may be necessary to replace \Locale::setDefault('de_AT'); by\Locale::setDefault('de_DE'); at

as for

See alsoaa3c66e

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

See also comment#19854 (comment)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@jakzal Why was the change inaa3c66e necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Did you see the comment#19854 (comment) ? You have maybe not see the previous link

ICU data was indeed changed for de_AT. It is taken from cldr though, which also has this bit
changed. So it looks like it's a bug in CLDR (unless Austria really got rid of the period as a >grouping separator).

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@aaa2000 Indeed, changing the locale tode_DE fixes the initial issue.

@xabbuh
Copy link
MemberAuthor

Status: Needs Review


if ('' !==$remainder) {
thrownewTransformationFailedException(
sprintf('The number contains unrecognized characters: "%s"',$remainder)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

exception should be on one line

$length =mb_strlen($value,$encoding);
$remainder =mb_substr($value,$position,$length,$encoding);
}else {
$length =strlen($value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commit042eac4 intosymfony:2.7Oct 10, 2017
fabpot added a commit that referenced this pull requestOct 10, 2017
This PR was merged into the 2.7 branch.Discussion----------[Form] fix parsing invalid floating point numbers| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#19854,#22586| License       | MIT| Doc PR        |Should make AppVeyor builds pass again. Code borrowed from `NumberToLocalizedStringTransformer`.Commits-------042eac4 [Form] fix parsing invalid floating point numbers
@xabbuhxabbuh deleted the pr-22586 branchOctober 10, 2017 06:04
This was referencedNov 10, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr left review comments

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofAwaiting requested review from stof

+1 more reviewer

@aaa2000aaa2000aaa2000 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

7 participants

@xabbuh@fabpot@aaa2000@nicolas-grekas@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp