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
9a281ff0
Commit
9a281ff0
authored
Dec 04, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify string_malformed middleware
parent
218bcfa2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
lib/gitlab/middleware/handle_malformed_strings.rb
lib/gitlab/middleware/handle_malformed_strings.rb
+2
-8
spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
+1
-1
spec/requests/git_http_spec.rb
spec/requests/git_http_spec.rb
+10
-0
No files found.
lib/gitlab/middleware/handle_malformed_strings.rb
View file @
9a281ff0
...
...
@@ -61,7 +61,7 @@ module Gitlab
return
false
unless
credentials
credentials_
string_malformed?
(
credentials
)
string_malformed?
(
credentials
)
end
def
param_has_null_byte?
(
value
,
depth
=
0
)
...
...
@@ -93,14 +93,8 @@ module Gitlab
# We try to encode the string from ASCII-8BIT to UTF8. If we failed to do
# so for certain characters in the string, those chars are probably incomplete
# multibyte characters.
string
.
encode
(
Encoding
::
UTF_8
).
match?
(
NULL_BYTE_REGEX
)
rescue
ArgumentError
,
Encoding
::
UndefinedConversionError
# If we're here, we caught a malformed string. Return true
true
end
string
.
dup
.
force_encoding
(
'UTF-8'
).
match?
(
NULL_BYTE_REGEX
)
def
credentials_string_malformed?
(
string
)
string
.
force_encoding
(
'UTF-8'
).
match?
(
NULL_BYTE_REGEX
)
rescue
ArgumentError
,
Encoding
::
UndefinedConversionError
# If we're here, we caught a malformed string. Return true
true
...
...
spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
View file @
9a281ff0
#
rubocop:disable Style/FrozenStringLiteralComment
#
frozen_string_literal: true
require
'spec_helper'
require
"rack/test"
...
...
spec/requests/git_http_spec.rb
View file @
9a281ff0
...
...
@@ -280,6 +280,16 @@ RSpec.describe 'Git HTTP requests' do
project
.
add_developer
(
user
)
end
context
'when user is using password with special characters'
do
it
'allows clones'
do
user
.
update!
(
password:
'RçKszEwéC5kFnû∆f243fycGu§Gh9ftDj!U'
)
download
(
path
,
user:
user
.
username
,
password:
user
.
password
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
context
'but the repo is disabled'
do
let
(
:project
)
{
create
(
:project
,
:wiki_repo
,
:private
,
:repository_disabled
,
:wiki_enabled
)
}
...
...
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