fix(SetupChecks): Validate URL before parsing#49379
Open
joshtrichards wants to merge 1 commit intomasterfrom
Open
fix(SetupChecks): Validate URL before parsing#49379joshtrichards wants to merge 1 commit intomasterfrom
joshtrichards wants to merge 1 commit intomasterfrom
Conversation
4 tasks
come-nc
requested changes
Nov 19, 2024
Contributor
come-nc
left a comment
There was a problem hiding this comment.
I like this less, because it does not explicitely check the return of parse_url. It’s bad for static analysis also.
And $url in the single quoted string will not be interpolated.
Member
Author
Restructured the logic. Now we do it all. Plus we also check things even when not removing the web-root unlike master.
🤦♂️ Fixed. |
Signed-off-by: Josh <josh.t.richards@gmail.com>
b84b787 to
d8cd202
Compare
Member
Author
|
Also expanded the unit tests. |
come-nc
requested changes
Nov 21, 2024
Comment on lines
+96
to
+168
| // web-root left alone | ||
| // hostname without web-root | ||
| 'nothing to change' => ['http://example.com', false, 'http://example.com'], | ||
| 'with trailing slash' => ['http://example.com/', false, 'http://example.com'], | ||
| 'with port and nothing to change' => ['http://example.com:8081', false, 'http://example.com:8081'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/', false, 'http://example.com:8081'], | ||
| // hostname with web-root | ||
| 'nothing to change' => ['http://example.com/root', false, 'http://example.com/root'], | ||
| 'with trailing slash' => ['http://example.com/root/', false, 'http://example.com/root'], | ||
| 'with port and nothing to change' => ['http://example.com:8081/root', false, 'http://example.com:8081/root'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/root/', false, 'http://example.com:8081/root'], | ||
| // hostname with deep web-root | ||
| 'nothing to change' => ['http://example.com/deep/webroot', false, 'http://example.com/deep/webroot'], | ||
| 'with trailing slash' => ['http://example.com/deep/webroot/', false, 'http://example.com/deep/webroot'], | ||
| 'with port and nothing to change' => ['http://example.com:8081/deep/webroot', false, 'http://example.com/deep/webroot'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/deep/webroot/', false, 'http://example.com/deep/webroot'], | ||
| // IPv4 instead of hostname without web-root | ||
| 'nothing to change' => ['https://127.0.0.1', false, 'https://127.0.0.1'], | ||
| 'with trailing slash' => ['https://127.0.0.1/', false, 'https://127.0.0.1'], | ||
| 'with port and nothing to change' => ['https://127.0.0.1:8080', false, 'https://127.0.0.1:8080'], | ||
| 'with port and trailing slash' => ['https://127.0.0.1:8080/', false, 'https://127.0.0.1:8080'], | ||
| // IPv4 instead of hostname with web-root | ||
| 'nothing to change' => ['https://127.0.0.1/root', false, 'https://127.0.0.1/root'], | ||
| 'with trailing slash' => ['https://127.0.0.1/root/', false, 'https://127.0.0.1/root'], | ||
| 'with port and nothing to change' => ['https://127.0.0.1:8080/root', false, 'https://127.0.0.1:8080/root'], | ||
| 'with port and trailing slash' => ['https://127.0.0.1:8080/root/', false, 'https://127.0.0.1:8080/root'], | ||
| // IPv6 instead of hostname without web-root | ||
| 'nothing to change' => ['https://[ff02::1]', false, 'https://[ff02::1]'], | ||
| 'with trailing slash' => ['https://[ff02::1]/', false, 'https://[ff02::1]'], | ||
| 'with port and nothing to change' => ['https://[ff02::1]:8080', false, 'https://[ff02::1]:8080'], | ||
| 'with port and trailing slash' => ['https://[ff02::1]:8080/', false, 'https://[ff02::1]:8080'], | ||
| // IPv6 instead of hostname with web-root | ||
| 'nothing to change' => ['https://[ff02::1]/root', false, 'https://[ff02::1]/root'], | ||
| 'with trailing slash' => ['https://[ff02::1]/root/', false, 'https://[ff02::1]/root'], | ||
| 'with port and nothing to change' => ['https://[ff02::1]:8080/root', false, 'https://[ff02::1]:8080/root'], | ||
| 'with port and trailing slash' => ['https://[ff02::1]:8080/root/', false, 'https://[ff02::1]:8080/root'], | ||
|
|
||
| // web-root specified for removal | ||
| // hostname without web-root | ||
| 'nothing to change' => ['http://example.com', true, 'http://example.com'], | ||
| 'with trailing slash' => ['http://example.com/', true, 'http://example.com'], | ||
| 'with port and nothing to change' => ['http://example.com:8081', true, 'http://example.com:8081'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/', true, 'http://example.com:8081'], | ||
| // hostname with web-root | ||
| 'without trailing slash' => ['http://example.com/root', true, 'http://example.com'], | ||
| 'with trailing slash' => ['http://example.com/root/', true, 'http://example.com'], | ||
| 'with port without trailing slash' => ['http://example.com:8081/root', true, 'http://example.com:8081'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/root/', true, 'http://example.com:8081'], | ||
| // hostname with deep web-root | ||
| 'without trailing slash' => ['http://example.com/deep/webroot', true, 'http://example.com'], | ||
| 'with trailing slash' => ['http://example.com/deep/webroot/', true, 'http://example.com'], | ||
| 'with port without trailing slash' => ['http://example.com:8081/deep/webroot', true, 'http://example.com:8081'], | ||
| 'with port and trailing slash' => ['http://example.com:8081/deep/webroot/', true, 'http://example.com:8081'], | ||
| // IPv4 instead of hostname without web-root | ||
| 'nothing to change' => ['https://127.0.0.1', true, 'https://127.0.0.1'], | ||
| 'with trailing slash' => ['https://127.0.0.1/', true, 'https://127.0.0.1'], | ||
| 'with port and nothing to change' => ['https://127.0.0.1:8080', true, 'https://127.0.0.1:8080'], | ||
| 'with port and trailing slash' => ['https://127.0.0.1:8080/', true, 'https://127.0.0.1:8080'], | ||
| // IPv4 instead of hostname with web-root | ||
| 'without trailing slash' => ['https://127.0.0.1/root', true, 'https://127.0.0.1'], | ||
| 'with trailing slash' => ['https://127.0.0.1/root/', true, 'https://127.0.0.1'], | ||
| 'with port' => ['https://127.0.0.1:8080/root', true, 'https://127.0.0.1:8080/root'], | ||
| 'with port and trailing slash' => ['https://127.0.0.1:8080/root/', true, 'https://127.0.0.1:8080/root'], | ||
| // IPv6 instead of hostname without web-root | ||
| 'nothing to change' => ['https://[ff02::1]', true, 'https://[ff02::1]'], | ||
| 'with trailing slash' => ['https://[ff02::1]/', true, 'https://[ff02::1]'], | ||
| 'with port and nothing to change' => ['https://[ff02::1]:8080', true, 'https://[ff02::1]:8080'], | ||
| 'with port and trailing slash' => ['https://[ff02::1]:8080/', true, 'https://[ff02::1]:8080'], | ||
| // IPv6 instead of hostname with web-root | ||
| 'without trailing slash' => ['https://[ff02::1]/root', true, 'https://[ff02::1]'], | ||
| 'with trailing slash' => ['https://[ff02::1]/root/', true, 'https://[ff02::1]'], | ||
| 'with port' => ['https://[ff02::1]:8080/root', true, 'https://[ff02::1]:8080'], | ||
| 'with port and trailing slash' => ['https://[ff02::1]:8080/root/', true, 'https://[ff02::1]:8080'], |
Contributor
There was a problem hiding this comment.
You cannot use the same key several time in an associative array, your are overwriting the previous value each time you use the same key.
Merged
This was referenced Aug 22, 2025
Merged
Merged
Merged
Merged
Merged
This was referenced Sep 25, 2025
Merged
Merged
Merged
This was referenced Jan 29, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Came up while looking at #49373 / #49370 in
stable30.Summary
Using
filter_var()should be safer / more likely to catch edge cases.Also adds the url in the error output to help the operator track down the culprit faster.
TODO
Checklist