mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +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:
parent
4031ac3139
commit
2cbf5bb29e
@ -622,10 +622,21 @@ class MailHandler < ActionMailer::Base
|
||||
rescue RegexpError => e
|
||||
logger&.error "MailHandler: invalid regexp delimiter found in mail_handler_body_delimiters setting (#{e.message})"
|
||||
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
|
||||
|
||||
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, '')
|
||||
end
|
||||
body.strip
|
||||
|
||||
@ -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
|
||||
platea dictumst.
|
||||
|
||||
> --- Reply above. Do not remove this line. ---
|
||||
> --- Reply above. Do not
|
||||
> remove this line. ---
|
||||
>
|
||||
> Issue #6779 has been updated by Eric Davis.
|
||||
>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user