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
33aed43e
Commit
33aed43e
authored
May 30, 2017
by
Bob Van Landuyt
Committed by
Douwe Maan
May 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid crash when trying to parse string with invalid UTF-8 sequence
parent
374486fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
app/validators/dynamic_path_validator.rb
app/validators/dynamic_path_validator.rb
+5
-0
spec/lib/gitlab/git/encoding_helper_spec.rb
spec/lib/gitlab/git/encoding_helper_spec.rb
+1
-1
spec/validators/dynamic_path_validator_spec.rb
spec/validators/dynamic_path_validator_spec.rb
+22
-0
No files found.
app/validators/dynamic_path_validator.rb
View file @
33aed43e
...
@@ -6,16 +6,21 @@
...
@@ -6,16 +6,21 @@
# Values are checked for formatting and exclusion from a list of illegal path
# Values are checked for formatting and exclusion from a list of illegal path
# names.
# names.
class
DynamicPathValidator
<
ActiveModel
::
EachValidator
class
DynamicPathValidator
<
ActiveModel
::
EachValidator
extend
Gitlab
::
Git
::
EncodingHelper
class
<<
self
class
<<
self
def
valid_user_path?
(
path
)
def
valid_user_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
root_namespace_path_regex
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
root_namespace_path_regex
end
end
def
valid_group_path?
(
path
)
def
valid_group_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_namespace_path_regex
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_namespace_path_regex
end
end
def
valid_project_path?
(
path
)
def
valid_project_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_project_path_regex
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_project_path_regex
end
end
end
end
...
...
spec/lib/gitlab/git/encoding_helper_spec.rb
View file @
33aed43e
...
@@ -2,7 +2,7 @@ require "spec_helper"
...
@@ -2,7 +2,7 @@ require "spec_helper"
describe
Gitlab
::
Git
::
EncodingHelper
do
describe
Gitlab
::
Git
::
EncodingHelper
do
let
(
:ext_class
)
{
Class
.
new
{
extend
Gitlab
::
Git
::
EncodingHelper
}
}
let
(
:ext_class
)
{
Class
.
new
{
extend
Gitlab
::
Git
::
EncodingHelper
}
}
let
(
:binary_string
)
{
File
.
join
(
SEED_STORAGE_PATH
,
'gitlab_logo.png'
)
}
let
(
:binary_string
)
{
File
.
read
(
Rails
.
root
+
"spec/fixtures/dk.png"
)
}
describe
'#encode!'
do
describe
'#encode!'
do
[
[
...
...
spec/validators/dynamic_path_validator_spec.rb
View file @
33aed43e
...
@@ -3,6 +3,28 @@ require 'spec_helper'
...
@@ -3,6 +3,28 @@ require 'spec_helper'
describe
DynamicPathValidator
do
describe
DynamicPathValidator
do
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:path
])
}
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:path
])
}
def
expect_handles_invalid_utf8
expect
{
yield
(
'\255invalid'
)
}.
to
be_falsey
end
describe
'.valid_user_path'
do
it
'handles invalid utf8'
do
expect
(
described_class
.
valid_user_path?
(
"a
\0
weird
\255
path"
)).
to
be_falsey
end
end
describe
'.valid_group_path'
do
it
'handles invalid utf8'
do
expect
(
described_class
.
valid_group_path?
(
"a
\0
weird
\255
path"
)).
to
be_falsey
end
end
describe
'.valid_project_path'
do
it
'handles invalid utf8'
do
expect
(
described_class
.
valid_project_path?
(
"a
\0
weird
\255
path"
)).
to
be_falsey
end
end
describe
'#path_valid_for_record?'
do
describe
'#path_valid_for_record?'
do
context
'for project'
do
context
'for project'
do
it
'calls valid_project_path?'
do
it
'calls valid_project_path?'
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