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