diff options
author | Robert Speicher <robert@gitlab.com> | 2017-12-25 18:24:59 +0000 |
---|---|---|
committer | Tiago <tiagonbotelho@hotmail.com> | 2018-01-19 14:53:05 +0000 |
commit | f921c6e233f3b936ea94e4020cf1e90b3cd17048 (patch) | |
tree | 753a19d7073a326b8b9fb0394a18e880196eb5a7 | |
parent | 69cf3fa982d51c94cf605a6deaab11dbfd719ca7 (diff) | |
download | gitlab-ce-f921c6e233f3b936ea94e4020cf1e90b3cd17048.tar.gz |
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
(cherry picked from commit 29749f92b7f86d45af41509262601e47ee848d92)
0faf772b Gracefully handle garbled URIs in Markdown
-rw-r--r-- | changelogs/unreleased/sh-catch-invalid-uri-markdown.yml | 5 | ||||
-rw-r--r-- | lib/banzai/filter/relative_link_filter.rb | 2 | ||||
-rw-r--r-- | spec/lib/banzai/filter/relative_link_filter_spec.rb | 5 |
3 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-catch-invalid-uri-markdown.yml b/changelogs/unreleased/sh-catch-invalid-uri-markdown.yml new file mode 100644 index 00000000000..9b0233fe988 --- /dev/null +++ b/changelogs/unreleased/sh-catch-invalid-uri-markdown.yml @@ -0,0 +1,5 @@ +--- +title: Gracefully handle garbled URIs in Markdown +merge_request: +author: +type: fixed diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 758f15c8a67..63017ada36d 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -42,7 +42,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 diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 08beede62db..f24e7be6b4e 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -70,6 +70,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']) |