diff options
author | Jan Beckmann <king-jan1999@hotmail.de> | 2018-03-14 21:33:18 +0100 |
---|---|---|
committer | Jan Beckmann <king-jan1999@hotmail.de> | 2018-03-14 21:33:18 +0100 |
commit | f97dffdd6eaf7e2bd4804309417cabe8b50efa90 (patch) | |
tree | 8c21105656a7a3baf7c870a8c561df3beac1804c /spec | |
parent | 2824a72552f6c54585cca97d5ffa9477aa8f8269 (diff) | |
download | gitlab-ce-f97dffdd6eaf7e2bd4804309417cabe8b50efa90.tar.gz |
add spec testing '#' escape in relative link filter
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/banzai/filter/relative_link_filter_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 3ca4652f7cc..ba8dc68ceda 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -217,6 +217,23 @@ describe Banzai::Filter::RelativeLinkFilter do end end + context 'when ref name contains special chars' do + let(:ref) {'mark#\'@],+;-._/#@!$&()+down'} + + it 'correctly escapes the ref' do + # Adressable won't escape the '#', so we do this manually + ref_escaped = 'mark%23\'@%5D,+;-._/%23@!$&()+down' + + # Stub this method so the branch doesn't actually need to be in the repo + allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw) + + doc = filter(link('files/images/logo-black.png')) + + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png" + end + end + context 'when requested path is a directory with space in the repo' do let(:ref) { 'master' } let(:commit) { project.commit('38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e') } |