[Security] Fix login url matching when app is not run with url rewriting or from a sub folder #47317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses the fix suggested by @weaverryan in #44893 (comment). I also added three tests for scenarios which I could replicate from running a simple app on a real webserver (Apache and Nginx). This, however, might not be sufficient because there could be other combinations of server variables like
DOCUMENT_ROOT,PHP_SELF,SCRIPT_FILENAME,SCRIPT_NAMEand possibly others depending on the server configuration and setup. As long as\Symfony\Component\HttpFoundation\Request::getBaseUrl()and\Symfony\Component\HttpFoundation\Request::getPathInfo()work correctly, I assume that the fix will also be correct in all those constellations.The fix is based on the assumptions that:
\Symfony\Component\HttpFoundation\Request::getBaseUrl()always returns an empty string when the application is run from root without the front controller script in the URL (using URL rewriting for example)\Symfony\Component\HttpFoundation\Request::getBaseUrl()always returns the path from the server root to the application base path (possibly including the front controller script)\Symfony\Component\HttpFoundation\Request::getPathInfo()always returns just the routed part of the requestPlease advise if you'd need some more tests.