BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1207d451
Commit
1207d451
authored
Jul 05, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes file_name_regex from Gitlab::Regex
parent
d1e0b1b3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
6 additions
and
63 deletions
+6
-63
snippet.rb
app/models/snippet.rb
+1
-3
browse_files.feature
features/project/source/browse_files.feature
+0
-10
browse_files.rb
features/steps/project/source/browse_files.rb
+0
-4
index.rb
lib/gitlab/git/index.rb
+0
-4
regex.rb
lib/gitlab/regex.rb
+0
-8
creating_a_file_spec.rb
spec/features/projects/files/creating_a_file_spec.rb
+0
-5
index_spec.rb
spec/lib/gitlab/git/index_spec.rb
+0
-19
regex_spec.rb
spec/lib/gitlab/regex_spec.rb
+0
-6
repository_spec.rb
spec/models/repository_spec.rb
+5
-4
No files found.
app/models/snippet.rb
View file @
1207d451
...
...
@@ -37,9 +37,7 @@ class Snippet < ActiveRecord::Base
validates
:author
,
presence:
true
validates
:title
,
presence:
true
,
length:
{
maximum:
255
}
validates
:file_name
,
length:
{
maximum:
255
},
format:
{
with:
Gitlab
::
Regex
.
file_name_regex
,
message:
Gitlab
::
Regex
.
file_name_regex_message
}
length:
{
maximum:
255
}
validates
:content
,
presence:
true
validates
:visibility_level
,
inclusion:
{
in:
Gitlab
::
VisibilityLevel
.
values
}
...
...
features/project/source/browse_files.feature
View file @
1207d451
...
...
@@ -131,16 +131,6 @@ Feature: Project Source Browse Files
Then
I can see the new text file
@javascript
Scenario
:
If I enter an illegal file name I see an error message
Given
I click on
"New file"
link in repo
And
I fill the new file name with an illegal name
And
I edit code
And
I fill the commit message
And
I click on
"Commit changes"
Then
I am on the new file page
And
I see
"Path can contain only..."
@javascript
Scenario
:
I
can create file with a directory name
Given
I click on
"New file"
link in repo
And
I fill the new file name with a new directory
...
...
features/steps/project/source/browse_files.rb
View file @
1207d451
...
...
@@ -92,10 +92,6 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
fill_in
:branch_name
,
with:
'new_branch_name'
,
visible:
true
end
step
'I fill the new file name with an illegal name'
do
fill_in
:file_name
,
with:
'Filename/Slash'
end
step
'I fill the new file name with a new directory'
do
fill_in
:file_name
,
with:
new_file_name_with_directory
end
...
...
lib/gitlab/git/index.rb
View file @
1207d451
...
...
@@ -110,10 +110,6 @@ module Gitlab
if
segment
==
'..'
raise
IndexError
,
'Path cannot include directory traversal'
end
unless
segment
=~
Gitlab
::
Regex
.
file_name_regex
raise
IndexError
,
"Path
#{
Gitlab
::
Regex
.
file_name_regex_message
}
"
end
end
pathname
.
to_s
...
...
lib/gitlab/regex.rb
View file @
1207d451
...
...
@@ -19,14 +19,6 @@ module Gitlab
"It must start with letter, digit, emoji or '_'."
end
def
file_name_regex
@file_name_regex
||=
/\A[^\/\0]*\z/
.
freeze
end
def
file_name_regex_message
"can contain only letters, digits, '_', '-', '@', '+' and '.'."
end
def
container_registry_reference_regex
Gitlab
::
PathRegex
.
git_reference_regex
end
...
...
spec/features/projects/files/creating_a_file_spec.rb
View file @
1207d451
...
...
@@ -30,11 +30,6 @@ feature 'User wants to create a file', feature: true do
expect
(
page
).
to
have_content
'The file has been successfully created'
end
scenario
'file name contains invalid characters'
do
submit_new_file
(
file_name:
'\\'
)
expect
(
page
).
to
have_content
'Path can contain only'
end
scenario
'file name contains directory traversal'
do
submit_new_file
(
file_name:
'../README.md'
)
expect
(
page
).
to
have_content
'Path cannot include directory traversal'
...
...
spec/lib/gitlab/git/index_spec.rb
View file @
1207d451
...
...
@@ -25,16 +25,6 @@ describe Gitlab::Git::Index, seed_helper: true do
expect
(
entry
).
not_to
be_nil
expect
(
repository
.
lookup
(
entry
[
:oid
]).
content
).
to
eq
(
options
[
:content
])
end
it
'creates the file if file_path has spaces in between words'
do
options
[
:file_path
]
=
'new file.txt'
index
.
create
(
options
)
entry
=
index
.
get
(
options
[
:file_path
])
expect
(
entry
).
not_to
be_nil
expect
(
repository
.
lookup
(
entry
[
:oid
]).
content
).
to
eq
(
options
[
:content
])
end
end
context
'when a file at that path exists'
do
...
...
@@ -91,15 +81,6 @@ describe Gitlab::Git::Index, seed_helper: true do
expect
(
entry
).
not_to
be_nil
end
it
'creates the dir if it has spaces in between words'
do
options
[
:file_path
]
=
'new dir'
index
.
create_dir
(
options
)
entry
=
index
.
get
(
options
[
:file_path
]
+
'/.gitkeep'
)
expect
(
entry
).
not_to
be_nil
end
end
context
'when a file at that path exists'
do
...
...
spec/lib/gitlab/regex_spec.rb
View file @
1207d451
...
...
@@ -14,12 +14,6 @@ describe Gitlab::Regex, lib: true do
it
{
is_expected
.
not_to
match
(
'?gitlab'
)
}
end
describe
'.file_name_regex'
do
subject
{
described_class
.
file_name_regex
}
it
{
is_expected
.
to
match
(
'foo@bar'
)
}
end
describe
'.environment_slug_regex'
do
subject
{
described_class
.
environment_name_regex
}
...
...
spec/models/repository_spec.rb
View file @
1207d451
...
...
@@ -347,14 +347,15 @@ describe Repository, models: true do
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
end
it
'creates new file
with spaces in between successfully
'
do
it
'creates new file
and dir when file_path has a forward slash
'
do
expect
do
repository
.
create_file
(
user
,
'
NEW FILE
'
,
'File!'
,
message:
'Create
NEW FILE
'
,
repository
.
create_file
(
user
,
'
new_dir/new_file.txt
'
,
'File!'
,
message:
'Create
new_file with new_dir
'
,
branch_name:
'master'
)
end
.
to
change
{
repository
.
commits
(
'master'
).
count
}.
by
(
1
)
expect
(
repository
.
blob_at
(
'master'
,
'NEW FILE'
).
data
).
to
eq
(
'File!'
)
expect
(
repository
.
tree
(
'master'
,
'new_dir'
).
path
).
to
eq
(
'new_dir'
)
expect
(
repository
.
blob_at
(
'master'
,
'new_dir/new_file.txt'
).
data
).
to
eq
(
'File!'
)
end
it
'respects the autocrlf setting'
do
...
...
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