Open PVince81 opened 1 year ago
So actually the problem is that it's a string and then should not use the "matches" but the "is" equation?
yes, likely same issue
and just now I noticed that we actually officially allow non-regexp input, at least the placeholder says so:
So actually the problem is that it's a string and then should not use the "matches" but the "is" equation?
ouch, I didn't notice that.
so it's more of a UX issue, we shouldn't allow selecting those presets when using "matches" and always having an input field
still, it looks like some people managed to pass validation despite using the presets and using "matches", it only did not work for me.
it might be best to fix the UI and leave the engine as is and think about what to do with setups where validation passed where it shouldn't
⚠️ This issue respects the following points: ⚠️
Bug description
When selecting "Folder" in it says "The given regular expression is invalid". I've expanded the error message and saw that the string is "httpd/unix-directory" which is technically not a regexp.
In the code, I see that it calls
preg_match()
to validate it: https://github.com/nextcloud/server/blob/v24.0.8/apps/workflowengine/lib/Check/AbstractStringCheck.php#L93According to @mahibi the validation accepted that string on PHP 8.0.26. However for me on PHP 8.1.13 the validation failed.
I suspect that perhaps PHP 8.1 got more strict with regular expressions.
Steps to reproduce
Expected behavior
Folder rule can be saved and works.
Installation method
Community Manual installation with Archive
Operating system
Other
PHP engine version
PHP 8.1
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
No response
Nextcloud Logs
Additional info
The presets for the dropdown are here: https://github.com/nextcloud/server/blob/v24.0.8/apps/workflowengine/src/components/Checks/FileMimeType.vue#L71
Should we convert these all to regular expressions, even for strict matching or should we loosen the validation code ? For folders specifically, I saw code in the workflow engine where it checked if the string is strictly "httpd/unix-directory" so adjusting the presets for regexp might need a more expanded fix.
@nickvergessen @juliushaertl @come-nc thoughts ?
I suspect that this fell under the radar when we added PHP 8.1 support