Skip to content
Snippets Groups Projects
Commit 1fdceefa authored by GitLab Release Tools Bot's avatar GitLab Release Tools Bot
Browse files

Merge branch 'security-dos-issue-and-commit-comments-12-3' into '12-3-stable'

Fix invalid byte sequence

See merge request gitlab/gitlabhq!3549
parents 17f98469 0159e004
No related branches found
No related tags found
No related merge requests found
---
title: Fix 500 error caused by invalid byte sequences in links
merge_request:
author:
type: security
Loading
Loading
@@ -103,7 +103,7 @@ module Banzai
end
 
def relative_file_path(uri)
path = Addressable::URI.unescape(uri.path).delete("\0")
path = Addressable::URI.unescape(uri.path).scrub.delete("\0")
request_path = Addressable::URI.unescape(context[:requested_path])
nested_path = build_relative_path(path, request_path)
file_exists?(nested_path) ? nested_path : path
Loading
Loading
Loading
Loading
@@ -87,6 +87,11 @@ 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' do
act = link("%FF")
expect { filter(act) }.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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment