dodo icon indicating copy to clipboard operation
dodo copied to clipboard

tags should be wrapped in double quotes in queries for tags with spaces

Open digitalsignalperson opened this issue 2 years ago • 1 comments

hey I'm using lieer which syncs tags to gmail labels so I'll have tags that looks like this "the tag/with stuff"

In dodo it lists all the tags but says there are zero messages for them.

Investigating a bit with notmuch, the following notmuch commands return nothing:

notmuch search tag:the tag/with stuff
notmuch search tag:"the tag/with stuff"

But the following does work:

notmuch search 'tag:"the tag/with stuff"'

I found that working combo here https://notmuchmail.org/pipermail/notmuch/2012/013532.html

so checking some of the calls dodo makes

stuff like this

r1 = subprocess.run(['notmuch', 'count', '--output=threads', '--', 'tag:'+t],

I think should be like

r1 = subprocess.run(['notmuch', 'count', '--output=threads', '--',  'tag:"%s"' % t],

just wrapping the tag in double quote (I think the extra single quotes are only needed in a shell)

I'll see if I can try fixing it

digitalsignalperson avatar Jun 09 '23 07:06 digitalsignalperson

oh darn, this breaks this concept of

A tag expression is a string consisting of one more statements of the form "+TAG" or "-TAG" to add or remove TAG, respectively, separated by whitespace

But it's valid for tags themselves to have whitespace

Looking at how this is used, we could just switch to a list instead of string

e.g. stuff like

  'a':       ('tag -inbox -unread', lambda p: p.tag_thread('-inbox -unread')),

can be

  'a':       ('tag -inbox -unread', lambda p: p.tag_thread(["-inbox", "-unread"])),

so then later there's no need to tag_expr.split() and break any tags containing spaces.

Hmm, there's probably some other bugs too if anyone has a tag containing "+" or "-". I know sometimes (in general) I put in the first character of a tag or label things like "!", "#", "-", "+" etc. to make those appear at the top of various sorted lists in a UI.

digitalsignalperson avatar Jun 09 '23 07:06 digitalsignalperson