From: Samuel GROOT Date: Wed, 08 Jun 2016 23:54:03 GMT Subject: Re: [PATCH v4 4/6] send-email: create email parser subroutine Message-ID: <4c1dcf95-d8bb-4649-8980-fa947617b96e@grenoble-inp.org> In-Reply-To: On 06/08/2016 10:17 PM, Junio C Hamano wrote: > Eric Sunshine writes: > >> An embedded CR probably shouldn't happen, but I'm not convinced that >> folding it out is a good idea. I would think that you'd want to >> preserve the header's value verbatim. If anything, I'd expect to see >> the regex tightened to: >> >> s/\r?\n$//; > > Yes, that would be more sensible than silently removing \r in the > middle which _is_ a sign of something funny going on. >> Alternately, consider using 'chop' or 'chomp'. > > Even if you use chomp(), you'd still need to worry about possible \r > at the end, no? 'chomp' is what we used before, but with *.eml files (microsoft's file format, with CRLF), '\n' were removed but '\r' remained, that's why we used s/\r\n|\r|\n//. s/\r?\n$// looks fine. Email::Simple library uses qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/ [1]. Should we handle \n\r at end of line as well? [1] * http://cpansearch.perl.org/src/RJBS/Email-Simple-2.210/lib/Email/Simple.pm