Repository navigation
Don't merge raw and quoted arguments when grouping functions - #468
Merged
Merged
Conversation
The simplifier merges leaves using the same function under the same
operator, e.g. or(from:a, from:b) becomes from:{a b}. When any of the
merged leaves was raw (`isEscaped: true`, or a downloaded filter), the
whole merged leaf was marked raw. Since quoting is skipped for all the
arguments of a raw leaf, the non-raw ones silently lost their quotes:
or: [
{ from: 'John Smith' },
{ from: '-(foo bar)', isEscaped: true },
]
produced `from:{John Smith -(foo bar)}`, which matches mail from "John"
or "Smith" instead of "John Smith".
Group raw and non-raw leaves separately instead, which now produces
`{from:"John Smith" from:-(foo bar)}`. When the `or` is at the top of a
rule it is split into one Gmail filter per leaf, as already happens for
different functions (e.g. or(from:a, to:b)). Leaves that are all raw,
or all non-raw, are grouped exactly as before.
A function can now produce two sibling leaves that differ only in the
raw flag. They come out of a map, in random order, and the tree sort
didn't tell them apart, so the order of the generated query (and with
it the diff against Gmail) would change between runs. Sort non-raw
leaves before raw ones to keep the output deterministic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #468 +/- ##
==========================================
+ Coverage 41.37% 41.86% +0.48%
==========================================
Files 54 54
Lines 3693 3698 +5
==========================================
+ Hits 1528 1548 +20
+ Misses 2063 2049 -14
+ Partials 102 101 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The simplifier merges leaves using the same function under the same operator, e.g. or(from:a, from:b) becomes from:{a b}. When any of the merged leaves was raw (
isEscaped: true, or a downloaded filter), the whole merged leaf was marked raw. Since quoting is skipped for all the arguments of a raw leaf, the non-raw ones silently lost their quotes:produced
from:{John Smith -(foo bar)}, which matches mail from "John" or "Smith" instead of "John Smith".Group raw and non-raw leaves separately instead, which now produces
{from:"John Smith" from:-(foo bar)}. When theoris at the top of a rule it is split into one Gmail filter per leaf, as already happens for different functions (e.g. or(from:a, to:b)). Leaves that are all raw, or all non-raw, are grouped exactly as before.A function can now produce two sibling leaves that differ only in the raw flag. They come out of a map, in random order, and the tree sort didn't tell them apart, so the order of the generated query (and with it the diff against Gmail) would change between runs. Sort non-raw leaves before raw ones to keep the output deterministic.