Skip to content

Revert "check for undesirable quotes" - #299

Merged
mbrt merged 1 commit into
masterfrom
revert-260-check_quoted
Nov 2, 2022
Merged

mbrt merged 1 commit into
masterfrom
revert-260-check_quoted

Conversation

@mbrt

@mbrt mbrt commented Nov 2, 2022

Copy link
Copy Markdown
Owner

Reverts #260. See #66 (comment) and following for the discussion.

@mbrt mbrt added the kind/bug Something isn't working label Nov 2, 2022
@mbrt
mbrt merged commit 34412e9 into master Nov 2, 2022
@mbrt
mbrt deleted the revert-260-check_quoted branch November 2, 2022 13:45
gpechenik pushed a commit to gpechenik/gmailctl that referenced this pull request Oct 4, 2026
Gmail's search syntax has no way to escape a double quote, so a `"`
inside a value can only be valid as a pair around the whole value,
e.g. subject: '"hello world"'. Since bc6bb81 such values are passed
through unchanged, which fixed the example originally reported in mbrt#66.
Any other quote still produced a malformed query without warning:

    subject: 'say "hi" now'       ->  subject:"say "hi" now"
    subject: '"unbalanced start'  ->  subject:""unbalanced start"
    from: 'foo"bar'               ->  from:foo"bar
    has: '"exact phrase" other'   ->  ""exact phrase" other"

The pass-through check also only looked at the first and last
characters, so '"foo" OR "bar"' was treated as a single phrase. Nested
in a larger query it rendered as `subject:"foo" OR "bar"`, where "bar"
matches anywhere in the message, not only in the subject.

Make quote() accept a quote only when the value is exactly one quoted
phrase (the new filter.IsQuoted), and fail otherwise, with a note on
how to fix the config: remove the quotes (they are added automatically
when needed), or write raw Gmail syntax with `isEscaped: true` or
`query`, which are not checked.

A similar check was added in mbrt#260 and reverted in mbrt#299, because it
rejected every quote, including values wrapped as a whole, which users
rely on to force an exact match (e.g. to: '"foo+bar"'). Those keep
working: the new check only rejects values that already generated
broken queries. Configs containing them will now fail to apply until
fixed, which is intended, but worth a release note.

`gmailctl test` also treated the quotes around a phrase as literal
text, so rules like subject: '"hello world"' or to: '"foo+bar"' failed
their own tests, even though Gmail matches them. The evaluators now
strip those quotes before matching, using the same IsQuoted check.

Close mbrt#66.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant