From 56a7249498e2119fd33f50a782c9db06328b457e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 15 Jul 2016 15:36:56 -0400 Subject: [PATCH] Minor quoting improvements to email cooker --- lib/email_cook.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/email_cook.rb b/lib/email_cook.rb index f2cbaa33c..0e8dad21e 100644 --- a/lib/email_cook.rb +++ b/lib/email_cook.rb @@ -10,6 +10,13 @@ class EmailCook @raw = raw end + def add_quote(result, buffer) + if buffer.present? + return if buffer =~ /\A(
)+\z$/ + result << "
#{buffer}
" + end + end + def cook result = "" @@ -23,7 +30,7 @@ class EmailCook in_quote = true quote_buffer << l.sub(/^[\s>]*/, '') << "
" elsif in_quote - result << "
#{quote_buffer}
" + add_quote(result, quote_buffer) quote_buffer = "" in_quote = false else @@ -49,8 +56,8 @@ class EmailCook end end - if in_quote - result << "
#{quote_buffer}
" + if in_quote && quote_buffer.present? + add_quote(result, quote_buffer) end result.gsub!(/(
\n*){3,10}/, '

')