Patch #17718

Body delimiters to truncate emails do not take uncommon whitespace into account

Added by Holger Just over 3 years ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email receiving
Target version:3.4.0

Description

The function which truncate emails after a certain delimiter was found (i.e. MailHandler#cleanup_body) currently does not take trailing whitespace into account that is not part of \s. This e.g. includes non-breaking spaces which are common after e.g. signature delimiters (hyphen hyphen no-break-space).

This results in delimiters being not taken into account if there are these unicode whitespace characters at the end of the line.

The attached patch fixes this for Ruby versions >= 1.9. I have found no generally reliable way to fix this for Ruby 1.8 which thus retains the previous behavior. The reason this only works on Ruby >= 1.9 is that only this version includes a possibility to match unicode whitespace. Ruby 1.8 only has a limited list of ASCII characters (against the unicode spec apparently).

Given that I can't change the behavior on 1.8, this change is unfortunately rather difficult to test. I have also attached a patch with improved tests which work properly on 1.9 and 2.0 but breaks on 1.8 as it doesn't recognize the change in behavior. Given that, I'd rather prefer to pull the improvement of behavior without the test than to hold everything out...

Associated revisions

Revision 16609
Added by Toshi MARUYAMA 6 months ago

allow unicode whitespace after mail handler body delimiters (#17718)

Contributed by Holger Just and Marius BALTEANU.

History

#1 Updated by Jan Niggemann (redmine.org team member) over 3 years ago

  • Tracker changed from Defect to Patch

Thank you, Holger!

#2 Updated by Toshi MARUYAMA about 3 years ago

  • Target version set to 2.6.0

#3 Updated by Toshi MARUYAMA about 3 years ago

  • Target version changed from 2.6.0 to Candidate for next major release

#4 Updated by Go MAEDA 11 months ago

Current versions of Redmine don't support Ruby 1.8 (#14371).
I think the rebased version of the patch can be merged into Redmine core.

#5 Updated by Marius BALTEANU 7 months ago

Updated Holger Just first patch to apply cleanly.

#6 Updated by Go MAEDA 7 months ago

  • Target version changed from Candidate for next major release to 3.4.0

Thank you for fixing the patch. Now we can apply 0001-Allow-unicode-whitespace-after-mail-handler-body-del_r16545.patch and 0002-Add-test-for-trailing-unicode-whitespace-after-email.patch to the current trunk.
Setting target version to 3.4.0.

#7 Updated by Toshi MARUYAMA 6 months ago

  • Status changed from New to Closed

Committed in trunk, thanks.

Also available in: Atom PDF