1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 23:11:12 +00:00

Allow newlines and quote characters within mail body delimiters (#34794).

Patch by Holger Just.


git-svn-id: http://svn.redmine.org/redmine/trunk@20767 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2021-03-09 08:28:01 +00:00
parent 4031ac3139
commit 2cbf5bb29e
2 changed files with 14 additions and 2 deletions

View File

@ -622,10 +622,21 @@ class MailHandler < ActionMailer::Base
rescue RegexpError => e rescue RegexpError => e
logger&.error "MailHandler: invalid regexp delimiter found in mail_handler_body_delimiters setting (#{e.message})" logger&.error "MailHandler: invalid regexp delimiter found in mail_handler_body_delimiters setting (#{e.message})"
end end
else
# In a "normal" delimiter, allow a single space from the originally
# defined delimiter to match:
# * any space-like character, or
# * line-breaks and optional quoting with arbitrary spacing around it
# in the mail in order to allow line breaks of delimiters.
delimiters = delimiters.map do |delimiter|
delimiter = Regexp.escape(delimiter).encode!(Encoding::UTF_8)
delimiter = delimiter.gsub(/(\\ )+/, '\p{Space}*(\p{Space}|[\r\n](\p{Space}|>)*)')
Regexp.new(delimiter)
end
end end
unless delimiters.empty? unless delimiters.empty?
regex = Regexp.new("^[> ]*(#{ Regexp.union(delimiters) })[[:blank:]]*[\r\n].*", Regexp::MULTILINE) regex = Regexp.new("^(\\p{Space}|>)*(#{ Regexp.union(delimiters) })\\p{Space}*[\\r\\n].*", Regexp::MULTILINE)
body = body.gsub(regex, '') body = body.gsub(regex, '')
end end
body.strip body.strip

View File

@ -33,7 +33,8 @@ sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
platea dictumst. platea dictumst.
> --- Reply above. Do not remove this line. --- > --- Reply above. Do not
> remove this line. ---
> >
> Issue #6779 has been updated by Eric Davis. > Issue #6779 has been updated by Eric Davis.
> >