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

Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message

From
Michael Witten <mfwitten@gmail.com>
Date
Apr 19, 2009, 14:39 UTC
Message-ID
<b4087cc50904190739u54a9a9d7p6f011ab2b47c1d05@mail.gmail.com>
In-Reply-To
<76718490904190713l3d6b5abcmf54544512de87413@mail.gmail.com>
On Sun, Apr 19, 2009 at 09:13, Jay Soffian <jaysoffian@gmail.com> wrote:
> 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.

Ah. However, there is still the question of whether the actual email headers are present to declare the right encoding. I don't know enough to comment on this, though; before this patch, this quoting was performed by code that new to right the correct "Content-Type" and "Content-Transfer-Encoding" headers. I suppose I'll have to read the RFC.

Show 14 quoted lines
>
>>        sub quote_rfc2047 {
>>                local $_ = shift;
>
> Add this:
>                 return $_ unless /[^[:ascii:]]/;
>
>>                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.

I'm morally opposed to this kind of thing. The caller should be required to test whether quote_rfc2047() is required, as it's not the job of quote_rfc2047 to validate. Suppose that quote_rfc2047 were actually part of a library of useful functions that my program imports. Perhaps my program knows that it must always quote some piece of text. Why, then, should my program be forced to waste the cycles to perform a useless test?

IMnsHO, verification should always be done by the caller with one exception: Interactive (human) input should always be verified, because humans represent an unreliable component in the system (in terms of digital systems, their asynchronous input must be synchronized with the clocked system). WIth this model, there's are fewer wasted cycles, because you can reuse verification across similar functions, and the code (particularly library code) is easier to understand.

Previous: Jay SoffianNext: Michael Witten
Message 17 of 50 in “Introduction to Decreasing send-email Entropy”
  1. 00/12 Introduction to Decreasing send-email EntropyMichael Witten, Apr 18, 2009
  2. 01/12 send-email: Cleanup the usage text and docs a bitMichael Witten, Apr 18, 2009
  3. 02/12 send-email: No longer repeatedly test if $smtp_server is a commandMichael Witten, Apr 18, 2009
  4. 03/12 send-email: Interpret --smtp-server "" as "use a default".Michael Witten, Apr 18, 2009
  5. 04/12 send-email: Verification for --smtp-server and --smpt-server-portMichael Witten, Apr 18, 2009
  6. 05/12 send-email: Improve redability and error-handling in send_message's sendmail codeMichael Witten, Apr 18, 2009
  7. 06/12 send-email: Cleanup and streamline the SMTP code in send_messageMichael Witten, Apr 18, 2009
  8. 07/12 send-email: Cleanup send_message 'log' codeMichael Witten, Apr 18, 2009
  9. 08/12 send-email: Move Subject sanitization from --compose code to send_messageMichael Witten, Apr 18, 2009
  10. 09/12 Docs: send-email: Reorganize the CONFIGURATION sectionMichael Witten, Apr 18, 2009
  11. 10/12 Docs: Embolden the CONFIGURATION referencesMichael Witten, Apr 18, 2009
  12. 11/12 Docs: send-email: Clarification of sendemail.<identity>Michael Witten, Apr 18, 2009
  13. 12/12 Docs: send-email: git send-email -> 'send-email'Michael Witten, Apr 18, 2009
  14. Jay SoffianApr 19, 2009
  15. Michael WittenApr 19, 2009
  16. Jay SoffianApr 19, 2009
  17. Michael WittenApr 19, 2009
  18. Michael WittenApr 19, 2009
  19. 08/12 send-email: Simplify --compose subject sanitationMichael Witten, Apr 19, 2009
  20. Jeff KingApr 21, 2009
  21. Michael WittenApr 21, 2009
  22. Junio C HamanoApr 20, 2009
  23. Michael WittenApr 20, 2009
  24. Junio C HamanoApr 20, 2009
  25. Jay SoffianApr 19, 2009
  26. Michael WittenApr 19, 2009
  27. Thomas AdamApr 19, 2009
  28. Michael WittenApr 19, 2009
  29. Junio C HamanoApr 19, 2009
  30. 05/12 send-email: Improve readability and error-handling in send_message's sendmail codeMichael Witten, Apr 19, 2009
  31. Jay SoffianApr 19, 2009
  32. Junio C HamanoApr 20, 2009
  33. Junio C HamanoApr 20, 2009
  34. Jeff KingApr 21, 2009
  35. Jeff KingApr 21, 2009
  36. 04/12 send-email: Verification for --smtp-server and --smpt-server-portMichael Witten, Apr 19, 2009
  37. Michael WittenApr 20, 2009
  38. Junio C HamanoApr 20, 2009
  39. Junio C HamanoApr 20, 2009
  40. Michael WittenApr 20, 2009
  41. Michael WittenApr 20, 2009
  42. Wesley J. LandakerApr 18, 2009
  43. Michael WittenApr 19, 2009
  44. 03/12 send-email: Interpret --smtp-server "" as "use a default".Michael Witten, Apr 19, 2009
  45. Junio C HamanoApr 20, 2009
  46. Michael WittenApr 20, 2009
  47. Junio C HamanoApr 20, 2009
  48. Michael WittenApr 20, 2009
  49. Junio C HamanoApr 20, 2009
  50. Subject: Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a commandMichael Witten, Apr 20, 2009

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.