New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HttpFoundation] Fix request uri when it starts with double slashes #29494
Conversation
bfe7d4c
to
c2b69ef
Compare
efe0e35
to
99151e4
Compare
95e9fe0
to
8a7707e
Compare
All code review notes answered by a code modification and the branch has been rebased and squashed. |
Maybe extract the if( empty $requestUri string ) to jump over the if/else, unless you actually want to send an empty string into parse_url()? Just micro optimizations. I tested it with our setup and it worked well. |
@danijelk Thank you for your feedback. On the majority of cases Your idea is good in order to skip null and empty strings. However, it is a bit overkill regarding the occurrence of this case while So to keep the code simple (as we cannot use here an early return) I think that this micro optimization adds useless complexity. @nicolas-grekas Do you think that we can turn this PR as |
Is there a way to keep existing tests the same? |
Yes for sure. I can revert them. @nicolas-grekas FYI: Tests has been refactored on this commit 95e9fe0 then squashed. Its tests has been added on #29256. |
ee1d77f
to
2b97683
Compare
2b97683
to
cf850c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this guy's solution where he is just using the parse_url function correctly, much more obvious and readable? a3cbb65
@Dylan-DutchAndBold it's not: see how many tests this "solution" breaks. |
You're right, missed that, didn't get what you meant by your original comment at first. |
Thank you @alquerci. |
…e slashes (alquerci) This PR was merged into the 3.4 branch. Discussion ---------- [HttpFoundation] Fix request uri when it starts with double slashes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29478 | License | MIT | Doc PR | ~ When the `REQUEST_URI` starts with a slash no need to `parse_url()`. However to keep the same behaviour regarding the fragment we need to add a logic to remove it. While `parse_url()` handle all cases itself. Commits ------- cf850c1 [HttpFoundation] Fix request uri when it starts with double slashes
When the
REQUEST_URI
starts with a slash no need toparse_url()
. However to keep the same behaviour regarding the fragment we need to add a logic to remove it. Whileparse_url()
handle all cases itself.