diff options
author | Nick Thomas <nick@gitlab.com> | 2018-01-18 16:29:00 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-01-18 17:32:19 +0000 |
commit | 3b0235318ef1fd39311910da7eb1893a4d3ae312 (patch) | |
tree | 02c5597d014dd28cf9914c4f246e3d9a874f01bd /spec/lib | |
parent | e56bcf92774b19115f62b609163c44ba9d919e69 (diff) | |
download | gitlab-ce-3b0235318ef1fd39311910da7eb1893a4d3ae312.tar.gz |
Correctly escape UTF-8 path elements for uploads
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/banzai/filter/relative_link_filter_spec.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 7e17457ce70..3ca4652f7cc 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -278,18 +278,19 @@ describe Banzai::Filter::RelativeLinkFilter do expect(doc.at_css('a')['href']).to eq 'http://example.com' end - it 'supports Unicode filenames' do + it 'supports unescaped Unicode filenames' do path = '/uploads/한글.png' - escaped = Addressable::URI.escape(path) + doc = filter(link(path)) - # Stub these methods so the file doesn't actually need to be in the repo - allow_any_instance_of(described_class) - .to receive(:file_exists?).and_return(true) - allow_any_instance_of(described_class) - .to receive(:image?).with(path).and_return(true) + expect(doc.at_css('a')['href']).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png") + end + it 'supports escaped Unicode filenames' do + path = '/uploads/한글.png' + escaped = Addressable::URI.escape(path) doc = filter(image(escaped)) - expect(doc.at_css('img')['src']).to match "/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png" + + expect(doc.at_css('img')['src']).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png") end end |