Closed nicolasbock closed 5 years ago
@nicolasbock
self.query = 'folder:"{folder}" AND {subquery}'
need to be un-quoted again, as shlex.quote
does add enclosing quotes automatically when necessary:
>>> import shlex
>>> print(shlex.quote("foo"))
foo
>>> print(shlex.quote("foo\""))
'foo"'
You are right, I missed that. It's fixed now.
Thanks!
@flokli For some reason this is not working. With this PR the search query does not return anything.
Running afew --move-mail --verbose --verbose
fails to find matching emails:
DEBUG:root:query: folder:'xxx.gmail/[Gmail].Spam' AND NOT tag:spam
[NO RESULTS]
But running that query in the shell works:
$ notmuch search folder:'xxx.gmail/[Gmail].Spam' AND NOT tag:spam
[RESULTS]
Interestingly, when I revert the shlex.quote()
call in line 58 but change the query string in line 26 to
self.query = "folder:'{folder}' AND {subquery}"
I get the same result as with this PR, i.e. the query does not return anything. The failure is reproducible with single quotes but I don't understand why.
Do you have any suggestions?
Follow on to PR #216:
In cases where the folder name contains characters that should be quoted, use the
shlex.quote()
function to properly format the folder name.Signed-off-by: Nicolas Bock nicolasbock@gmail.com