fix(gitea): escape every value joined into an API path or query #614
No reviewers
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea!614
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-609-escape-path-values"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Most endpoint builders in
internal/giteajoined values into the path as raw strings. A?,#,%, or space in a value could change the endpoint or add a query. The builders now wrap each value in the existingescapePath, which escapes each/-separated part and keeps the/, so a branchfeat/xand a file path still work. The release asset upload escapes the file name withurl.QueryEscape.A
..segment could not take a repo-scoped client out of its repo:pathUnderScopealready percent-decodes the path and resolves dot-segments before its prefix check.TestNoUnescapedPathJoinsis a guard over the package source. It fails when a path builder joins a value withoutescapePath(orurl.PathEscape, or astrconvnumber), or joins a query value withouturl.QueryEscapeorurl.Values. A line that is plumbing, not a value join, carries apathjoin:okcomment with its reason (13 lines). WithMADTEA_FIX_PATHJOINS=1set, the same test wraps flagged path values in place; it made the 313 edits here.TestEscapedValuesReachTheServerchecks the result against a test server: a?and#in a tag name stay in its segment,feat/xkeeps its/, and the upload namea b&x=1.ziparrives as one value. Both tests fail when an escape is undone.Closes #609
Closes #609