From dd0f0494c64e75046a4f26e3e46c132edb750cb0 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Wed, 17 Jul 2019 09:15:09 +0530 Subject: [PATCH] FIX: convert hotlinked non-image urls to short url. 3840ace97820acf98cb8f58ab1cab96f66e2def2 --- app/services/inline_uploads.rb | 5 ----- spec/services/inline_uploads_spec.rb | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb index 13d5db72dd0..6f1cedeb4a4 100644 --- a/app/services/inline_uploads.rb +++ b/app/services/inline_uploads.rb @@ -123,11 +123,6 @@ class InlineUploads .sort { |a, b| a[3] <=> b[3] } .each do |match, link, replace_with, _index| - if match == link - extension = match.split(".")[-1].downcase - next if FileHelper.supported_images.exclude?(extension) - end - node_info = link_occurences.shift next unless node_info&.dig(:is_valid) diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb index dfc2ec4b015..dd9c1090597 100644 --- a/spec/services/inline_uploads_spec.rb +++ b/spec/services/inline_uploads_spec.rb @@ -228,7 +228,7 @@ RSpec.describe InlineUploads do MD end - it "should not correct non image URLs to the short url and paths" do + it "should correct non image URLs to the short url" do SiteSetting.authorized_extensions = "mp4" upload = Fabricate(:video_upload) @@ -236,7 +236,9 @@ RSpec.describe InlineUploads do #{GlobalSetting.cdn_url}#{upload.url} MD - expect(InlineUploads.process(md)).to eq(md) + expect(InlineUploads.process(md)).to eq(<<~MD) + #{Discourse.base_url}#{upload.short_path} + MD end it "should correct img tags with uppercase upload extension" do