From: Stefano Zacchiroli Date: Thu, 14 Feb 2013 08:37:13 +0000 (+0100) Subject: Re: notmuch-mutt: Use of uninitialized value. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=5008ad619f5e9349b14aa3644ffbf585d2c15ad7;p=notmuch-archives.git Re: notmuch-mutt: Use of uninitialized value. --- diff --git a/f6/79a12e1849d92cbf26d48b0f3c1b9270775e51 b/f6/79a12e1849d92cbf26d48b0f3c1b9270775e51 new file mode 100644 index 000000000..ea0b5b6c5 --- /dev/null +++ b/f6/79a12e1849d92cbf26d48b0f3c1b9270775e51 @@ -0,0 +1,153 @@ +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 02AE3431FBC + for ; Thu, 14 Feb 2013 00:37:19 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 0Gkb2LB44SyG for ; + Thu, 14 Feb 2013 00:37:16 -0800 (PST) +Received: from upsilon.hackadomia.org (upsilon.hackadomia.org + [91.121.245.170]) by olra.theworths.org (Postfix) with ESMTP id B04CD431FAF + for ; Thu, 14 Feb 2013 00:37:15 -0800 (PST) +Received: from usha.takhisis.invalid (unknown + [IPv6:2a01:e34:eecc:42f0:76e5:bff:fea7:56b8]) + by upsilon.hackadomia.org (Postfix) with ESMTPSA id 954487E00D; + Thu, 14 Feb 2013 09:37:13 +0100 (CET) +Received: by usha.takhisis.invalid (Postfix, from userid 1000) + id 0ED45680849; Thu, 14 Feb 2013 09:37:13 +0100 (CET) +Date: Thu, 14 Feb 2013 09:37:13 +0100 +From: Stefano Zacchiroli +To: Profpatsch +Subject: Re: notmuch-mutt: Use of uninitialized value. +Message-ID: <20130214083713.GA4123@upsilon.cc> +References: <20130212005801.GA8419@soarin> <20130213223535.GA3258@zaogao.lan> + <20130213233657.GA4489@soarin> +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <20130213233657.GA4489@soarin> +User-Agent: Mutt/1.5.21 (2010-09-15) +Cc: David Bremner , notmuch@notmuchmail.org +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: Thu, 14 Feb 2013 08:37:19 -0000 + + +--YZ5djTAD1cGYuMQK +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit + +On Thu, Feb 14, 2013 at 12:36:58AM +0100, Profpatsch wrote: +> On 13-02-13 02:35pm, Kevin J. McCarthy wrote: +> > A more likely idea is to check whether you have $pipe_decode set. +> +> BRILLIANT! +> So much for copying a basic rc from someone else. +> Of course, that was it and I’m officially an idiot. + +Neat, thanks Kevin for debugging the issue down to $pipe_decode (which +I've never used, mutt never stops to amaze me :-)). + +> And apparently Mail::Internet errors out if there is no Message-ID. +> (Which mentioned in the docs at CPAN…) +> +> Mystery solved. + +Right, but still a more graceful failure model would be nice. + +Please find attached a patch that in such cases should 1) give a +supposedly nice error message explaining what's going on and 2) empty +the results dir to avoid showing you unrelated results. It works for me. +But extra checking never hurts, in particular for the tag action, which +I don't personally use. + +I guess it would also be nice to actually disable $pipe_decode in the +relevant Mutt macros, but I'm not sure about to do that without +interfering with user desired configuration. Kevin: do you know if there +is a common Mutt trick to store the value of a variable before changing +it, and restoring it a posteriori? More isolation for this kind of +things in Mutt would definitely be welcome... + +Cheers. +-- +Stefano Zacchiroli . . . . . . . zack@upsilon.cc . . . . o . . . o . o +Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o +Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o . +« the first rule of tautology club is the first rule of tautology club » + +--YZ5djTAD1cGYuMQK +Content-Type: text/x-diff; charset=us-ascii +Content-Disposition: attachment; + filename="0001-notmuch-mutt-more-graceful-handling-of-missing-Messa.patch" + +>From b67ab95855ce7d279d8c0b3ddcbc20e679afc70b Mon Sep 17 00:00:00 2001 +From: Stefano Zacchiroli +Date: Thu, 14 Feb 2013 09:31:37 +0100 +Subject: [PATCH] notmuch-mutt: more graceful handling of missing Message-Id + errors + +in particular: +- the "thread" action would print an error and empty results dir +- the "tag action would print an error +--- + contrib/notmuch-mutt/notmuch-mutt | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt +index d14709d..bc97908 100755 +--- a/contrib/notmuch-mutt/notmuch-mutt ++++ b/contrib/notmuch-mutt/notmuch-mutt +@@ -121,7 +121,8 @@ sub prompt($$) { + + sub get_message_id() { + my $mail = Mail::Internet->new(\*STDIN); +- $mail->head->get("message-id") =~ /^<(.*)>$/; # get message-id ++ my $mid = $mail->head->get("message-id") or return undef; ++ $mid =~ /^<(.*)>$/; # get message-id value + return $1; + } + +@@ -142,6 +143,10 @@ sub thread_action($$@) { + my ($results_dir, $remove_dups, @params) = @_; + + my $mid = get_message_id(); ++ if (! defined $mid) { ++ empty_maildir($results_dir); ++ die "notmuch-mutt: cannot find Message-Id, abort.\n"; ++ } + my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid"); + my $tid = `$search_cmd`; # get thread id + chomp($tid); +@@ -151,6 +156,7 @@ sub thread_action($$@) { + + sub tag_action(@) { + my $mid = get_message_id(); ++ defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n"; + + system("notmuch tag " + . shell_quote(join(' ', @_)) +-- +1.7.10.4 + + +--YZ5djTAD1cGYuMQK--