Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 3c / d77137e8331a2fb4435388e1a619a6a545d3eb
1 Return-Path: <dme@dme.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 arlo.cworth.org (Postfix) with ESMTP id 415696DE035C\r
6  for <notmuch@notmuchmail.org>; Fri, 29 Apr 2016 23:52:02 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.231\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.231 tagged_above=-999 required=5 tests=[AWL=0.298, \r
12  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
13  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652,\r
14  UNPARSEABLE_RELAY=0.001] autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id zQeplO8f_yv9 for <notmuch@notmuchmail.org>;\r
18  Fri, 29 Apr 2016 23:51:54 -0700 (PDT)\r
19 Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com\r
20  [74.125.82.49]) by arlo.cworth.org (Postfix) with ESMTPS id 9AF426DE034D for\r
21  <notmuch@notmuchmail.org>; Fri, 29 Apr 2016 23:51:53 -0700 (PDT)\r
22 Received: by mail-wm0-f49.google.com with SMTP id n129so50703025wmn.1\r
23  for <notmuch@notmuchmail.org>; Fri, 29 Apr 2016 23:51:53 -0700 (PDT)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25  d=dme-org.20150623.gappssmtp.com; s=20150623;\r
26  h=from:to:subject:date:message-id:in-reply-to:references;\r
27  bh=Jn5Xj5FrI+RVuER5XWDYYAQrxqIEiH1Kkda3TGp4IW0=;\r
28  b=f8mvvXiwA3BWMxVq+9LXpIH2m9dkunv5rGmltLq5501uvmpoIvIbMYDJYQT6TPX/8Y\r
29  XpEHnEv/FHRg60cMLV/Q9Y6uL5gnCOX8kSh9In/Fz1dShhVD1Aaob7UG+73Udje6FByw\r
30  Z1j8c6KVGMOOMuFNvM/7DTd53rBUUnNgueTIIkQJEvsVwRKZ2cH+pCGLASsZl5YILNMG\r
31  Ebo8GaGvbe8MhmLi9Z9yOGWomFpFurCI7J1lW8uyXPl+swgzZ3UUeFw+YWVvzlrj8c5r\r
32  B32o3NMTaB3ate0Xe2n/NZirLefJ4Isq/DTWhtIioUy1lyNYw1a0ehxzcIn/pKg0w3W2\r
33  S9iw==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=Jn5Xj5FrI+RVuER5XWDYYAQrxqIEiH1Kkda3TGp4IW0=;\r
39  b=Fvy5D49GJeo+9N1qjHay4JgTdOpI6hyc6Xt7NraIoCuCXQUwMIZ/IX8jSHcueFP7qs\r
40  MBc/27CpOeQusM2NcxpPKNdpjnHvyvwdtnxpFraMWkVTQkpKr+CqzrjzT1BrsIcxLe5Z\r
41  UrxJR+6wqgc9Cr6Mne5jmBLE9aLQWXhRbuyu8HJx3Jo1kuezD7WHHLYmRImI54nbVl0+\r
42  JM92Kjw+5gr5sUrDCxtNQ7+0QcpqixwXvNVhCTVxTQ+6IyLbsASOMeW15E01PQz9Xl83\r
43  nI4ElvrUBmZkp5J6ti6qDCky08D8yBT8707Bf5tjdm2MYziqGxCiOTIGGlYVxFJVicCh\r
44  cyQQ==\r
45 X-Gm-Message-State:\r
46  AOPr4FWR/+GnChNZg2dKmU+UlfboOO/oOpXxoLQvwEg04TmcmtV0OYMEFsH2suXLssVMTQ==\r
47 X-Received: by 10.194.58.138 with SMTP id r10mr25459936wjq.153.1461999112294; \r
48  Fri, 29 Apr 2016 23:51:52 -0700 (PDT)\r
49 Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net.\r
50  [81.149.164.25])\r
51  by smtp.gmail.com with ESMTPSA id k139sm6774756wmg.24.2016.04.29.23.51.50\r
52  for <notmuch@notmuchmail.org>\r
53  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
54  Fri, 29 Apr 2016 23:51:51 -0700 (PDT)\r
55 Received: from localhost (disaster-area.hh.sledj.net [local])\r
56  by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 539b1410\r
57  for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 06:51:48 +0000 (UTC)\r
58 From: David Edmondson <dme@dme.org>\r
59 To: notmuch@notmuchmail.org\r
60 Subject: [PATCH v1 1/2] emacs: Observe the charset of MIME parts when reading\r
61  them.\r
62 Date: Sat, 30 Apr 2016 07:51:47 +0100\r
63 Message-Id: <1461999108-68582-2-git-send-email-dme@dme.org>\r
64 X-Mailer: git-send-email 2.7.1\r
65 In-Reply-To: <1461999108-68582-1-git-send-email-dme@dme.org>\r
66 References: <1461999108-68582-1-git-send-email-dme@dme.org>\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.20\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71  <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
78  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Sat, 30 Apr 2016 06:52:02 -0000\r
80 \r
81 `notmuch--get-bodypart-raw' previously assumed that all non-binary MIME\r
82 parts could be successfully read by assuming that they were UTF-8\r
83 encoded. This was demonstrated to be wrong, specifically when a part was\r
84 marked as ISO8859-1 and included accented characters (which were\r
85 incorrectly rendered as a result).\r
86 \r
87 Rather than assuming UTF-8, attempt to use the part's declared charset\r
88 when reading it, falling back to US-ASCII if the declared charset is\r
89 unknown, unsupported or invalid.\r
90 ---\r
91  emacs/notmuch-lib.el | 16 +++++++++++++++-\r
92  1 file changed, 15 insertions(+), 1 deletion(-)\r
93 \r
94 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
95 index 78978ee..f05ded6 100644\r
96 --- a/emacs/notmuch-lib.el\r
97 +++ b/emacs/notmuch-lib.el\r
98 @@ -23,6 +23,7 @@\r
99  \r
100  ;;; Code:\r
101  \r
102 +(require 'mm-util)\r
103  (require 'mm-view)\r
104  (require 'mm-decode)\r
105  (require 'cl)\r
106 @@ -572,7 +573,20 @@ the given type."\r
107                                    ,@(when process-crypto '("--decrypt"))\r
108                                    ,(notmuch-id-to-query (plist-get msg :id))))\r
109                            (coding-system-for-read\r
110 -                           (if binaryp 'no-conversion 'utf-8)))\r
111 +                           (if binaryp 'no-conversion\r
112 +                             (let ((coding-system (mm-charset-to-coding-system\r
113 +                                                   (plist-get part :content-charset))))\r
114 +                               ;; Sadly,\r
115 +                               ;; `mm-charset-to-coding-system' seems\r
116 +                               ;; to return things that are not\r
117 +                               ;; considered acceptable values for\r
118 +                               ;; `coding-system-for-read'.\r
119 +                               (if (coding-system-p coding-system)\r
120 +                                   coding-system\r
121 +                                 ;; RFC 2047 says that the default\r
122 +                                 ;; charset is US-ASCII. RFC6657\r
123 +                                 ;; complicates this somewhat.\r
124 +                                 'us-ascii)))))\r
125                        (apply #'call-process notmuch-command nil '(t nil) nil args)\r
126                        (buffer-string))))))\r
127      (when (and cache data)\r
128 -- \r
129 2.7.1\r
130 \r