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
a832e69c
Commit
a832e69c
authored
Mar 04, 2020
by
Lucas Charles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rescue invalid URLs during badge retrieval in asset proxy
parent
db0d1c9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
changelogs/unreleased/use-addressable-for-asset-proxy-badge-render.yml
...released/use-addressable-for-asset-proxy-badge-render.yml
+5
-0
lib/gitlab/asset_proxy.rb
lib/gitlab/asset_proxy.rb
+3
-1
spec/lib/gitlab/asset_proxy_spec.rb
spec/lib/gitlab/asset_proxy_spec.rb
+7
-1
No files found.
changelogs/unreleased/use-addressable-for-asset-proxy-badge-render.yml
0 → 100644
View file @
a832e69c
---
title
:
Rescue invalid URLs during badge retrieval in asset proxy
merge_request
:
26524
author
:
type
:
fixed
lib/gitlab/asset_proxy.rb
View file @
a832e69c
...
...
@@ -11,12 +11,14 @@ module Gitlab
return
url
if
asset_host_whitelisted?
(
url
)
"
#{
Gitlab
.
config
.
asset_proxy
.
url
}
/
#{
asset_url_hash
(
url
)
}
/
#{
hexencode
(
url
)
}
"
rescue
Addressable
::
URI
::
InvalidURIError
url
end
private
def
asset_host_whitelisted?
(
url
)
parsed_url
=
URI
.
parse
(
url
)
parsed_url
=
Addressable
::
URI
.
parse
(
url
)
Gitlab
.
config
.
asset_proxy
.
domain_regexp
&
.
match?
(
parsed_url
.
host
)
end
...
...
spec/lib/gitlab/asset_proxy_spec.rb
View file @
a832e69c
...
...
@@ -33,9 +33,15 @@ describe Gitlab::AssetProxy do
expect
(
described_class
.
proxy_url
(
url
)).
to
eq
(
proxied_url
)
end
it
'returns original URL for invalid domains'
do
url
=
'foo_bar://'
expect
(
described_class
.
proxy_url
(
url
)).
to
eq
(
url
)
end
context
'whitelisted domain'
do
it
'returns original URL for single domain whitelist'
do
url
=
'http://gitlab.com/test.png'
url
=
'http://gitlab.com/
${default_branch}/
test.png'
expect
(
described_class
.
proxy_url
(
url
)).
to
eq
(
url
)
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