Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message
- From
Jay Soffian <jaysoffian@gmail.com>
- Date
- Apr 19, 2009, 14:13 UTC
- Message-ID
- <76718490904190713l3d6b5abcmf54544512de87413@mail.gmail.com>
- In-Reply-To
- <b4087cc50904181937q38ef45fm7409e020ecf40792@mail.gmail.com>
On Sat, Apr 18, 2009 at 10:37 PM, Michael Witten <mfwitten@gmail.com> wrote:
Show 9 quoted lines
> On Sat, Apr 18, 2009 at 20:54, Jay Soffian <jaysoffian@gmail.com> wrote: >> On Sat, Apr 18, 2009 at 1:02 PM, Michael Witten <mfwitten@gmail.com> wrote: >>> + my $sanitized_subject = ($subject =~ /[^[:ascii:]]/) ? quote_rfc2047($subject) : $subject; >> >> I wonder if it would be clearer to always call quote_rfc2047, then >> have that function just return its input unaltered if quoting is not >> needed. > > It actually ALWAYS changes the input. This code:
I think I was not clear. My suggestion was to move the /[^[:ascii:]]/ check to the inside of quote_rfc2047 exactly so that it doesn't always change its input. i.e.
> sub quote_rfc2047 {
> local $_ = shift;Add this:
return $_ unless /[^[:ascii:]]/;Show 5 quoted lines
> my $encoding = shift || 'utf-8';
> s/([^-a-zA-Z0-9!*+\/])/sprintf("=%02X", ord($1))/eg;
> s/(.*)/=\?$encoding\?q\?$1\?=/;
> return $_;
> }This simplifies things for the function caller I think.
j.