Re: use font-face instead of explicit colouring
[notmuch-archives.git] / c7 / 0dfb1d5ac8810f0668c020a701865567762cdc
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 4881B431FBF\r
6         for <notmuch@notmuchmail.org>; Wed, 16 Oct 2013 12:00:25 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id V068ZgqOylfY for <notmuch@notmuchmail.org>;\r
17         Wed, 16 Oct 2013 12:00:19 -0700 (PDT)\r
18 Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com\r
19  [74.125.83.52])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
20  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
21  768A6431FB6    for <notmuch@notmuchmail.org>; Wed, 16 Oct 2013 12:00:19 -0700\r
22  (PDT)\r
23 Received: by mail-ee0-f52.google.com with SMTP id c41so585987eek.11\r
24         for <notmuch@notmuchmail.org>; Wed, 16 Oct 2013 12:00:18 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
28         :references:in-reply-to:references;\r
29         bh=T53yQrOXHwZ4CKZLvq8kwsItjeBdoKIAWRNL8vQR/E4=;\r
30         b=RXH8dEL6w89EpAevLCAX4cyfHYhKmyawju5NPbrQpx6WkYth5/AeFUuChATje8Rip/\r
31         dYGwj0IhIMs0aJUvyEkauMkvmq8l30DmYtMoHZANRuYPJrh6oqWLh+JFYHzkEzeHJ4Nq\r
32         M8N8cCKjatSwY+dlVFisv8tGfbS7huHtcOP+RudVNMDBXoGrbFmnzeU0LkUrVi0KfrJW\r
33         tVAP3DoYMr21oz/BqLfp5mOMT3idRQ0l+Ay94LHq7CARNOnCLf4V2URf+lYvcvl6j6mh\r
34         DgX0F3JhYqIWgjI060FkqNyAljU5vIcnbdf7RpcQiMln/dpKIoJwZa8tGZqTS76gbfyr\r
35         Uewg==\r
36 X-Gm-Message-State:\r
37  ALoCoQm2Zzi1QUoXVCQRrCO2GsikqoWk+0it3yB80zRoCoFDILzOZTefIr1MkvG2e7zZWkLm/bQU\r
38 X-Received: by 10.15.61.73 with SMTP id h49mr6822542eex.57.1381950018350;\r
39         Wed, 16 Oct 2013 12:00:18 -0700 (PDT)\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
41         [88.195.111.91])\r
42         by mx.google.com with ESMTPSA id 48sm21233018eeq.4.1969.12.31.16.00.00\r
43         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
44         Wed, 16 Oct 2013 12:00:17 -0700 (PDT)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH 1/6] emacs: Sanitize authors and subjects in search and show\r
48 Date: Wed, 16 Oct 2013 22:00:08 +0300\r
49 Message-Id:\r
50  <8a1cf0f31f31b7f7be8a7458a5cbf0cc3ead6ac0.1381948853.git.jani@nikula.org>\r
51 X-Mailer: git-send-email 1.8.4.rc3\r
52 In-Reply-To: <cover.1381948853.git.jani@nikula.org>\r
53 References: <cover.1381948853.git.jani@nikula.org>\r
54 In-Reply-To: <cover.1381948853.git.jani@nikula.org>\r
55 References: <cover.1381948853.git.jani@nikula.org>\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: Wed, 16 Oct 2013 19:00:25 -0000\r
69 \r
70 From: Austin Clements <amdragon@MIT.EDU>\r
71 \r
72 Authors and subjects can contain embedded, encoded control characters\r
73 like "\n" and "\t" that mess up display.  Transform control characters\r
74 into spaces everywhere we display them in search and show.\r
75 ---\r
76  emacs/notmuch-lib.el  | 6 ++++++\r
77  emacs/notmuch-show.el | 7 ++++---\r
78  emacs/notmuch.el      | 6 ++++--\r
79  3 files changed, 14 insertions(+), 5 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
82 index 58f3313..6541282 100644\r
83 --- a/emacs/notmuch-lib.el\r
84 +++ b/emacs/notmuch-lib.el\r
85 @@ -243,6 +243,12 @@ depending on the value of `notmuch-poll-script'."\r
86         "[No Subject]"\r
87        subject)))\r
88  \r
89 +(defun notmuch-sanitize (str)\r
90 +  "Sanitize control character in STR.\r
91 +\r
92 +This includes newlines, tabs, and other funny characters."\r
93 +  (replace-regexp-in-string "[[:cntrl:]\x7f\u2028\u2029]+" " " str))\r
94 +\r
95  (defun notmuch-escape-boolean-term (term)\r
96    "Escape a boolean term for use in a query.\r
97  \r
98 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
99 index 7325792..fa11d98 100644\r
100 --- a/emacs/notmuch-show.el\r
101 +++ b/emacs/notmuch-show.el\r
102 @@ -407,7 +407,8 @@ unchanged ADDRESS if parsing fails."\r
103  message at DEPTH in the current thread."\r
104    (let ((start (point)))\r
105      (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
106 -           (notmuch-show-clean-address (plist-get headers :From))\r
107 +           (notmuch-sanitize\r
108 +            (notmuch-show-clean-address (plist-get headers :From)))\r
109             " ("\r
110             date\r
111             ") ("\r
112 @@ -417,7 +418,7 @@ message at DEPTH in the current thread."\r
113  \r
114  (defun notmuch-show-insert-header (header header-value)\r
115    "Insert a single header."\r
116 -  (insert header ": " header-value "\n"))\r
117 +  (insert header ": " (notmuch-sanitize header-value) "\n"))\r
118  \r
119  (defun notmuch-show-insert-headers (headers)\r
120    "Insert the headers of the current message."\r
121 @@ -1154,7 +1155,7 @@ function is used."\r
122        (jit-lock-register #'notmuch-show-buttonise-links)\r
123  \r
124        ;; Set the header line to the subject of the first message.\r
125 -      (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))\r
126 +      (setq header-line-format (notmuch-sanitize (notmuch-show-strip-re (notmuch-show-get-subject))))\r
127  \r
128        (run-hooks 'notmuch-show-hook))))\r
129  \r
130 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
131 index c47c6b5..44cd2fd 100644\r
132 --- a/emacs/notmuch.el\r
133 +++ b/emacs/notmuch.el\r
134 @@ -791,11 +791,13 @@ non-authors is found, assume that all of the authors match."\r
135                                         (plist-get result :total)))\r
136                         'face 'notmuch-search-count)))\r
137     ((string-equal field "subject")\r
138 -    (insert (propertize (format format-string (plist-get result :subject))\r
139 +    (insert (propertize (format format-string\r
140 +                               (notmuch-sanitize (plist-get result :subject)))\r
141                         'face 'notmuch-search-subject)))\r
142  \r
143     ((string-equal field "authors")\r
144 -    (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
145 +    (notmuch-search-insert-authors\r
146 +     format-string (notmuch-sanitize (plist-get result :authors))))\r
147  \r
148     ((string-equal field "tags")\r
149      (let ((tags (plist-get result :tags)))\r
150 -- \r
151 1.8.4.rc3\r
152 \r