diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb index 816e848f7d1..4ae95e8ce56 100644 --- a/app/services/inline_uploads.rb +++ b/app/services/inline_uploads.rb @@ -177,7 +177,7 @@ class InlineUploads end def self.match_bbcode_img(markdown, external_src: false) - markdown.scan(/(\[img\]\s?(.+)\s?\[\/img\])/) do |match| + markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/) do |match| if (matched_uploads(match[1]).present? && block_given?) || external_src yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0]) end diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb index e563eee1435..ef7f48d7c73 100644 --- a/spec/services/inline_uploads_spec.rb +++ b/spec/services/inline_uploads_spec.rb @@ -163,6 +163,8 @@ RSpec.describe InlineUploads do [img] #{upload2.url} [/img] + + [img]#{upload.url}[/img][img]#{upload2.url}[/img] MD expect(InlineUploads.process(md)).to eq(<<~MD) @@ -171,6 +173,8 @@ RSpec.describe InlineUploads do ![](#{upload3.short_url}) ![](#{upload2.short_url}) + + ![](#{upload.short_url})![](#{upload2.short_url}) MD end