Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] IntegerType: reject submitted non-integer numbers #30329

Merged
merged 1 commit into from Feb 23, 2019

Conversation

Projects
None yet
6 participants
@xabbuh
Copy link
Member

xabbuh commented Feb 21, 2019

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10240
License MIT
Doc PR

@xabbuh xabbuh added this to the 3.4 milestone Feb 21, 2019

@fabpot

fabpot approved these changes Feb 21, 2019

@xabbuh

This comment has been minimized.

Copy link
Member Author

xabbuh commented Feb 21, 2019

Status: Needs work

@@ -40,6 +42,12 @@ public function __construct($scale = 0, $grouping = false, $roundingMode = self:
*/
public function reverseTransform($value)
{
$decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
if (\is_string($value) && false !== strpos($value, $decimalSeparator)) {

This comment has been minimized.

Copy link
@yceruto

yceruto Feb 21, 2019

Contributor

The transformation is invoked in reverse order in DateIntervalType when widget = integer, also in the model layer, so it could receive a real floating value here, isn't it?

This comment has been minimized.

Copy link
@xabbuh

xabbuh Feb 21, 2019

Author Member

Can you give an example? I am not sure that I understand what you mean.

This comment has been minimized.

Copy link
@yceruto

yceruto Feb 21, 2019

Contributor

if ('integer' === $options['widget']) {
$childForm->addModelTransformer(
new ReversedTransformer(
new IntegerToLocalizedStringTransformer()
)
);
}

This comment has been minimized.

Copy link
@yceruto

yceruto Feb 21, 2019

Contributor

Unlike IntegerType this transformation is invoked for model layer in reversed order, so I guess we should deal with real float values here.

This comment has been minimized.

Copy link
@yceruto

yceruto Feb 21, 2019

Contributor

Basically, this is what I suggest:

if (false !== strpos((string) $value, $decimalSeparator)) {

This comment has been minimized.

Copy link
@yceruto

yceruto Feb 21, 2019

Contributor

Although, technically that should never happen because DateIntervalToArrayTransformer, so ignore my suggestion.

@xabbuh xabbuh force-pushed the xabbuh:issue-10240 branch from ce14463 to a93df81 Feb 22, 2019

@xabbuh xabbuh force-pushed the xabbuh:issue-10240 branch from a93df81 to 6a43e74 Feb 22, 2019

@nicolas-grekas

This comment has been minimized.

Copy link
Member

nicolas-grekas commented Feb 23, 2019

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit 6a43e74 into symfony:3.4 Feb 23, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

nicolas-grekas added a commit that referenced this pull request Feb 23, 2019

bug #30329 [Form] IntegerType: reject submitted non-integer numbers (…
…xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] IntegerType: reject submitted non-integer numbers

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10240
| License       | MIT
| Doc PR        |

Commits
-------

6a43e74 IntegerType: reject submitted non-integer numbers

@xabbuh xabbuh deleted the xabbuh:issue-10240 branch Feb 23, 2019

This was referenced Mar 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.