Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 87 / 4aef3f47cd6e53f38dc3124eb7e0dae5f1c0f8
1 Return-Path: <Sebastian@SSpaeth.de>\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 0F612429E25\r
6         for <notmuch@notmuchmail.org>; Wed, 17 Aug 2011 05:49:05 -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.09\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.09 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         RCVD_IN_DNSWL_NONE=-0.0001, T_MIME_NO_TEXT=0.01] 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 Xc06EBasMO88 for <notmuch@notmuchmail.org>;\r
17         Wed, 17 Aug 2011 05:49:04 -0700 (PDT)\r
18 Received: from homiemail-a19.g.dreamhost.com (caiajhbdcagg.dreamhost.com\r
19         [208.97.132.66])\r
20         by olra.theworths.org (Postfix) with ESMTP id 66BA9431FD0\r
21         for <notmuch@notmuchmail.org>; Wed, 17 Aug 2011 05:49:04 -0700 (PDT)\r
22 Received: from homiemail-a19.g.dreamhost.com (localhost [127.0.0.1])\r
23         by homiemail-a19.g.dreamhost.com (Postfix) with ESMTP id D6903604079;\r
24         Wed, 17 Aug 2011 05:49:02 -0700 (PDT)\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=SSpaeth.de; h=from:to:subject\r
26         :in-reply-to:references:date:message-id:mime-version:\r
27         content-type; q=dns; s=sspaeth.de; b=gWLjVNFlq3CBG/GayJKgZbTF31L\r
28         YmfeUNCF2mRdzb01k5tCwhdHn6yNO6/w3jVytpzZT8ioseGRbHhCLv0cFZLknPGO\r
29         s9J37tPT3b8WmklkzYqUGZev9lfmAaeJvl9uxNVQbs8juMeMW5J+NYZorr5MBq5U\r
30         13dPvAs/b6SBp8Gw=\r
31 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=SSpaeth.de; h=from:to\r
32         :subject:in-reply-to:references:date:message-id:mime-version:\r
33         content-type; s=sspaeth.de; bh=4j0U88P/LuOykzupuAVPdp6r0Og=; b=T\r
34         MSv8yeYpencJq+pUD5A9XEo4ullcNuobqCb6KwdLqxfQ/QImtfzztBKW+qfDE70m\r
35         juziG0xYp4fbSrCpSsbakB9mEk63oDdxzXNoXS7OS09sOdSq1oxoWMrCoUznqpFn\r
36         AxU3JKdJcGuus6OEBFDBWlrRnW5XBoj0KtzL/Q8TbI=\r
37 Received: from spaetzbook.sspaeth.de (mtec-hg-docking-1-dhcp-21.ethz.ch\r
38         [129.132.133.21])\r
39         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
40         (No client certificate requested)\r
41         (Authenticated sender: fax@sspaeth.de)\r
42         by homiemail-a19.g.dreamhost.com (Postfix) with ESMTPSA id 55C1A60405D; \r
43         Wed, 17 Aug 2011 05:49:01 -0700 (PDT)\r
44 Received: by spaetzbook.sspaeth.de (sSMTP sendmail emulation);\r
45         Wed, 17 Aug 2011 14:48:58 +0200\r
46 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
47 To: Patrick Totzke <patricktotzke@googlemail.com>, notmuch@notmuchmail.org\r
48 Subject: Re: [PATCH 2/2] [python] fix unsafe utf-8 decodings\r
49 In-Reply-To: <1313530667-10648-1-git-send-email-patricktotzke@gmail.com>\r
50 References: <1313155408-17156-1-git-send-email-patricktotzke@gmail.com>\r
51         <1313530667-10648-1-git-send-email-patricktotzke@gmail.com>\r
52 User-Agent: Notmuch/0.7-19-gee4579a (http://notmuchmail.org) Emacs/23.2.1\r
53         (x86_64-pc-linux-gnu)\r
54 Date: Wed, 17 Aug 2011 14:48:58 +0200\r
55 Message-ID: <87wrecqk3p.fsf@SSpaeth.de>\r
56 MIME-Version: 1.0\r
57 Content-Type: multipart/signed; boundary="=-=-=";\r
58         micalg=pgp-sha1; protocol="application/pgp-signature"\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Wed, 17 Aug 2011 12:49:05 -0000\r
72 \r
73 --=-=-=\r
74 Content-Transfer-Encoding: quoted-printable\r
75 \r
76 On Tue, 16 Aug 2011 22:37:47 +0100, Patrick Totzke <patricktotzke@googlemai=\r
77 l.com> wrote:\r
78 > This prevents unsafe calls to decode for return\r
79 > value None in get_authors/get_subject\r
80 \r
81 Thanks for the heads up, I just pushed a modified version of this. Some\r
82 comments on the code below.\r
83 \r
84 Sebastian\r
85 \r
86 > -        tag =3D Tags._get(self._tags).decode('utf-8')\r
87 > +        tag =3D Tags._get(self._tags)\r
88 > +        if tag:\r
89 > +            tag =3D tag.decode('UTF-8')\r
90 \r
91 This was already safe as=20\r
92   if not nmlib.notmuch_tags_valid(self._tags):\r
93 was making sure that something useful will be returned.\r
94 \r
95 > -        return Thread._get_authors(self._thread).decode('UTF-8')\r
96 > +        authors =3D Thread._get_authors(self._thread)\r
97 > +        if authors:\r
98 > +            return authors.decode('UTF-8')\r
99 > +        return None\r
100 \r
101 > -        return Thread._get_subject(self._thread).decode('UTF-8')\r
102 > +        subject =3D Thread._get_subject(self._thread)\r
103 > +        if subject:\r
104 > +            return subject.decode('UTF-8')\r
105 > +        return None\r
106 \r
107 Modified this to say:\r
108 \r
109 foo =3D get_foo()\r
110 if foo is None:\r
111    return None\r
112 return foo.decode('UTF-8')\r
113 \r
114 Otherwise you would fall into a trap when e.g. the subject is empty and\r
115 a '' is returned. Your code would have returned "None". My version will\r
116 return ''.\r
117 \r
118 Thanks!\r
119 \r
120 --=-=-=\r
121 Content-Type: application/pgp-signature\r
122 \r
123 -----BEGIN PGP SIGNATURE-----\r
124 Version: GnuPG v1.4.11 (GNU/Linux)\r
125 \r
126 iEYEARECAAYFAk5LuLoACgkQVYX1jMgnoGIjrwCeJ9GkxYX2rYmboZLkkJntextG\r
127 2h0An2afzUU+q77USkgy6Cuw5xAZQLGr\r
128 =X7et\r
129 -----END PGP SIGNATURE-----\r
130 --=-=-=--\r