diff --git a/lib/email_cook.rb b/lib/email_cook.rb index 56eca025fcf..bc1f587944d 100644 --- a/lib/email_cook.rb +++ b/lib/email_cook.rb @@ -17,6 +17,13 @@ class EmailCook end end + def link_string!(str) + str.scan(EmailCook.url_regexp).each do |m| + url = m[0] + str.gsub!(url, "#{url}") + end + end + def cook result = "" @@ -28,6 +35,7 @@ class EmailCook if l =~ /^\s*>/ in_quote = true + link_string!(l) quote_buffer << l.sub(/^[\s>]*/, '') << "
" elsif in_quote add_quote(result, quote_buffer) @@ -37,10 +45,7 @@ class EmailCook sz = l.size - l.scan(EmailCook.url_regexp).each do |m| - url = m[0] - l.gsub!(url, "#{url}") - end + link_string!(l) result << l diff --git a/spec/components/email_cook_spec.rb b/spec/components/email_cook_spec.rb index 15844764d19..fff81d40b80 100644 --- a/spec/components/email_cook_spec.rb +++ b/spec/components/email_cook_spec.rb @@ -34,4 +34,8 @@ LONG_COOKED it 'autolinks without the beginning of a line' do expect(EmailCook.new("my site: https://www.eviltrout.com").cook).to eq("my site: https://www.eviltrout.com
") end + + it 'links even within a quote' do + expect(EmailCook.new("> https://www.eviltrout.com").cook).to eq("
https://www.eviltrout.com
") + end end