Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / e0 / 00cb1b3b5b72b6c6dd1afe18f5ce20ba1c55c0
1 Return-Path: <league@contrapunctus.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id AE10A4196F0\r
6         for <notmuch@notmuchmail.org>; Fri, 28 May 2010 17:02:45 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.8\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.8 tagged_above=-999 required=5 tests=[BAYES_50=0.8]\r
12         autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id duDkWGmGuBXk for <notmuch@notmuchmail.org>;\r
16         Fri, 28 May 2010 17:02:35 -0700 (PDT)\r
17 X-Greylist: delayed 425 seconds by postgrey-1.32 at olra;\r
18         Fri, 28 May 2010 17:02:35 PDT\r
19 Received: from contrapunctus.net (contrapunctus.net [207.210.219.173])\r
20         by olra.theworths.org (Postfix) with ESMTP id 3153A431FC1\r
21         for <notmuch@notmuchmail.org>; Fri, 28 May 2010 17:02:35 -0700 (PDT)\r
22 Received: from ansible (unknown [96.239.99.202])\r
23         by contrapunctus.net (Postfix) with ESMTPSA id C614B9456\r
24         for <notmuch@notmuchmail.org>; Fri, 28 May 2010 19:55:27 -0400 (EDT)\r
25 From: Christopher League <league@contrapunctus.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [PATCH] quoting message-IDs for the shell\r
28 User-Agent: Notmuch/0.3.1-17-gc50524e (http://notmuchmail.org) Emacs/23.1.1\r
29         (i486-pc-linux-gnu)\r
30 Date: Fri, 28 May 2010 19:55:25 -0400\r
31 Message-ID: <87bpbztwcy.fsf@contrapunctus.net>\r
32 MIME-Version: 1.0\r
33 Content-Type: text/plain; charset=us-ascii\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.13\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38         <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 29 May 2010 00:02:45 -0000\r
47 \r
48 Hello all, I'm new to notmuch and having fun so far, although it has\r
49 some rough edges! I hope I can help polish some things, but please be\r
50 kind if I make any missteps as I begin to engage with this community!\r
51 \r
52 One thing I noticed is that sometimes the tag removal would fail and\r
53 messages would stay in my inbox after I had supposedly read and archived\r
54 them. It turned out that these messages had dollar signs in the message\r
55 IDs, causing them to be interpreted strangely by the shell!\r
56 \r
57 So below is a small patch that quotes message IDs when adding and\r
58 removing tags. I looked for a lower-level place to do more systematic\r
59 quoting, but I thought it would be more likely to break things. There is\r
60 code for quoting search-terms already.\r
61 \r
62 It occurs to me that since Message-IDs are external data, and we're\r
63 passing them to the shell, this could be an EXTREMELY dangerous security\r
64 hole.. but I won't be the one to craft an email to this list with some\r
65 ";rm -rf /;" component in the Message-ID...\r
66 \r
67 Best,\r
68 Chris\r
69 \r
70 ---\r
71  emacs/notmuch-show.el |    8 ++++++--\r
72  1 files changed, 6 insertions(+), 2 deletions(-)\r
73 \r
74 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
75 index 4b1baf3..a0a390f 100644\r
76 --- a/emacs/notmuch-show.el\r
77 +++ b/emacs/notmuch-show.el\r
78 @@ -721,6 +721,10 @@ All currently available key bindings:\r
79    "Return the message id of the current message."\r
80    (concat "id:" (notmuch-show-get-prop :id)))\r
81  \r
82 +(defun notmuch-show-quoted-message-id ()\r
83 +  "Return the message id of the current message, quoted for shell."\r
84 +  (shell-quote-argument (notmuch-show-get-message-id)))\r
85 +\r
86  ;; dme: Would it make sense to use a macro for many of these?\r
87  \r
88  (defun notmuch-show-get-filename ()\r
89 @@ -915,7 +919,7 @@ to stdout or stderr will appear in the *Messages* buffer."\r
90    (apply 'notmuch-call-notmuch-process\r
91          (append (cons "tag"\r
92                        (mapcar (lambda (s) (concat "+" s)) toadd))\r
93 -                (cons (notmuch-show-get-message-id) nil)))\r
94 +                (cons (notmuch-show-quoted-message-id) nil)))\r
95    (notmuch-show-set-tags (sort (union toadd (notmuch-show-get-tags) :test 'string=) 'string<)))\r
96  \r
97  (defun notmuch-show-remove-tag (&rest toremove)\r
98 @@ -929,7 +933,7 @@ to stdout or stderr will appear in the *Messages* buffer."\r
99           (apply 'notmuch-call-notmuch-process\r
100                  (append (cons "tag"\r
101                                (mapcar (lambda (s) (concat "-" s)) toremove))\r
102 -                        (cons (notmuch-show-get-message-id) nil)))\r
103 +                        (cons (notmuch-show-quoted-message-id) nil)))\r
104           (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))\r
105  \r
106  (defun notmuch-show-toggle-headers ()\r
107 -- \r
108 1.7.0.4\r
109 \r