Skip to content

[Validator] fix IBAN validator fails if IBAN contains non-breaking space #57380

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

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

antten
Copy link
Contributor

@antten antten commented Jun 12, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #57364
License MIT

Hello,
It's my first contribution to Symfony and I am really happy to be able to participate in the project.

After analyzing the class \Symfony\Component\Validator\Constraints\IbanValidator, I think the solution proposed in the issue is the right one.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@antten antten force-pushed the fix/validator-issue-57364 branch from 4497742 to 8a6ec10 Compare June 12, 2024 14:09
@@ -163,9 +163,6 @@ class IbanValidator extends ConstraintValidator
'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France
];

/**
* {@inheritdoc}
*/
Copy link
Member

Choose a reason for hiding this comment

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

I suppose that this comes from fabbot. This should be reverted as not related to this PR.

Comment on lines 182 to 183
// Remove spaces and non-breaking spaces and convert to uppercase
$canonicalized = str_replace([' ', '\XC2\XA0'], '', strtoupper($value));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Remove spaces and non-breaking spaces and convert to uppercase
$canonicalized = str_replace([' ', '\XC2\XA0'], '', strtoupper($value));
// Remove spaces (regular, non-breaking, and narrow non-breaking) and convert to uppercase
$canonicalized = str_replace([' ', "\xc2\xa0", "\xe2\x80\xaf"], '', strtoupper($value));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion.

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

LGTM, I am just not sure if this qualifies as a bugfix after all

@fabpot fabpot modified the milestones: 5.4, 7.2 Jun 17, 2024
@fabpot fabpot changed the base branch from 5.4 to 7.2 June 17, 2024 05:51
@fabpot fabpot force-pushed the fix/validator-issue-57364 branch from bf70d77 to 6f6c4b7 Compare June 17, 2024 05:51
@fabpot
Copy link
Member

fabpot commented Jun 17, 2024

Thank you @antten.

@fabpot fabpot merged commit 9ed27d0 into symfony:7.2 Jun 17, 2024
8 of 10 checks passed
@xabbuh
Copy link
Member

xabbuh commented Jun 17, 2024

changelog entry added in 62fcf93

@fabpot fabpot mentioned this pull request Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Validator] IBAN validator fails if IBAN contains non-breaking space
4 participants