Skip to content
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

404 On Pull Request when branch has plus character #6333

Closed
2 of 7 tasks
fubarwrangler opened this issue Mar 14, 2019 · 4 comments · Fixed by #6334
Closed
2 of 7 tasks

404 On Pull Request when branch has plus character #6333

fubarwrangler opened this issue Mar 14, 2019 · 4 comments · Fixed by #6334
Labels
Milestone

Comments

@fubarwrangler
Copy link

Description

If you have a branch with a plus sign in it (haven't tried other characters) which is legal in git (my client in Fedora didn't complain -- a colleague had a branch with 'c++' in the name), you can't make a pull request: as soon as you select the branch with the + in the name you get a 404.
...

Screenshots

Screenshot_20190314_153617
--> (click on test++)
Screenshot_20190314_153809

@zeripath
Copy link
Contributor

zeripath commented Mar 14, 2019

See #6302 - I've listed a number of ways that the compare url is broken.

That being said rather than mark this issue as a duplicate - We could use this issue as the sub issue for dealing with url decomposition and creation affecting compare.

(There's several subissues to #6302 - including the actual issue that causes it which as yet is unidentified.)

@mrsdizzie
Copy link
Member

It looks like this problem comes from:

infoPath, err = url.QueryUnescape(ctx.Params("*"))

QueryUnescape will turn a literal + into a blank space. Heres a test:
https://play.golang.org/p/i19lnB9Q7-M

I think we might want PathUnescape here:
https://golang.org/src/net/url/url.go?s=5107:5151#L173
Based on

// PathUnescape is identical to QueryUnescape except that it does not
// unescape '+' to ' ' (space).

mrsdizzie added a commit to mrsdizzie/gitea that referenced this issue Mar 14, 2019
Currently branch names with a '+' fail in certain situations because
QueryUnescape replaces the + character with a blank space.

Using PathUnescape should be better since it is defined as:

// PathUnescape is identical to QueryUnescape except that it does not
// unescape '+' to ' ' (space).

Fixes go-gitea#6333
@lunny
Copy link
Member

lunny commented Mar 16, 2019

If this is duplicated with #6302 , I think we can close this one.

@mrsdizzie
Copy link
Member

This issue is separate and has a specific known cause (which will be fixed with PR #6334)

@lunny lunny added this to the 1.8.0 milestone Mar 18, 2019
@lunny lunny added the type/bug label Mar 18, 2019
techknowlogick pushed a commit that referenced this issue Mar 18, 2019
…6334)

* Use PathUnescape instead of QueryUnescape when working with branch names

Currently branch names with a '+' fail in certain situations because
QueryUnescape replaces the + character with a blank space.

Using PathUnescape should be better since it is defined as:

// PathUnescape is identical to QueryUnescape except that it does not
// unescape '+' to ' ' (space).

Fixes #6333

* Change error to match new function name

* Add new util function PathEscapeSegments

This function simply runs PathEscape on each segment of a path without
touching the forward slash itself. We want to use this instead of
PathEscape/QueryEscape in most cases because a forward slash is a valid name for a
branch etc... and we don't want that escaped in a URL.

Putting this in new file url.go and also moving a couple similar
functions into that file as well.

* Use EscapePathSegments where appropriate

Replace various uses of EscapePath/EscapeQuery with new
EscapePathSegments. Also remove uncessary uses of various
escape/unescape functions when the text had already been escaped or was
not escaped.

* Reformat comment to make drone build happy

* Remove no longer used url library

* Requested code changes
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants