Re: [PATCH v4 1/3] show: don't use hex literals in JSON output
authorThomas Jost <schnouki@schnouki.net>
Fri, 20 Jan 2012 12:33:58 +0000 (13:33 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:49 +0000 (09:42 -0800)
6e/0f37ce002745875cd68aeecd82e7911b4092fa [new file with mode: 0644]

diff --git a/6e/0f37ce002745875cd68aeecd82e7911b4092fa b/6e/0f37ce002745875cd68aeecd82e7911b4092fa
new file mode 100644 (file)
index 0000000..7cbe91a
--- /dev/null
@@ -0,0 +1,118 @@
+Return-Path: <schnouki@schnouki.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id F4224431FAF\r
+       for <notmuch@notmuchmail.org>; Fri, 20 Jan 2012 04:34:03 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id LCyTPvkVEkTQ for <notmuch@notmuchmail.org>;\r
+       Fri, 20 Jan 2012 04:34:03 -0800 (PST)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+       by olra.theworths.org (Postfix) with ESMTP id 340F8431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 20 Jan 2012 04:34:03 -0800 (PST)\r
+Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])\r
+       by ks3536.kimsufi.com (Postfix) with ESMTPSA id 30B526C000A;\r
+       Fri, 20 Jan 2012 13:33:49 +0100 (CET)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+       s=key-schnouki; t=1327062829;\r
+       bh=PXpy8heLvAnTN2W3ypGlelWwgEK3cZQ5Wae3zRvu3BU=;\r
+       h=From:To:Subject:In-Reply-To:References:Date:Message-ID:\r
+       MIME-Version:Content-Type;\r
+       b=GrlqquWnFblyiQdMRskEYGu/F8rGkh2nzS5ICFp/cki7cUnYqYO5rcmRZjEIEBOBA\r
+       q+cTWTbMFU9pBSDbM+0xBJXlFX8e8A0mH0SVA9hz9Gugl54VMEr+EZYacG/sTfmgeF\r
+       sp6TDVNsrBg54eNtKbCnIp7AqViyDwUKdX+sDCr0=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 1/3] show: don't use hex literals in JSON output\r
+In-Reply-To: <87mx9id1wo.fsf@zancas.localnet>\r
+References: <87fwfaemuc.fsf@thor.loria.fr>\r
+       <1327052365-20012-1-git-send-email-schnouki@schnouki.net>\r
+       <87mx9id1wo.fsf@zancas.localnet>\r
+User-Agent: Notmuch/0.11+96~g5e187d3 (http://notmuchmail.org) Emacs/24.0.92.1\r
+       (x86_64-unknown-linux-gnu)\r
+Date: Fri, 20 Jan 2012 13:33:58 +0100\r
+Message-ID: <87d3aeeeo9.fsf@thor.loria.fr>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 20 Jan 2012 12:34:04 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On Fri, 20 Jan 2012 07:55:03 -0400, David Bremner <david@tethera.net> wrote:\r
+> On Fri, 20 Jan 2012 10:39:23 +0100, Thomas Jost <schnouki@schnouki.net> w=\r
+rote:\r
+> > JSON does not support hex literals (0x..) so numbers must be formatted =\r
+as %d\r
+> > instead of %x.\r
+> > ---\r
+> >  notmuch-show.c |    2 +-\r
+> >  1 files changed, 1 insertions(+), 1 deletions(-)\r
+>=20=20\r
+> Probably I'm just being lazy here, but can you explain why this change\r
+> does not require a corresponding change on the emacs side?\r
+\r
+Because Emacs already does the right thing. JSON numbers are supposed to\r
+be decimal only (see http://json.org/: digits are 0-9 only), but the\r
+current code could result in displaying a hexadecimal number instead\r
+("c" instead of "12"). This would then trigger an error in Emacs, or in\r
+any other correct JSON parser.\r
+\r
+However we are quite lucky: because of the possible values of the gmime\r
+error codes, such an error cannot happen.\r
+\r
+The most common gmime error codes are 1 (expired signature), 2 (no\r
+public key), 4 (expired key) and 8 (revoked key). The other possible\r
+value is 16 (unsupported algorithm) but obviously it is much more rare.\r
+If this happens, the current code will add '"errors": 10' (hex for\r
+16...). This is valid JSON (it looks like a decimal number) but it is\r
+incorrect (should be 16, not 10).\r
+\r
+With this patch, notmuch will correctly display '"errors": 16' if such a\r
+case happens.\r
+\r
+(By the way, this issue was spotted by Austin Clements in\r
+id:"20120117034714.GG16740@mit.edu", so he deserves the credits :))\r
+\r
+Regards,\r
+\r
+=2D-=20\r
+Thomas/Schnouki\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.11 (GNU/Linux)\r
+\r
+iQEcBAEBAgAGBQJPGV83AAoJEMPdciX+bh5IjeoIAJScqo3bRI0pJumtxrLA1OqB\r
+eb3iYDptZ4a8i4oK15mj+PLERvUKPZEW6aggSfrb3Y3FJXNQZ0ilPgvnIIzSvXrF\r
+i7VYk7xSjZhsudRgcGYPV1AQckhQ0DAQvOWmcgiCG15vGbHddKNfnBuFOfigSAq7\r
+qhO0AN0j/hYwMGH0srF29rbLrAfU5Sw1H8GGCqBe8aqsvILlLUv1L0wOj7y6UcgJ\r
+MtFjXwfhI39fWZMgRDnVekcNhCWwLeJPbzRLl/VqinhZvGOBn7J5jDZR9lznosTb\r
+UIZgGEV8vZ2YjmuROWT9sqbmBbNBH6FRghlwC5ftELNBiRrsW5nqp+PSalRTdSs=\r
+=Y8PS\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r