Do not use EqualFold when checking u.Host#4496
Open
nikola-jokic wants to merge 1 commit into
Open
Conversation
Contributor
|
Hello! Thank you for your contribution. Please review our contribution guidelines to understand the project's testing and code conventions. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes hosted GitHub host detection and API host routing by replacing strings.EqualFold checks on url.URL.Host with case-sensitive equality comparisons.
Changes:
- Replaced
strings.EqualFold("www.github.com", c.ConfigURL.Host)withc.ConfigURL.Host == "www.github.com"inGitHubAPIURL. - Replaced
strings.EqualFoldhost matching inisHostedGitHubURLwithu.Host == ...comparisons.
Comments suppressed due to low confidence (1)
github/actions/actions.go:108
- These hosted GitHub checks are now case-sensitive on u.Host; hostnames are case-insensitive and url.Parse does not guarantee lowercase. This can misclassify hosted URLs and change the API base path/host selection. Consider comparing against a normalized hostname (e.g., strings.ToLower(u.Hostname())) rather than raw u.Host.
return u.Host == "github.com" ||
u.Host == "www.github.com" ||
u.Host == "github.localhost" ||
strings.HasSuffix(u.Host, ".ghe.com")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
85
to
90
| result.Host = fmt.Sprintf("api.%s", c.ConfigURL.Host) | ||
| result.Path = "" | ||
|
|
||
| if strings.EqualFold("www.github.com", c.ConfigURL.Host) { | ||
| if c.ConfigURL.Host == "www.github.com" { | ||
| // re-routing www.github.com to api.github.com | ||
| result.Host = "api.github.com" |
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.
No description provided.