FIX: Correct more edge cases with `InlineUploads`.

approved
#1

FIX: Correct more edge cases with InlineUploads.

diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb
index 42f410d..45afd7b 100644
--- a/app/services/inline_uploads.rb
+++ b/app/services/inline_uploads.rb
@@ -193,7 +193,7 @@ class InlineUploads
   end
 
   def self.match_img(markdown, external_src: false)
-    markdown.scan(/(<(?!img)[^<>]+\/?>)?(\n*)(([ ]*)<img ([^<>]+)>([ ]*))(\n*)/) do |match|
+    markdown.scan(/(<(?!img)[^<>]+\/?>)?(\n*)(([ ]*)<img ([^>\n]+)>([ ]*))(\n*)/) do |match|
       node = Nokogiri::HTML::fragment(match[2].strip).children[0]
       src =  node.attributes["src"]&.value
 
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index 4eb1495..5efb98a 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -298,6 +298,8 @@ RSpec.describe InlineUploads do
 
         <img src="#{upload.url}" alt="test">
 
+        <img src="#{upload2.url}" alt="test" height="150<img">
+
         > some quote
 
         <a class="attachment" href="#{upload2.url}">test2</a>
@@ -310,6 +312,8 @@ RSpec.describe InlineUploads do
 
         ![test](#{upload.short_url})
 
+        ![test](#{upload2.short_url})
+
         > some quote
 
         [test2|attachment](#{upload2.short_url})

GitHub sha: 73bf880f

1 Like
Approved #2