unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: sanitization of args notmuch-cli in notmuch-emacs
Date: Mon, 03 Feb 2014 23:21:03 +0200	[thread overview]
Message-ID: <m2sirzj3k0.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <m2mwi8q6gh.fsf@guru.guru-group.fi>

On Mon, Feb 03 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:

> On Mon, Feb 03 2014, David Bremner <david@tethera.net> wrote:
>
>> Antoine Beaupré found a bug when notmuch-saved-searches contains 
>> newlines:
>>
>>         http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737496
>>
>> We can remove newlines with something like
>>           
>> (mapcar (lambda (arg) 
>> 	  (replace-regexp-in-string "\n" " " arg))
>> 	args)
>>
>> I wonder if we should do some other sanitization at the same time?
>
> It took a while to reproduce...
>
> $ echo $'foo\nbar' | notmuch count --batch 
> 665
> 631
>
> $ echo $'foo\n and bar' | notmuch count --batch
> 665
> A Xapian exception occurred: Syntax: <expression> AND <expression>
> Query string was:  and bar
> 0
>
> Therefore: (wrong-type-argument number-or-marker-p A)
>
> (I run non-byte-compiled version of (one-) notmuch.el and
> got this as a backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p A)
>   >(A 0)
>   (or (plist-get options :show-empty-searches) (> message-count 0))
> ...
>   (notmuch-remove-if-not
> ...
>   notmuch-hello-query-counts
> ...
>
> simpler way to reproduce:
>
> $ notmuch count 'and bar'
> A Xapian exception occurred: Syntax: <expression> AND <expression>
> Query string was: and bar
> 0
>
> Maybe the cli should be fixed ? (and/or make emacs MUA resilient to
> this kind of result)

of yes, the notmuch count --batch gets borken with \n -- from one
query there are 2 new count queries (and counts should be all wrong
from that point on (if there were no Xapian exception))

We would not have noticed this (as easily) if the Xapian execption did not
happen.

So, whether (or not?) some fixing is done in CLI the batch query emacs
sends needs to be sanitized exactly as David suggested above.

>
>>
>> d
>>
>
> Tomi

Tomi

  reply	other threads:[~2014-02-03 21:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-03 19:13 sanitization of args notmuch-cli in notmuch-emacs David Bremner
2014-02-03 20:36 ` Tomi Ollila
2014-02-03 21:21   ` Tomi Ollila [this message]
2014-02-08 14:25     ` [PATCH] emacs: remove newlines from input to notmuch count --batch David Bremner
2014-02-08 18:31       ` Tomi Ollila
2014-02-26  1:02       ` David Bremner
2014-02-04 13:10   ` sanitization of args notmuch-cli in notmuch-emacs David Bremner
2014-02-04 17:30     ` Mark Walters
2014-02-04 18:02     ` Tomi Ollila
2014-02-26  1:03 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2sirzj3k0.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).