-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fixed 404 caused by unexpected question mark #17
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
Conversation
Please reopen against master. |
Could you provide a testcase for the issue, or at least instructions to reproduce ? |
@strk It's a simple case of creating a file with '?' in the filename. |
@@ -97,7 +97,7 @@ func NewFuncMap() []template.FuncMap { | |||
"MD5": base.EncodeMD5, | |||
"ActionContent2Commits": ActionContent2Commits, | |||
"EscapePound": func(str string) string { | |||
return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20").Replace(str) | |||
return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand here what the dark red color on percent sign means, do you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not important, it's just invalid highlighting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better method is to define as a static replacer
var replacerEscapePound = strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F")
And then replace the two palces of references.
Quick question, doesn't golang have a URL_escape? :) |
Yet you can't use QueryEscape for filenames though. |
Could the code duplication be avoided by putting the replace code in a common function ? |
Besides, I just tested reproducing and I go the 404 before and after applying your patch |
@strk can you tell me what you did to get the 404? |
I reloaded the URL I got the 404 from before the patch (url containing the |
Meanwhile please consider removing the code duplication, and maybe put the shared function under automatic testing |
Ok, reloading the previous page gives the correct link. So LGTM (but code duplication would really be better to avoid) |
LGTM |
This fixes 404 caused when creating new files or wiki pages with question marks. Amended to force CI rebuild
Current coverage is 3.14% (diff: 100%)@@ master #17 diff @@
========================================
Files 33 33
Lines 7823 7823
Methods 0 0
Messages 0 0
Branches 0 0
========================================
Hits 246 246
Misses 7557 7557
Partials 20 20
|
LGTM |
* Avoid creating an array for the sole purpose of counting elements Probably speeds up counting commits for git versions < 1.8.0, although I dubt it would make a visible difference * Fix commit count with git version < 1.8.0 With format='' the output does not end with a newline (checked)
Added real name of Bwko to maintainers file
Very simply, this pull request modifies certain files to escape symbols in filenames that may cause 404s unescaped.