Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell quote mail folder #218

Merged
merged 1 commit into from
Jan 20, 2019
Merged

Shell quote mail folder #218

merged 1 commit into from
Jan 20, 2019

Conversation

nicolasbock
Copy link
Contributor

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

@flokli
Copy link
Member

flokli commented Jan 18, 2019

@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"'

Copy link
Member

@flokli flokli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.query needs to be unquoted again (see previous comment)

Follow on to PR afewmail#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>
@nicolasbock
Copy link
Contributor Author

You are right, I missed that. It's fixed now.

@flokli flokli merged commit ba57311 into afewmail:master Jan 20, 2019
@flokli
Copy link
Member

flokli commented Jan 20, 2019

Thanks!

@nicolasbock nicolasbock deleted the quotes branch January 23, 2019 18:54
@nicolasbock
Copy link
Contributor Author

@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?

flokli added a commit to flokli/afew that referenced this pull request Jan 28, 2019
shlex.quote quoted with single quotes, which is not supported by
notmuch, so we have to quote and escape on our own

followup of afewmail#218 (comment)
flokli added a commit to flokli/afew that referenced this pull request Jan 28, 2019
shlex.quote quoted with single quotes, which is not supported by
notmuch, so we have to quote and escape on our own

followup of afewmail#218 (comment)
flokli added a commit to flokli/afew that referenced this pull request Jan 28, 2019
shlex.quote quoted with single quotes, which is not supported by
notmuch, so we have to quote and escape on our own

followup of afewmail#218 (comment)
flokli added a commit that referenced this pull request Jan 29, 2019
shlex.quote quoted with single quotes, which is not supported by
notmuch, so we have to quote and escape on our own

followup of #218 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants