Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message
From: Michael Witten <hidden>
Date: 2016-06-15 22:46:37
On Sun, Apr 19, 2009 at 09:39, Michael Witten [off-list ref] wrote:
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.
I should add, though, that making the logic of the program clear is a good idea. In that sense, your approach makes sense. Since we 'own' quote_rfc2047(), I'd say we could take your approach, but rename the function to something like quote_rfc2047_if_necessary(). If quote_rfc2047() were part of a library, I think the only moral solution would be to insist that callers wrap it in another function named quote_rfc2047_if_necessary().