Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
acc27dc6
Commit
acc27dc6
authored
Apr 15, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
5db22fa9
b40ea0f1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
0 deletions
+58
-0
changelogs/unreleased/sh-validate-ref-name-in-commit.yml
changelogs/unreleased/sh-validate-ref-name-in-commit.yml
+5
-0
lib/extracts_path.rb
lib/extracts_path.rb
+3
-0
spec/controllers/projects/tree_controller_spec.rb
spec/controllers/projects/tree_controller_spec.rb
+20
-0
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+30
-0
No files found.
changelogs/unreleased/sh-validate-ref-name-in-commit.yml
0 → 100644
View file @
acc27dc6
---
title
:
Validate refs used in controllers don't have spaces
merge_request
:
24037
author
:
type
:
other
lib/extracts_path.rb
View file @
acc27dc6
...
...
@@ -113,6 +113,9 @@ module ExtractsPath
@id
=
get_id
@ref
,
@path
=
extract_ref
(
@id
)
@repo
=
@project
.
repository
@ref
.
strip!
raise
InvalidPathError
if
@ref
.
match?
(
/\s/
)
@commit
=
@repo
.
commit
(
@ref
)
...
...
spec/controllers/projects/tree_controller_spec.rb
View file @
acc27dc6
...
...
@@ -74,6 +74,26 @@ describe Projects::TreeController do
end
end
describe
'GET show with whitespace in ref'
do
render_views
let
(
:id
)
{
"this ref/api/responses"
}
it
'does not call make a Gitaly request'
do
allow
(
::
Gitlab
::
GitalyClient
).
to
receive
(
:call
).
and_call_original
expect
(
::
Gitlab
::
GitalyClient
).
not_to
receive
(
:call
).
with
(
anything
,
:commit_service
,
:find_commit
,
anything
,
anything
)
get
(
:show
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
id
})
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
describe
'GET show with blob path'
do
render_views
...
...
spec/lib/extracts_path_spec.rb
View file @
acc27dc6
...
...
@@ -44,6 +44,36 @@ describe ExtractsPath do
end
end
context
'ref contains trailing space'
do
let
(
:ref
)
{
'master '
}
it
'strips surrounding space'
do
assign_ref_vars
expect
(
@ref
).
to
eq
(
'master'
)
end
end
context
'ref contains leading space'
do
let
(
:ref
)
{
' master '
}
it
'strips surrounding space'
do
assign_ref_vars
expect
(
@ref
).
to
eq
(
'master'
)
end
end
context
'ref contains space in the middle'
do
let
(
:ref
)
{
'master plan '
}
it
'returns 404'
do
expect
(
self
).
to
receive
(
:render_404
)
assign_ref_vars
end
end
context
'path contains space'
do
let
(
:params
)
{
{
path:
'with space'
,
ref:
'38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e'
}
}
...
...
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