]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: remove all CR before LF
authorEric Wong <e@80x24.org>
Fri, 11 Feb 2022 20:22:17 +0000 (20:22 +0000)
committerEric Wong <e@80x24.org>
Fri, 11 Feb 2022 20:30:45 +0000 (20:30 +0000)
While we've rendered CR-LF as LF-only in HTML for many years,
some messages end up as CR-CR-LF.  So strip ALL all CR bytes
preceding LF bytes, while preserving odd CR in the middle of
lines.

Reported-by: Thomas Weißschuh <thomas@t-8ch.de>
Link: https://public-inbox.org/meta/8d13668f-cac7-4984-bb4e-ad90502dc46d@t-8ch.de/
lib/PublicInbox/View.pm

index 2e9cf7054243897ea0eb84c7d654f9d0add6906d..ca02ae057f2343ad4d66f9202a8563ccfc46c6ac 100644 (file)
@@ -586,7 +586,7 @@ sub add_text_body { # callback for each_part
 
        # makes no difference to browsers, and don't screw up filename
        # link generation in diffs with the extra '%0D'
 
        # makes no difference to browsers, and don't screw up filename
        # link generation in diffs with the extra '%0D'
-       $s =~ s/\r\n/\n/sg;
+       $s =~ s/\r+\n/\n/sg;
 
        # will be escaped to `&#8226;' in HTML
        obfuscate_addrs($ibx, $s, "\x{2022}") if $ibx->{obfuscate};
 
        # will be escaped to `&#8226;' in HTML
        obfuscate_addrs($ibx, $s, "\x{2022}") if $ibx->{obfuscate};