Skip to content

fix(text): preserve percent-encoding in DisplayURL - #13758

Open
salarkhannn wants to merge 1 commit into
cli:trunkfrom
salarkhannn:fix/display-url-percent-encoding
Open

fix(text): preserve percent-encoding in DisplayURL#13758
salarkhannn wants to merge 1 commit into
cli:trunkfrom
salarkhannn:fix/display-url-percent-encoding

Conversation

@salarkhannn

Copy link
Copy Markdown

DisplayURL was reconstructing the URL with u.Hostname() + u.Path, which decodes percent-encoded characters (e.g. %22") in the path and drops query strings entirely. Use url.URL{}.String() instead, which re-encodes the path via EscapedPath() and preserves the original encoding.

Fixes #13546

DisplayURL was reconstructing the URL with u.Hostname() + u.Path,
which decoded percent-encoded characters (e.g. %22 -> ") in the
path and lost query strings entirely. Use url.URL{}.String() instead,
which re-encodes the path via EscapedPath() and preserves the original
encoding.

Fixes cli#13546
@salarkhannn
salarkhannn requested a review from a team as a code owner June 30, 2026 12:00
@salarkhannn
salarkhannn requested a review from babakks June 30, 2026 12:00
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed ready-for-review and removed needs-triage needs to be reviewed labels Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your pull request! While it doesn't meet all of our standard requirements, it appears to be a small, focused contribution and has been routed to the team for review.

Note: We still encourage linking to an issue with the help wanted label when possible, as it helps us prioritize and track contributions.

Comment thread internal/text/text.go
scheme = "https"
}
return scheme + "://" + u.Hostname() + u.Path
return (&url.URL{Scheme: scheme, Host: u.Hostname(), Path: u.Path}).String()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

building a fresh url.URL from u.Path re-encodes the decoded path, so this still drops the encoding for anything that decodes to a reserved char — e.g. ...feat%2Ffoo has Path .../feat/foo, and String() gives back feat/foo, not feat%2F foo. same class of bug the PR is fixing, just for %2F instead of %22. u.EscapedPath() preserves RawPath and covers both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve percent-encoded branch names in gh pr create display URLs

2 participants