Bug #53134

Regex Character class "alnum" not working correct in AlphanumericValidator

Added by Michael Gerdemann almost 2 years ago. Updated over 1 year ago.

Status:Closed Start date:2013-10-25
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

0%

Category:Validation
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:Flow 2.0.0

Description

The Regex Character class "alnum" not working correct in AlphanumericValidator.
A better regular expression would be:

/^[[:alnum:]\pL]*$/u

History

#1 Updated by Gerrit Code Review almost 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/25006

#2 Updated by Karsten Dambekalns over 1 year ago

  • Category set to Validation
  • Status changed from Under Review to Needs Feedback
  • Assigned To set to Karsten Dambekalns

I think this needs more background. Rasmus Lerdorf said this

I think the documentation is wrong on that. In Unicode mode :alnum: actually becomes \p{Xan} which should match Unicode chars as well, but only if PCRE was compiled with Unicode support. So I suspect you don't actually have a Unicode-capable PCRE build in some cases there.

about the PHP documentations saying

In UTF-8 mode, characters with values greater than 128 do not match any of the POSIX character classes.

(see http://grokbase.com/t/php/php-internals/12b5rfqxxc/incomprehension-with-preg-match-and-utf8#201211050tzcfjc0dmzpz0zj15z8w2j5mg)

So as long as PHP and the PCRE library support UTF-8, the use of the u flag in the validator should be enough. If UTF-8 support is missing or broken, the use of \p{L} probably doesn't help.

Could you provide a test case that shows the validator failing?

#3 Updated by Michael Gerdemann over 1 year ago

In the meantime, we have updated the PHP version and the PCRE version, so the validator don't fail anymore.
With the previous versions the test failed. But the UTF8 support should have been correct.
I can't reproduce it now, so it's okay if this issue is closed.

#4 Updated by Karsten Dambekalns over 1 year ago

  • Status changed from Needs Feedback to Closed

Ok, thanks for the quick feedback.

Also available in: Atom PDF