Bug #91340
closedRegEx validator in EXT:form does not support negative lookbehind
0%
Description
I tried to use this regular expression to allow all email addresses but not those ending with @qq.com:
/^.+@.+(?<!@qq.com)$/g
There are two problem with the regex validator of EXT:form when you want to use an expression with negative lookbehind:
1. The GUI of the TYPO3 backend cuts the regular expression when there is a < in the expression.
2. Even if you edit the yaml file in the file system and enter the expression manually, you end up with the following exception:
TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException: regularExpression \"/^.+@.+(?<!@qq.com)$/g\" in RegularExpressionValidator contained an error. in /var/www/html/public/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php:51
Updated by Björn Jacob over 3 years ago
Right now, we tend to not implement the first part. Since "<" is part of an HTML tag, allowing it could create security issues. The second part of the issue description seems valid :)
Updated by Björn Jacob over 2 years ago
- Related to Task #70889: In a ModuleController use iconFactory from moduleTemplate added
Updated by Björn Jacob over 2 years ago
- Related to deleted (Task #70889: In a ModuleController use iconFactory from moduleTemplate)
Updated by Björn Jacob over 2 years ago
- Related to Bug #90640: ext:form - RegularExpressionValidator with empty value will lead to exception added
Updated by Björn Jacob over 2 years ago
- Sprint Focus set to Remote Sprint
We can work on the second part. The GUI does not support the regex validator anymore (soon), see #90640.
Updated by Björn Jacob over 2 years ago
- TYPO3 Version changed from 10 to 12
The behaviour is still the same on current main.
Updated by Elias Häußler over 2 years ago
Hi Peter,
I just tested this on latest main with the following form definition:
renderingOptions:
submitButtonLabel: Submit
type: Form
identifier: test91340
label: 'test 91340'
prototypeName: standard
renderables:
-
renderingOptions:
previousButtonLabel: 'Previous step'
nextButtonLabel: 'Next step'
type: Page
identifier: page-1
label: Step
renderables:
-
defaultValue: ''
validators:
-
identifier: EmailAddress
-
identifier: RegularExpression
options:
regularExpression: '/^.+@.+(?<!@qq.com)$/g'
type: Email
identifier: email-1
label: 'Email address'
With this configuration, on form submit I get the following exception:
#1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: preg_match(): Unknown modifier 'g' in /var/www/html/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php line 42
This is correct, since the regex should be
-regularExpression: '/^.+@.+(?<!@qq.com)$/g'
+regularExpression: '/^.+@.+(?<!@qq\.com)$/'
When using the modified regex, I get
You must enter a valid value. Please refer to the description of this field.
when entering foo@qq.com
as e-mail address, which is expected behavior.
Additionally, I can successfully submit the form when using a different e-mail address, e.g. foo@bar.com
.
That's why I'd say this issue is already resolved. Can you confirm?
Updated by Björn Jacob over 2 years ago
- Status changed from New to Needs Feedback
Updated by Peter Kraume over 2 years ago
Hi guys,
thx a lot for taking care of my issue. I've tested the regular expression as suggested by Elias and that worked fine with TYPO3 11.5.12.
So I would say that this issue can be closed. Thx again!
Updated by Björn Jacob over 2 years ago
- Status changed from Needs Feedback to Closed
Thanks Peter for your feedback. Perfect.
Updated by Elias Häußler about 1 year ago
- Related to Bug #102143: Regular Expression is cut off added