FIX: URL with params for svg images should not be light boxed.

This commit is contained in:
Guo Xiang Tan 2018-06-20 10:47:14 +08:00
parent ca4d08f9d9
commit 806f0ca19d
2 changed files with 21 additions and 1 deletions

View File

@ -541,7 +541,14 @@ class CookedPostProcessor
private
def is_svg?(img)
File.extname(img["src"]) == '.svg'
path =
begin
URI(img["src"]).path
rescue URI::InvalidURIError, URI::InvalidComponentError
nil
end
File.extname(path) == '.svg' if path
end
end

View File

@ -178,6 +178,19 @@ describe CookedPostProcessor do
expect(cpp.html).to match_html("<p><img src=\"/uploads/default/1/1234567890123456.svg\" width=\"690\"\ height=\"788\"></p>")
end
describe 'when image src is an URL' do
let(:post) do
Fabricate(:post, raw: '<img src="http://test.discourse/uploads/default/1/1234567890123456.svg?somepamas">')
end
it 'should not add lightbox' do
SiteSetting.crawl_images = true
cpp.post_process_images
expect(cpp.html).to match_html("<p><img src=\"http://test.discourse/uploads/default/1/1234567890123456.svg?somepamas\" width=\"690\"\ height=\"788\"></p>")
end
end
end
end