]> Sergey Matveev's repositories - public-inbox.git/commitdiff
solver: force quoted-printable bodies to LF
authorEric Wong <e@80x24.org>
Sun, 20 Jan 2019 13:46:28 +0000 (13:46 +0000)
committerEric Wong <e@80x24.org>
Sun, 20 Jan 2019 20:22:45 +0000 (20:22 +0000)
..if the Email::MIME ->crlf is LF.

Email::MIME::Encodings forces everything to CRLF on
quoted-printable messages for RFC-compliance; and
git-apply --ignore-whitespace seems to miss a context
line which is just "\r\n" (w/o leading space).

lib/PublicInbox/SolverGit.pm

index 8fde2329fa757a639aba76375c4ab63ffa55ab1b..612f495bd3bc2ba0c9a0d51b11a82a348865f72e 100644 (file)
@@ -78,6 +78,14 @@ sub extract_diff ($$$$) {
        my ($s, undef) = msg_part_text($part, $ct);
        defined $s or return;
        my $di = {};
+
+       # Email::MIME::Encodings forces QP to be CRLF upon decoding,
+       # change it back to LF:
+       my $cte = $part->header('Content-Transfer-Encoding') || '';
+       if ($cte =~ /\bquoted-printable\b/i && $part->crlf eq "\n") {
+               $s =~ s/\r\n/\n/sg;
+       }
+
        foreach my $l (split(/^/m, $s)) {
                if ($l =~ $re) {
                        $di->{oid_a} = $1;