FIX: make markdown regexp patterns case insensitive.

This commit is contained in:
Vinoth Kannan
2019-09-12 22:25:15 +05:30
parent 568232052e
commit 321f559c7c
2 changed files with 17 additions and 3 deletions

View File

@@ -182,7 +182,7 @@ class InlineUploads
end
def self.match_bbcode_img(markdown, external_src: false)
markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/) do |match|
markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/i) do |match|
if (matched_uploads(match[1]).present? && block_given?) || external_src
yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0])
end
@@ -203,7 +203,7 @@ class InlineUploads
end
def self.match_anchor(markdown, external_href: false)
markdown.scan(/((<a[^<]+>)([^<\a>]*?)<\/a>)/) do |match|
markdown.scan(/((<a[^<]+>)([^<\a>]*?)<\/a>)/i) do |match|
node = Nokogiri::HTML::fragment(match[0]).children[0]
href = node.attributes["href"]&.value
@@ -219,7 +219,7 @@ class InlineUploads
end
def self.match_img(markdown, external_src: false)
markdown.scan(/(([ ]*)<(?!img)[^<>]+\/?>)?([\r\n]*)(([ ]*)<img ([^>\n]+)>([ ]*))([\r\n]*)/) do |match|
markdown.scan(/(([ ]*)<(?!img)[^<>]+\/?>)?([\r\n]*)(([ ]*)<img ([^>\n]+)>([ ]*))([\r\n]*)/i) do |match|
node = Nokogiri::HTML::fragment(match[3].strip).children[0]
src = node.attributes["src"]&.value