A platform for community discussion. Free, open, simple.
FIX: URL with params for svg images should not be light boxed.
Guo Xiang Tan806f0ca19d0e
diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rbindex 93866749e54..e89cee74bb2 100644--- a/lib/cooked_post_processor.rb+++ b/lib/cooked_post_processor.rb@@ -541,7 +541,14 @@ class CookedPostProcessorprivatedef 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 pathendenddiff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rbindex 1c3da190cca..0d1fa216a31 100644--- a/spec/components/cooked_post_processor_spec.rb+++ b/spec/components/cooked_post_processor_spec.rb@@ -178,6 +178,19 @@ describe CookedPostProcessor doexpect(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+ endendend