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
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
dynamic_path_validator.rb
app/validators/dynamic_path_validator.rb
+5
-0
encoding_helper_spec.rb
spec/lib/gitlab/git/encoding_helper_spec.rb
+1
-1
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 @@
# Values are checked for formatting and exclusion from a list of illegal path
# names.
class
DynamicPathValidator
<
ActiveModel
::
EachValidator
extend
Gitlab
::
Git
::
EncodingHelper
class
<<
self
def
valid_user_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
root_namespace_path_regex
end
def
valid_group_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_namespace_path_regex
end
def
valid_project_path?
(
path
)
encode!
(
path
)
"
#{
path
}
/"
=~
Gitlab
::
PathRegex
.
full_project_path_regex
end
end
...
...
spec/lib/gitlab/git/encoding_helper_spec.rb
View file @
33aed43e
...
...
@@ -2,7 +2,7 @@ require "spec_helper"
describe
Gitlab
::
Git
::
EncodingHelper
do
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
[
...
...
spec/validators/dynamic_path_validator_spec.rb
View file @
33aed43e
...
...
@@ -3,6 +3,28 @@ require 'spec_helper'
describe
DynamicPathValidator
do
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
context
'for project'
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