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
1c87bacb
Commit
1c87bacb
authored
Sep 04, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a regression breaking projects with an empty import URL
parent
0ae313c4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
22 deletions
+33
-22
app/validators/addressable_url_validator.rb
app/validators/addressable_url_validator.rb
+1
-3
changelogs/unreleased-ee/3288-fix-repository-mirroring-when-url-is-empty-string.yml
...288-fix-repository-mirroring-when-url-is-empty-string.yml
+5
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-1
lib/gitlab/url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+1
-1
spec/ee/spec/models/ee/project_spec.rb
spec/ee/spec/models/ee/project_spec.rb
+23
-17
spec/lib/gitlab/url_sanitizer_spec.rb
spec/lib/gitlab/url_sanitizer_spec.rb
+1
-0
No files found.
app/validators/addressable_url_validator.rb
View file @
1c87bacb
...
...
@@ -29,9 +29,7 @@ class AddressableUrlValidator < ActiveModel::EachValidator
private
def
valid_url?
(
value
)
return
false
unless
value
valid_protocol?
(
value
)
&&
valid_uri?
(
value
)
valid_uri?
(
value
)
&&
valid_protocol?
(
value
)
end
def
valid_uri?
(
value
)
...
...
changelogs/unreleased-ee/3288-fix-repository-mirroring-when-url-is-empty-string.yml
0 → 100644
View file @
1c87bacb
---
title
:
Fix a regression breaking projects with an empty import URL
merge_request
:
2824
author
:
type
:
fixed
ee/app/models/ee/project.rb
View file @
1c87bacb
...
...
@@ -384,7 +384,8 @@ module EE
def
username_only_import_url
=
(
value
)
unless
::
Gitlab
::
UrlSanitizer
.
valid?
(
value
)
self
.
import_url
=
value
return
self
.
import_data
&
.
user
=
nil
return
value
end
url
=
::
Gitlab
::
UrlSanitizer
.
new
(
value
)
...
...
lib/gitlab/url_sanitizer.rb
View file @
1c87bacb
...
...
@@ -9,7 +9,7 @@ module Gitlab
end
def
self
.
valid?
(
url
)
return
false
unless
url
return
false
unless
url
.
present?
Addressable
::
URI
.
parse
(
url
.
strip
)
...
...
spec/ee/spec/models/ee/project_spec.rb
View file @
1c87bacb
...
...
@@ -814,28 +814,24 @@ describe Project do
end
describe
'#username_only_import_url'
do
def
build_project
(
username:
'user'
,
password:
'password'
)
build
(
:project
,
import_url:
'http://example.com'
).
tap
do
|
project
|
project
.
build_import_data
(
credentials:
{
user:
username
,
password:
password
})
end
end
where
(
:import_url
,
:username
,
:expected_import_url
)
do
''
|
'foo'
|
''
''
|
''
|
''
''
|
nil
|
''
it
'shows the bare url when no username is present'
do
project
=
build_project
(
username:
nil
)
nil
|
'foo'
|
nil
nil
|
''
|
nil
nil
|
nil
|
nil
expect
(
project
.
username_only_import_url
).
to
eq
(
'http://example.com'
)
'http://example.com'
|
'foo'
|
'http://foo@example.com'
'http://example.com'
|
''
|
'http://example.com'
'http://example.com'
|
nil
|
'http://example.com'
end
it
'shows the URL with username when present'
do
project
=
build_project
(
password:
nil
)
with_them
do
let
(
:project
)
{
build
(
:project
,
import_url:
import_url
,
import_data_attributes:
{
user:
username
,
password:
'password'
})
}
expect
(
project
.
username_only_import_url
).
to
eq
(
'http://user@example.com'
)
end
it
'excludes the pasword when present'
do
project
=
build_project
expect
(
project
.
username_only_import_url
).
to
eq
(
'http://user@example.com'
)
it
{
expect
(
project
.
username_only_import_url
).
to
eq
(
expected_import_url
)
}
end
end
...
...
@@ -855,5 +851,15 @@ describe Project do
expect
(
project
.
import_url
).
to
eq
(
'http://user:pass@example.com'
)
expect
(
project
.
import_data
.
password
).
to
eq
(
'pass'
)
end
it
'clears the username if passed the empty string'
do
project
=
build
(
:project
,
import_url:
'http://olduser:pass@old.example.com'
)
project
.
username_only_import_url
=
''
expect
(
project
.
username_only_import_url
).
to
eq
(
''
)
expect
(
project
.
import_url
).
to
eq
(
''
)
expect
(
project
.
import_data
.
user
).
to
be_nil
expect
(
project
.
import_data
.
password
).
to
eq
(
'pass'
)
end
end
end
spec/lib/gitlab/url_sanitizer_spec.rb
View file @
1c87bacb
...
...
@@ -57,6 +57,7 @@ describe Gitlab::UrlSanitizer do
describe
'.valid?'
do
it
'validates url strings'
do
expect
(
described_class
.
valid?
(
nil
)).
to
be
(
false
)
expect
(
described_class
.
valid?
(
''
)).
to
be
(
false
)
expect
(
described_class
.
valid?
(
'valid@project:url.git'
)).
to
be
(
true
)
expect
(
described_class
.
valid?
(
'123://invalid:url'
)).
to
be
(
false
)
end
...
...
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