Re: emacs reply fills X clipboard with reply message body
[notmuch-archives.git] / e1 / 95e3069fa335a82490ba14fea54a1c7b815a0f
1 Return-Path: <jani@nikula.org>\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 C1AB6431FAF\r
6         for <notmuch@notmuchmail.org>; Fri, 11 Oct 2013 08:21:00 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 n7NoHgi3PpqB for <notmuch@notmuchmail.org>;\r
16         Fri, 11 Oct 2013 08:20:55 -0700 (PDT)\r
17 Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com\r
18  [74.125.83.46])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  20017431FB6    for <notmuch@notmuchmail.org>; Fri, 11 Oct 2013 08:20:55 -0700\r
21  (PDT)\r
22 Received: by mail-ee0-f46.google.com with SMTP id c13so1953395eek.19\r
23         for <notmuch@notmuchmail.org>; Fri, 11 Oct 2013 08:20:53 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=qUmfV6blunwVy76PQckxHxV83tFb4LrjVO52dIOiRlw=;\r
29         b=Gf+Cy1w2D3v0lCUZcXlHtmhIN3YRISKnnGnUacZCb7B3OMzO7ncEEafykeevWZBTt5\r
30         Iz9UP6G9mYpmpk39OBtsRmnRNBdskI+iqWZGNFy8oNPTDHX+Dmkoy0n/zhB7RQ7qUMoX\r
31         TfGVBwAIOYzCEQkAVxOdfXFNyE5sj0It/1qu2cCajmorAfa3ndkvtVAMDq9n0SECVeKC\r
32         Sopx7qkjlxTNM9NKea3CmmAKEiCCFF8PqpwQCGFzG7/kDv42ebRQP5fgUDjYjFX46mqa\r
33         qdBqXTQYOsg19rJWXnTpV9YXcIAiacOjS9l1n9yzqCscfxm8L3YMAXPzQGUwt8Srefo4\r
34         AyiQ==\r
35 X-Gm-Message-State:\r
36  ALoCoQk+tPMHKMCy0SfyFqBWqm6l/2qxCtIS5yMpy8EAJalvnFQ7wtb4jHV9COX/27fkGFYFsuCy\r
37 X-Received: by 10.14.87.135 with SMTP id y7mr3991954eee.57.1381504853738;\r
38         Fri, 11 Oct 2013 08:20:53 -0700 (PDT)\r
39 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
40         [88.195.111.91]) by mx.google.com with ESMTPSA id\r
41         z12sm115839243eev.6.1969.12.31.16.00.00\r
42         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
43         Fri, 11 Oct 2013 08:20:52 -0700 (PDT)\r
44 From: Jani Nikula <jani@nikula.org>\r
45 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
46 Subject: Re: [PATCH WIP] emacs: Sanitize authors and subjects in search and\r
47         show\r
48 In-Reply-To: <1381499619-14219-1-git-send-email-amdragon@mit.edu>\r
49 References: <1381499619-14219-1-git-send-email-amdragon@mit.edu>\r
50 User-Agent: Notmuch/0.16+96~g459c586 (http://notmuchmail.org) Emacs/24.3.1\r
51         (x86_64-pc-linux-gnu)\r
52 Date: Fri, 11 Oct 2013 18:20:51 +0300\r
53 Message-ID: <87d2nbzve4.fsf@nikula.org>\r
54 MIME-Version: 1.0\r
55 Content-Type: text/plain\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Fri, 11 Oct 2013 15:21:00 -0000\r
69 \r
70 On Fri, 11 Oct 2013, Austin Clements <amdragon@MIT.EDU> wrote:\r
71 > Authors and subjects can contain embedded, encoded control characters\r
72 > like "\n" and "\t" that mess up display.  Transform control characters\r
73 > into spaces everywhere we display them in search and show.\r
74 > ---\r
75 >\r
76 > This could obviously use some tests, but I thought I'd get it out\r
77 > there to see what people thought or if the behavior should be tweaked.\r
78 \r
79 I like it. Seems to work as advertized with some crappy Subject: lines\r
80 in my mail.\r
81 \r
82 BR,\r
83 Jani.\r
84 \r
85 \r
86 >\r
87 > Of course, I can't guarantee that this is all of the places we display\r
88 > untrusted header text.  I'm really not sure how to make that guarantee\r
89 > (suggestions welcome).\r
90 >\r
91 >  emacs/notmuch-lib.el  | 6 ++++++\r
92 >  emacs/notmuch-show.el | 7 ++++---\r
93 >  emacs/notmuch.el      | 6 ++++--\r
94 >  3 files changed, 14 insertions(+), 5 deletions(-)\r
95 >\r
96 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
97 > index 58f3313..6541282 100644\r
98 > --- a/emacs/notmuch-lib.el\r
99 > +++ b/emacs/notmuch-lib.el\r
100 > @@ -243,6 +243,12 @@ depending on the value of `notmuch-poll-script'."\r
101 >       "[No Subject]"\r
102 >        subject)))\r
103 >  \r
104 > +(defun notmuch-sanitize (str)\r
105 > +  "Sanitize control character in STR.\r
106 > +\r
107 > +This includes newlines, tabs, and other funny characters."\r
108 > +  (replace-regexp-in-string "[[:cntrl:]\x7f\u2028\u2029]+" " " str))\r
109 > +\r
110 >  (defun notmuch-escape-boolean-term (term)\r
111 >    "Escape a boolean term for use in a query.\r
112 >  \r
113 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
114 > index 7325792..fa11d98 100644\r
115 > --- a/emacs/notmuch-show.el\r
116 > +++ b/emacs/notmuch-show.el\r
117 > @@ -407,7 +407,8 @@ unchanged ADDRESS if parsing fails."\r
118 >  message at DEPTH in the current thread."\r
119 >    (let ((start (point)))\r
120 >      (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
121 > -         (notmuch-show-clean-address (plist-get headers :From))\r
122 > +         (notmuch-sanitize\r
123 > +          (notmuch-show-clean-address (plist-get headers :From)))\r
124 >           " ("\r
125 >           date\r
126 >           ") ("\r
127 > @@ -417,7 +418,7 @@ message at DEPTH in the current thread."\r
128 >  \r
129 >  (defun notmuch-show-insert-header (header header-value)\r
130 >    "Insert a single header."\r
131 > -  (insert header ": " header-value "\n"))\r
132 > +  (insert header ": " (notmuch-sanitize header-value) "\n"))\r
133 >  \r
134 >  (defun notmuch-show-insert-headers (headers)\r
135 >    "Insert the headers of the current message."\r
136 > @@ -1154,7 +1155,7 @@ function is used."\r
137 >        (jit-lock-register #'notmuch-show-buttonise-links)\r
138 >  \r
139 >        ;; Set the header line to the subject of the first message.\r
140 > -      (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))\r
141 > +      (setq header-line-format (notmuch-sanitize (notmuch-show-strip-re (notmuch-show-get-subject))))\r
142 >  \r
143 >        (run-hooks 'notmuch-show-hook))))\r
144 >  \r
145 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
146 > index c47c6b5..44cd2fd 100644\r
147 > --- a/emacs/notmuch.el\r
148 > +++ b/emacs/notmuch.el\r
149 > @@ -791,11 +791,13 @@ non-authors is found, assume that all of the authors match."\r
150 >                                       (plist-get result :total)))\r
151 >                       'face 'notmuch-search-count)))\r
152 >     ((string-equal field "subject")\r
153 > -    (insert (propertize (format format-string (plist-get result :subject))\r
154 > +    (insert (propertize (format format-string\r
155 > +                             (notmuch-sanitize (plist-get result :subject)))\r
156 >                       'face 'notmuch-search-subject)))\r
157 >  \r
158 >     ((string-equal field "authors")\r
159 > -    (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
160 > +    (notmuch-search-insert-authors\r
161 > +     format-string (notmuch-sanitize (plist-get result :authors))))\r
162 >  \r
163 >     ((string-equal field "tags")\r
164 >      (let ((tags (plist-get result :tags)))\r
165 > -- \r
166 > 1.8.4.rc3\r