Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
25e64b1a
Commit
25e64b1a
authored
Jan 04, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix routing for encoded slashes
parent
bd5ec001
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
main_test.go
main_test.go
+24
-0
upstream.go
upstream.go
+1
-1
No files found.
main_test.go
View file @
25e64b1a
...
...
@@ -12,6 +12,7 @@ import (
"os/exec"
"path"
"regexp"
"strings"
"testing"
"time"
)
...
...
@@ -196,6 +197,29 @@ func TestAllowedApiDownloadZip(t *testing.T) {
runOrFail
(
t
,
extractCmd
)
}
func
TestAllowedApiDownloadZipWithSlash
(
t
*
testing
.
T
)
{
prepareDownloadDir
(
t
)
// Prepare test server and backend
archiveName
:=
"foobar.zip"
ts
:=
testAuthServer
(
nil
,
200
,
archiveOkBody
(
t
,
archiveName
))
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
// Use foo%2Fbar instead of a numeric ID
downloadCmd
:=
exec
.
Command
(
"curl"
,
"-J"
,
"-O"
,
fmt
.
Sprintf
(
"%s/api/v3/projects/foo%%2Fbar/repository/archive.zip"
,
ws
.
URL
))
if
!
strings
.
Contains
(
downloadCmd
.
Args
[
3
],
`projects/foo%2Fbar/repository`
)
{
t
.
Fatalf
(
"Cannot find percent-2F: %v"
,
downloadCmd
.
Args
)
}
downloadCmd
.
Dir
=
scratchDir
runOrFail
(
t
,
downloadCmd
)
extractCmd
:=
exec
.
Command
(
"unzip"
,
archiveName
)
extractCmd
.
Dir
=
scratchDir
runOrFail
(
t
,
extractCmd
)
}
func
TestDownloadCacheHit
(
t
*
testing
.
T
)
{
prepareDownloadDir
(
t
)
...
...
upstream.go
View file @
25e64b1a
...
...
@@ -107,7 +107,7 @@ func (u *upstream) ServeHTTP(ow http.ResponseWriter, r *http.Request) {
}
// Check URL Root
URIPath
:=
cleanURIPath
(
r
.
URL
.
Path
)
URIPath
:=
cleanURIPath
(
r
.
URL
.
EscapedPath
()
)
if
!
strings
.
HasPrefix
(
URIPath
,
u
.
relativeURLRoot
)
&&
URIPath
+
"/"
!=
u
.
relativeURLRoot
{
httpError
(
&
w
,
r
,
fmt
.
Sprintf
(
"Not found %q"
,
URIPath
),
http
.
StatusNotFound
)
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment