Commit 9a281ff0 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Modify string_malformed middleware

parent 218bcfa2
......@@ -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
......
# rubocop:disable Style/FrozenStringLiteralComment
# frozen_string_literal: true
require 'spec_helper'
require "rack/test"
......
......@@ -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) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment