[PATCH] show: don't use hex literals in JSON output
authorThomas Jost <schnouki@schnouki.net>
Sun, 22 Jan 2012 00:20:57 +0000 (01:20 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:54 +0000 (09:42 -0800)
ad/3b9d3d7244d0bf3a608d120190718c554020fc [new file with mode: 0644]

diff --git a/ad/3b9d3d7244d0bf3a608d120190718c554020fc b/ad/3b9d3d7244d0bf3a608d120190718c554020fc
new file mode 100644 (file)
index 0000000..009709b
--- /dev/null
@@ -0,0 +1,85 @@
+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 575B4429E40\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Jan 2012 16:21:12 -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 NQsWF3Hk1U2L for <notmuch@notmuchmail.org>;\r
+       Sat, 21 Jan 2012 16:21:11 -0800 (PST)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+       by olra.theworths.org (Postfix) with ESMTP id A4888431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Jan 2012 16:21:11 -0800 (PST)\r
+Received: from odin.local (nancy.schnouki.net [78.238.0.45])\r
+       by ks3536.kimsufi.com (Postfix) with ESMTPSA id F03076C000A;\r
+       Sun, 22 Jan 2012 01:20:37 +0100 (CET)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+       s=key-schnouki; t=1327191638;\r
+       bh=r8aR65PGjaE3fHwxICZRLch+ZTcFP6mh8RhTlQe8URQ=;\r
+       h=From:To:Subject:Date:Message-Id:In-Reply-To:References;\r
+       b=W/XTXNGoA6gDqVcaZhf0ELR+sWTX2Q5A6hCWbMx4LRTJOVzPMu+KPp6/Tsd9wh0ff\r
+       +edWaT/XG8u4fIy1G3zTEjCOKDeDl7wfeMG7qOwPfnqUgjVGwj31HEsVwp6OdYC9Ut\r
+       QT5nguPZL8pZ59cneV6MOUyfXUH4vde9mr4i+rbc=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] show: don't use hex literals in JSON output\r
+Date: Sun, 22 Jan 2012 01:20:57 +0100\r
+Message-Id: <1327191657-13095-1-git-send-email-schnouki@schnouki.net>\r
+X-Mailer: git-send-email 1.7.8.4\r
+In-Reply-To: <87ipk6wlvv.fsf@convex-new.cs.unb.ca>\r
+References: <87ipk6wlvv.fsf@convex-new.cs.unb.ca>\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: Sun, 22 Jan 2012 00:21:12 -0000\r
+\r
+JSON does not support hex literals (0x..) so numbers must be formatted\r
+as %d instead of %x.\r
+\r
+Currently, the possible values for the gmime error code are 1 (expired\r
+signature), 2 (no public key), 4 (expired key) and 8 (revoked key).\r
+The other possible value is 16 (unsupported algorithm) but obviously\r
+it is much more rare. If this happens, the current code will add\r
+'"errors": 10'. This is valid JSON (it looks like a decimal number)\r
+but it is incorrect (should be 16, not 10).\r
+\r
+Since this is just an issue in the JSON encoder, no changes are needed\r
+on the Emacs side (or in other UIs using the JSON output).\r
+---\r
+\r
+ notmuch-show.c |    2 +-\r
+ 1 files changed, 1 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 43ee211..7b40568 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -728,7 +728,7 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity)\r
+                printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid));\r
+        }\r
+        if (signer->errors != GMIME_SIGNER_ERROR_NONE) {\r
+-           printf (", \"errors\": %x", signer->errors);\r
++           printf (", \"errors\": %d", signer->errors);\r
+        }\r
\r
+        printf ("}");\r
+-- \r
+1.7.8.4\r
+\r