terminal42 / contao-url-rewrite

Provides a back end module in Contao that allows you to specify url rewrites that are added to the Symfony Route collection
MIT License
15 stars 4 forks source link

Validate regular expression in route requirements #32

Closed aschempp closed 2 years ago

aschempp commented 2 years ago

My client added a value of *.* as the extra argument, which resulted in the whole application being down (and the back end no longer being accessible). Apparently an invalid regex can still make it into the cached router:

[2022-01-26T21:30:27.550299+01:00] request.CRITICAL: Uncaught PHP Exception ErrorException: "preg_match(): Compilation failed: (*VERB) not recognized or malformed at offset 536" at vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php line 352 {"exception":"[object] (ErrorException(code: 0): preg_match(): Compilation failed: (*VERB) not recognized or malformed at offset 536 at vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php:352)"} []

@qzminski @Toflar any objections?

aschempp commented 2 years ago

Personally I would've added a public static validateRegex() method or similar and used it in both places

I just tried that but then the backend exception does not have a useful explanation anymore. Not worth it imho 😊