powermail icon indicating copy to clipboard operation
powermail copied to clipboard

validation by regex works client side (JS), but not server side

Open derBoogie opened this issue 5 years ago • 2 comments

Hi, I have an problem with the validation of a password field with the following regex: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W])[a-zA-Z0-9\S]{8,}$/ -> rule: min. 8 characters, a small and a capital character, a number, a special character It works client side (JS) but not serverside. (TYPO3 9.5, Powermail 7.4.0)

Can someone test and confirm that?

Thanks!

derBoogie avatar May 07 '20 10:05 derBoogie

Yes, I can confirm that regex pattern validation does not seem to work, when ther is a unicode range included, like: ^[A-Za-z\-\_\,\.\s\u00c0-\u1f0f]+$ without that, it seems to work^^

mtness avatar May 19 '20 15:05 mtness

I can confirm at least the problem with unicode ranges. The cause is that regular expressions for JavaScript and PHP/ PCRE are not completely compatible. So either a converter (not sure if that's even possible for all cases but here's something I've found: https://github.com/TooTallNate/pcre-to-regexp) would be needed or the possibility to enter an optional server regex (which would be a lot easier to implement...).

Edit: I helped myself by not using the unicode positions but the characters themselves. So \u00C0-\u017F became À-ſ, which works for JavaScript and PCRE.

Hawkeye1909 avatar Aug 11 '21 08:08 Hawkeye1909