From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 831E86DE022D for ; Sun, 30 Sep 2018 13:43:36 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.284 X-Spam-Level: X-Spam-Status: No, score=-0.284 tagged_above=-999 required=5 tests=[AWL=-0.282, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id swAkCSFeMZSB for ; Sun, 30 Sep 2018 13:43:35 -0700 (PDT) Received: from thyestes.tartarus.org (thyestes.tartarus.org [5.196.91.86]) by arlo.cworth.org (Postfix) with ESMTPS id 47B626DE01ED for ; Sun, 30 Sep 2018 13:43:35 -0700 (PDT) Received: from olly by thyestes.tartarus.org with local (Exim 4.89) (envelope-from ) id 1g6iYp-00024u-DX; Sun, 30 Sep 2018 21:43:27 +0100 Date: Sun, 30 Sep 2018 21:43:27 +0100 From: Olly Betts To: David Bremner Cc: James Aylett , notmuch@notmuchmail.org, xapian-discuss@lists.xapian.org Subject: Re: xapian parser bug? Message-ID: <20180930204327.a4dwzh6jdqcqvk2e@survex.com> Reply-To: Xapian Discussion Mail-Followup-To: David Bremner , James Aylett , notmuch@notmuchmail.org, xapian-discuss@lists.xapian.org References: <87a7o02bya.fsf@tethera.net> <20180930092039.7imrsrjyctpel2sp@survex.com> <87y3bj198a.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y3bj198a.fsf@tethera.net> User-Agent: NeoMutt/20170113 (1.7.2) X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Sun, 30 Sep 2018 20:43:36 -0000 On Sun, Sep 30, 2018 at 09:05:25AM -0300, David Bremner wrote: > if (str.find (' ') != std::string::npos) > query_str = '"' + str + '"'; > else > query_str = str; > > return parser.parse_query (query_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix); I wouldn't recommend trying to generate strings to feed to QueryParser like this code seems to be doing. QueryParser aims to parse input from humans not machines. As well as the case where str is an operation name, the code above looks like it will mishandle cases where str contains a tab or double quotes. There are likely other problem cases too. Cheers, Olly