Merge branch 'sh-catch-invalid-uri-markdown' into 'master'

Gracefully handle garbled URIs in Markdown

Closes #41442

See merge request gitlab-org/gitlab-ce!16123
This commit is contained in:
Robert Speicher 2017-12-25 18:24:59 +00:00
commit 29749f92b7
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
title: Gracefully handle garbled URIs in Markdown
merge_request:
author:
type: fixed

View File

@ -66,7 +66,7 @@ module Banzai
if uri.relative? && uri.path.present?
html_attr.value = rebuild_relative_uri(uri).to_s
end
rescue URI::Error
rescue URI::Error, Addressable::URI::InvalidURIError
# noop
end

View File

@ -76,6 +76,11 @@ describe Banzai::Filter::RelativeLinkFilter do
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
end
it 'ignores ref if commit is passed' do
doc = filter(link('non/existent.file'), commit: project.commit('empty-branch') )
expect(doc.at_css('a')['href'])