git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] send-email: rfc2047-quote subject lines with non-ascii characters

From
Jeff King <peff@peff.net>
Date
Mar 30, 2008, 04:39 UTC
Message-ID
<20080330043920.GB18603@sigill.intra.peff.net>
In-Reply-To
<47EF0BC5.4040102@vilain.net>
On Sun, Mar 30, 2008 at 04:40:53PM +1300, Sam Vilain wrote:
Show 5 quoted lines
> > My point is that we don't _know_ what is happening in between the decode
> > and encode. Does that intermediate form have the information required to
> > convert back to the exact same bytes as the original form?
> No, it doesn't.  If you want that, save a copy of the string (it's a
> lazy copy anyway).

We do already save a copy. The question is that Robin is proposing decode/encode to check for validity. It was not clear to me that such a process would always return the exact same bytes even for valid utf-8.

But it seems like you are saying below that it is really just the "decode" part of that which is interesting:

Show 15 quoted lines
> utf8::decode works in-place; it is essentially checking that the string
> is valid, and if so, marking it as UTF8.
> 
>    my ($encoding);
>    if (utf8::decode($string)) {
>        if (utf8::is_utf($string)) {
>            $encoding = "UTF-8";
>        }
>        else {
>            $encoding = "US-ASCII";
>        }
>    }
>    else {
>        $encoding = "ISO8859-1"
>    }
OK, that was the magic invocation we were looking for. Thank you.
> For US-ASCII, you'll only have to encode if the string contains special
> characters (those below \037) or any "=" characters.

Ah, yeah. I think our tests are lacking in that they check for only [^[:ascii:]].

Show 6 quoted lines
> Anyway, I guess all this rubbish is why people use CPAN modules, so that
> they don't have to continually rediscover every single protocol quirk
> and reinvent the wheel.
> 
> ie, it would be much, much simpler to use MIME::Entity->build for all of
> this, and remove the duplication of code.

Yes, I actually made a similar comment recently. send-email could probably be shorter, easier to read, and have fewer bugs if it used one of the many mail-handling CPAN modules. I think it would pretty much involve scrapping the current send-email and starting fresh, though.

Thanks for your input.
-Peff
Previous: Sam VilainNext: Junio C Hamano
Message 19 of 32 in “[ANNOUNCE] GIT 1.5.5-rc2”
  1. Junio C HamanoMar 28, 2008
  2. Jeff KingMar 28, 2008
  3. Junio C HamanoMar 28, 2008
  4. Jeff KingMar 28, 2008
  5. Jeff KingMar 28, 2008
  6. 1/2 send-email: specify content-type of --compose bodyJeff King, Mar 28, 2008
  7. 2/2 send-email: rfc2047-quote subject lines with non-ascii charactersJeff King, Mar 28, 2008
  8. Robin RosenbergMar 29, 2008
  9. Jeff KingMar 29, 2008
  10. Robin RosenbergMar 29, 2008
  11. Jeff KingMar 29, 2008
  12. Robin RosenbergMar 29, 2008
  13. Jeff KingMar 29, 2008
  14. Robin RosenbergMar 29, 2008
  15. Jeff KingMar 29, 2008
  16. Robin RosenbergMar 29, 2008
  17. Jeff KingMar 29, 2008
  18. Sam VilainMar 30, 2008
  19. Jeff KingMar 30, 2008
  20. Junio C HamanoMar 30, 2008
  21. Robin RosenbergMar 29, 2008
  22. Jeff KingMar 29, 2008
  23. Robin RosenbergMar 29, 2008
  24. Jeff KingMar 29, 2008
  25. Robin RosenbergMar 29, 2008
  26. Jeff KingMar 29, 2008
  27. Robin RosenbergMar 29, 2008
  28. Jeff KingMar 29, 2008
  29. Sam VilainMar 30, 2008
  30. Jeff KingMar 30, 2008
  31. Junio C HamanoMay 21, 2008
  32. Jeff KingMay 21, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.