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
b7204098
Commit
b7204098
authored
Dec 20, 2019
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix invalid byte sequence for uploads links
parent
f93f3565
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
changelogs/unreleased/security-fix-invalid-byte-sequence-upload-links-master.yml
...ecurity-fix-invalid-byte-sequence-upload-links-master.yml
+5
-0
lib/banzai/filter/relative_link_filter.rb
lib/banzai/filter/relative_link_filter.rb
+9
-3
spec/lib/banzai/filter/relative_link_filter_spec.rb
spec/lib/banzai/filter/relative_link_filter_spec.rb
+9
-0
No files found.
changelogs/unreleased/security-fix-invalid-byte-sequence-upload-links-master.yml
0 → 100644
View file @
b7204098
---
title
:
Fix 500 error caused by invalid byte sequences in uploads links
merge_request
:
author
:
type
:
security
lib/banzai/filter/relative_link_filter.rb
View file @
b7204098
...
...
@@ -116,7 +116,7 @@ module Banzai
end
def
process_link_to_upload_attr
(
html_attr
)
path_parts
=
[
Addressable
::
URI
.
unescape
(
html_attr
.
value
)]
path_parts
=
[
unescape_and_scrub_uri
(
html_attr
.
value
)]
if
project
path_parts
.
unshift
(
relative_url_root
,
project
.
full_path
)
...
...
@@ -172,7 +172,7 @@ module Banzai
end
def
cleaned_file_path
(
uri
)
Addressable
::
URI
.
unescape
(
uri
.
path
).
scrub
.
delete
(
"
\0
"
).
chomp
(
"/"
)
unescape_and_scrub_uri
(
uri
.
path
)
.
delete
(
"
\0
"
).
chomp
(
"/"
)
end
def
relative_file_path
(
uri
)
...
...
@@ -184,7 +184,7 @@ module Banzai
def
request_path
return
unless
context
[
:requested_path
]
Addressable
::
URI
.
unescape
(
context
[
:requested_path
]).
chomp
(
"/"
)
unescape_and_scrub_uri
(
context
[
:requested_path
]).
chomp
(
"/"
)
end
# Convert a relative path into its correct location based on the currently
...
...
@@ -266,6 +266,12 @@ module Banzai
def
repository
@repository
||=
project
&
.
repository
end
private
def
unescape_and_scrub_uri
(
uri
)
Addressable
::
URI
.
unescape
(
uri
).
scrub
end
end
end
end
spec/lib/banzai/filter/relative_link_filter_spec.rb
View file @
b7204098
...
...
@@ -128,6 +128,15 @@ describe Banzai::Filter::RelativeLinkFilter do
expect
{
filter
(
act
)
}.
not_to
raise_error
end
it
'does not raise an exception on URIs containing invalid utf-8 byte sequences in uploads'
do
act
=
link
(
"/uploads/%FF"
)
expect
{
filter
(
act
)
}.
not_to
raise_error
end
it
'does not raise an exception on URIs containing invalid utf-8 byte sequences in context requested path'
do
expect
{
filter
(
link
(
"files/test.md"
),
requested_path:
'%FF'
)
}.
not_to
raise_error
end
it
'does not raise an exception with a garbled path'
do
act
=
link
(
"open(/var/tmp/):%20/location%0Afrom:%20/test"
)
expect
{
filter
(
act
)
}.
not_to
raise_error
...
...
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