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

[Validator] drop grapheme_strlen in LengthValidator #13527

Merged
merged 1 commit into from Jan 26, 2015

Conversation

nicolas-grekas
Copy link
Member

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

As stated in #13491, validating the length of a string with grapheme_strlen is not suited to validating input because a very long string can in fact have a length of 1 when counted with grapheme_strlen.
Counting UTF-8 characters (not clusters) is not subject to this problem.
The attached patch removes using grapheme_strlen but also adds more fallback when couting the length of strings, using iconv (which is more broadly avail. than mbstring) or PCRE for UTF-8 strings.

@stof
Copy link
Member

stof commented Jan 26, 2015

👍

@fabpot
Copy link
Member

fabpot commented Jan 26, 2015

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 915fcd8 into symfony:2.3 Jan 26, 2015
fabpot added a commit that referenced this pull request Jan 26, 2015
…as-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[Validator] drop grapheme_strlen in LengthValidator

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

As stated in #13491, validating the length of a string with grapheme_strlen is not suited to validating input because a very long string can in fact have a length of 1 when counted with grapheme_strlen.
Counting UTF-8 characters (not clusters) is not subject to this problem.
The attached patch removes using grapheme_strlen but also adds more fallback when couting the length of strings, using iconv (which is more broadly avail. than mbstring) or PCRE for UTF-8 strings.

Commits
-------

915fcd8 [Validator] drop grapheme_strlen in LengthValidator
@nicolas-grekas nicolas-grekas deleted the fix-length-validator branch January 26, 2015 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants