FIX: Skip upload if HTML cannot be parsed (#12971)
This commit is contained in:
parent
3a1b05f219
commit
c0679022e7
|
@ -200,7 +200,7 @@ class InlineUploads
|
|||
def self.match_img(markdown, external_src: false, uploads: nil)
|
||||
markdown.scan(/(<(?!img)[^<>]+\/?>)?(\s*)(<img [^>\n]+>)/i) do |match|
|
||||
node = Nokogiri::HTML5::fragment(match[2].strip).children[0]
|
||||
src = node.attributes["src"]&.value
|
||||
src = node&.attributes&.[]("src")&.value
|
||||
|
||||
if src && (matched_uploads(src).present? || external_src)
|
||||
upload = uploads&.[](src)
|
||||
|
|
|
@ -54,6 +54,11 @@ RSpec.describe InlineUploads do
|
|||
MD
|
||||
end
|
||||
|
||||
it "should work with invalid img tags" do
|
||||
md = '<img data-id="<>">'
|
||||
expect(InlineUploads.process(md)).to eq(md)
|
||||
end
|
||||
|
||||
it "should not correct code blocks" do
|
||||
md = "`<a class=\"attachment\" href=\"#{upload2.url}\">In Code Block</a>`"
|
||||
|
||||
|
|
Loading…
Reference in New Issue