68762[FEATURE] Introduce regular expression validation in FormEngine
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 3
Review log 1832
Show 37 earlier messages
-
Johannes Schlier uploaded patch set 1 04/12/21, 11:11
-
TYPO3com voted on patch set 1 V +1 04/12/21, 11:19 Completed build in 07m 22s on Mon, 12 Apr, 11:19 AM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10615
-
core-ci voted on patch set 1 V +1 04/12/21, 11:22 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2191
-
Andreas Kienast commented on patch set 1 CR -1 04/12/21, 12:29
Thank you for your contribution. I've downvoted this patch as-is for two reasons: 1.) a ReST file describing the feature and its impact is missing (https://forger.typo3.com/utilities/rst) 2.) Features must not get backported to non-master versions (in this case 10.4), unless there is a ultra important reasoning -
Johannes Schlier uploaded patch set 2 04/12/21, 13:41
-
TYPO3com voted on patch set 2 V +1 04/12/21, 13:50 Completed build in 08m 17s on Mon, 12 Apr, 01:50 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10616
-
core-ci voted on patch set 2 V +1 04/12/21, 13:52 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2193
-
Johannes Schlier commented on patch set 2 04/13/21, 14:23
Reply
Thanks for the review. I added a ReST file. I could not build the documentation locally, but hope that it's fine as it is. The backport has no real important reason. I simply thought it's not a complicated patch and could therefore easily be backported. Would be nice for some projects of ours with TYPO3 10 - but I can simply include a local patch until those are updated to TYPO3 11. Feel free to suggest more changes. -
Oli Bartsch uploaded patch set 3 04/13/21, 15:23
-
Oli Bartsch uploaded patch set 4 04/13/21, 15:26
-
TYPO3com voted on patch set 3 V +1 04/13/21, 15:30 Completed build in 07m 41s on Tue, 13 Apr, 03:30 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10649
-
TYPO3com voted on patch set 4 V +1 04/13/21, 15:34 Completed build in 07m 31s on Tue, 13 Apr, 03:34 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10650
-
core-ci voted on patch set 3 V +1 04/13/21, 15:35 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2231
-
core-ci voted on patch set 4 V +1 04/13/21, 15:40 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2232
-
Oli Bartsch uploaded patch set 5 04/13/21, 16:15
-
Oli Bartsch uploaded patch set 6 04/13/21, 16:16
-
Oli Bartsch voted on patch set 6 V +1 CR +1 04/13/21, 16:17
-
TYPO3com voted on patch set 5 V +1 04/13/21, 16:23 Completed build in 07m 53s on Tue, 13 Apr, 04:23 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10651
-
TYPO3com voted on patch set 6 V +1 04/13/21, 16:24 Completed build in 07m 35s on Tue, 13 Apr, 04:24 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10652
-
core-ci voted on patch set 5 V +1 04/13/21, 16:27 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2233
-
core-ci voted on patch set 6 V +1 04/13/21, 16:31 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2234
-
Oliver Hader commented on patch set 6 CR -1 04/19/21, 09:35
It looks like this is client-side validation only - are there plans to extend that to server-side validation in DataHandler as well. I'm giving a -1 since I fear that validation introduced with this change is used with the expectation it also concerns persistence. The missing server-side part might lead to new security-related aspects... -
Oliver Hader commented on patch set 6 04/19/21, 09:45
Feature-23633-RegularExpressionValidationInFormEngine.rst:33UnresolvedIn the long run, I could imagine something like ``` latitute type: input validation: regularExpression: pattern: ^\d+$ modifier: null preset: int transformation: search: , replace: . ``` Let's skip the `transformation` part for the time being (→ later™). The `preset` part in `validation` might later be used like the current presets we have with `eval` - thus, having a way to combine and normalize `eval` with new `regularExpression`. -
Johannes Schlier commented on patch set 6 05/04/21, 14:15
Reply
True, this is client-side validation only. Since the backend heavily relies on JavaScript anyways I figured this would be enough for all cases, but I can see that some might expect it to do something server-side. I don't quite know where to add this, besides in the DataHandler method "checkValueForInput". Everything is given there, but all I can manage is to change or remove the value passed to the database: ``` if (isset($tcaFieldConf['regularExpression']) && isset($tcaFieldConf['regularExpression']['expression'])) { $matches = []; $expression = '/' . $tcaFieldConf['regularExpression']['expression'] . '/' . $tcaFieldConf['regularExpression']['modifier'] ?? ''; try { $result = preg_match( $expression, $value, $matches ); if ($result === 0 || $result === false) { $res['value'] = ''; } } catch(Exception $e) { $res['value'] = ''; } } ``` I would prefer to actually send the user back with a FlashMessage. Otherwise the editor simply returns to the edit form with an empty field, probably without noticing that change. It seems the DataHandler is not built for this type of validation. If the given "$value" variable is overriden or set to an empty string instead of the "$res['value']" a database error is produced in the backend. This way at least the user is pointed to the correct field. Maybe within the EditDocumentController? It does not contain any similar cases yet. If anyone has any ideas or pointers where to add this, I'd glady add server side validation. It seems that to properly and cleanly add real validation (and not simply manipulation into certain ranges or something similar) some pretty big structural changes would have to be introduced. -
Oli Bartsch voted on patch set 6 V 0 CR 0 05/04/21, 14:24
-
Benni Mack wrote 11/29/21, 10:06
Change destination moved from master to main -
Benni Mack updated the commit message in patch set 7 11/29/21, 13:21
-
core-ci voted on patch set 7 V +1 11/29/21, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20006
-
Simon Schaufelberger uploaded patch set 8 04/26/22, 19:57
-
core-ci voted on patch set 8 V -1 04/26/22, 20:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26475
-
Andreas Kienast wrote 09/22/22, 11:08
Removed reviewer Andreas Kienast. -
Benni Mack abandoned the change 07/04/23, 13:12
I will abandon this change now, as we need to rework this completely anyways. Can be restored later-on