Open
Bug 1067706
Opened 10 years ago
Updated 2 years ago
When body matching rules(Body condition) are defined for IMAP in both "Filter before Junk Classification" and "Filter after Junk Classification", and if auto-sync is enabled, filtering result of first new mail is different from user's expectatilon
Categories
(MailNews Core :: Filters, defect)
Tracking
(Not tracked)
NEW
People
(Reporter: World, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
+++ This bug was initially created as a clone of Bug #971401 +++
Spin-off of Bug 971401 Comment #34.
[BuildID] Thunderbird 31.1.1, Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Thunderbird/31.1.1
When body matching rules(Body condition) are defined for IMAP in both "Filter before Junk Classification" and "Filter after Junk Classification", and if auto-sync is enabled, filtering result of first new mail is different from user's expectatilon.
[Steps to reproduce]
Gmail IMAP is used(Move extension is supported), Tb's CONDSTORE support is disabled.
Max cached connections=2, for simple log.
IMAP log option : SET NSPR_LOG_MODULES=imap:5,ImapAutoSync:5,IMAPOFFLINE:5,MsgCopyService:5
6 small test mails.
mail-#1 = Subject: test-103, body = test-103 uid in Inbox = 698
mail-#2 = Subject: test-102, body = test-102 uid in Inbox = 699
mail-#3 = Subject: test-101, body = test-101 uid in Inbox = 700
mail-#4 = Subject: test-003, body = test-003 uid in Inbox = 701
mail-#5 = Subject: test-002, body = test-002 uid in Inbox = 702
mail-#6 = Subject: test-001, body = test-001 uid in Inbox = 703
Filter Rules :
Rule-1-1 : Before Junk Classification : If Subject begins with test-, Add tag_Before
Rule-1-2 : Before Junk Classification : If Subject begins with test-0, Add tag1
Rule-1-3 : Before Junk Classification : If Subject begins with test-0, Move to MoveTarget
Rule-2-1 : Before Junk Classification : If Subject begins with test-, Add tag_After
Rule-2-2 : After Junk Classification : If Body contains test-1, Add tag2
Rule-2-3 : After Junk Classification : If Subject begins with test-1, Add tag3
Rule-2-4 : After Junk Classification : If Subject begins with test-1, Move to MoveTarget
Auto-Sync is enabled, but Offline-Use=On is set for Inbox & MoveTarget only, to avoid excess log.
[Expected result]
After filter move,
mail-#1 = Subject: test-103, body = test-103 uid in Inbox = 698 : Tagged tag_Before, tag_After, tag4 moved by Rule-2-4
mail-#2 = Subject: test-102, body = test-102 uid in Inbox = 699 : Tagged tag_Before, tag_After, tag4 moved by Rule-2-4
mail-#3 = Subject: test-101, body = test-101 uid in Inbox = 700 : Tagged tag_Before, tag_After, tag4 moved by Rule-2-4
mail-#4 = Subject: test-003, body = test-003 uid in Inbox = 701 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
mail-#5 = Subject: test-002, body = test-002 uid in Inbox = 702 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
mail-#6 = Subject: test-001, body = test-001 uid in Inbox = 703 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
[Actual result]
After filter move. mail-#1 is different from mail-#2/mail-#3.
mail-#1 = Subject: test-103, body = test-103 uid in Inbox = 698 : Tagged tag_Before, tag_After, tag3, tag4 moved by Rule-2-3 & moved by Rule-2-4
mail-#2 = Subject: test-102, body = test-102 uid in Inbox = 699 : Tagged tag_Before, tag_After, tag4 moved by Rule-2-4
mail-#3 = Subject: test-101, body = test-101 uid in Inbox = 700 : Tagged tag_Before, tag_After, tag4 moved by Rule-2-4
mail-#4 = Subject: test-003, body = test-003 uid in Inbox = 701 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
mail-#5 = Subject: test-002, body = test-002 uid in Inbox = 702 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
mail-#6 = Subject: test-001, body = test-001 uid in Inbox = 703 : Tagged tag_Before, tag1, tag2, tag_After moved by Rule-1-3
This may be following.
(a) If Body Filter is used by "Filter before Junk Classification", auto-sync of all new mil is requested immediately, before actions by Biff, before filter execution.
uid 698:703 ( ... body.peek[])
(b) Filtering of first new mail imy be independent from filtering of other mails :
Do both "Filter before Junk Classification" and "Filter after Junk Classification" on first new mails.
Do both "Filter before Junk Classification" and "Filter after Junk Classification" on other new mails.
(c) If first new mail, mail data stream is held at top of IMAP data buffer.
So, at "Filter after Junk Classification" step of first new mails, message body data is accessible in buffer.
Then "Body contins" condition retuns true.
If second or more new mails, message body data is not accessible in buffer.
Because auto-sync is still in progress("uid xx:yy fetch body.peek[]" command is still in execution), "maail data in offline-store" is not availaable yet.
Reporter | ||
Comment 1•10 years ago
|
||
For ese of log reading, following is done.
Log lines, before first open of Inbox after restart of Tb, are removed.
Because Subject: header is sufficient to identify a mail in test, "mail data line except Subject: header" is removed from response to FETCH BODY.PEEK[].
Add New Line before/after each IMAP command for ease of reading.
Remove following log lines for data stream log.
": ReadNextLine [" ;
Remove following log lines in IMAP url scheduling.
": proposed url = " ;
": considering playing queued url:" ;
": creating protocol instance to play queued url:" ;
": failed creating protocol instance to play queued url:" ;
": playing queued url:" ;
":ProcessCurrentURL: entering" ;
By this removal, ": queuing url:" log for request, and :ProcessCurrentURL:" just before requested IMAP command execution, is seen.
After it, by ": queuing url:" log and "CopyMessages" log, "when IMAP command execution was requested by filter" is known.
Reporter | ||
Comment 2•10 years ago
|
||
Reporter | ||
Comment 3•10 years ago
|
||
Sorry, correct filter rules was :
Filter Rules :
Rule-1-1 : Before Junk Classification : If Subject begins with test-, Add tag_Before
Rule-1-2 : Before Junk Classification : If Body contains test-0, Add tag1
Rule-1-3 : Before Junk Classification : If Subject begins with test-0, Add tag2
Rule-1-4 : Before Junk Classification : If Subject begins with test-0, Move to MoveTarget
Rule-2-1 : After Junk Classification : If Subject begins with test-, Add tag_After
Rule-2-2 : After Junk Classification : If Body contains test-1, Add tag3
Rule-2-3 : After Junk Classification : If Body contains test-1, Move to MoveTarget
Rule-2-4 : After Junk Classification : If Subject begins with test-1, Add tag4
Rule-2-5 : After Junk Classification : If Subject begins with test-1, Move to MoveTarget
Reporter | ||
Comment 4•10 years ago
|
||
Reporter | ||
Comment 5•10 years ago
|
||
Mail data/tag of mails in MoveTarget folder after filter move.
Why test-103 is tagged as "tag4 tag3 tag_before tag_afterm" but test-102/test-101 is tagged as "tag4 tag_before tag_after"?
> imap.gmail.com:S-MoveTarget:SendData: 20 UID fetch 1:* (FLAGS)
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 1 FETCH (UID 80 FLAGS (tag4 tag3 tag_before tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 2 FETCH (UID 81 FLAGS (tag2 tag_before tag1 tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 3 FETCH (UID 82 FLAGS (tag2 tag_before tag1 tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 4 FETCH (UID 83 FLAGS (tag2 tag_before tag1 tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 5 FETCH (UID 84 FLAGS (tag4 tag_before tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 6 FETCH (UID 85 FLAGS (tag4 tag_before tag_after))
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: 20 OK Success
>
> imap.gmail.com:S-MoveTarget:SendData: 21 UID fetch 80:85 (UID X-GM-MSGID X-GM-THRID X-GM-LABELS RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)])
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 1 FETCH (X-GM-THRID 1252049043641350787 X-GM-MSGID 1252049043641350787 X-GM-LABELS () UID 80 RFC822.SIZE 230 FLAGS (tag4 tag3 tag_before tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-103
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-103>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket:
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 2 FETCH (X-GM-THRID 1252049043042262710 X-GM-MSGID 1252049043042262710 X-GM-LABELS () UID 81 RFC822.SIZE 230 FLAGS (tag2 tag_before tag1 tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-003
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-003>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 3 FETCH (X-GM-THRID 1252049043346626023 X-GM-MSGID 1252049043346626023 X-GM-LABELS () UID 82 RFC822.SIZE 230 FLAGS (tag2 tag_before tag1 tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-002
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-002>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket:
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 4 FETCH (X-GM-THRID 1252049043022963288 X-GM-MSGID 1252049043022963288 X-GM-LABELS () UID 83 RFC822.SIZE 230 FLAGS (tag2 tag_before tag1 tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-001
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-001>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket:
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 5 FETCH (X-GM-THRID 1252049043737800421 X-GM-MSGID 1252049043737800421 X-GM-LABELS () UID 84 RFC822.SIZE 230 FLAGS (tag4 tag_before tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-102
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-102>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket:
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: * 6 FETCH (X-GM-THRID 1252049042833990581 X-GM-MSGID 1252049042833990581 X-GM-LABELS () UID 85 RFC822.SIZE 230 FLAGS (tag4 tag_before tag_after) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To)] {197}
> imap.gmail.com:S-MoveTarget:STREAM:OPEN Size: 230: Begin Message Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Content-Type: text/plain
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Date: Sat, 03 Nov 2007 08:43:35 +0900
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: From: sender@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: To: receiver@sample.com
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Subject: test-101
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: Message-ID: <abcdefg.0123456789.xyzxyz@sample.com-test-101>
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket:
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: )
> imap.gmail.com:S-MoveTarget:STREAM:CLOSE: Normal Message End Download Stream
> imap.gmail.com:S-MoveTarget:CreateNewLineFromSocket: 21 OK Success
Reporter | ||
Comment 6•10 years ago
|
||
It looks for me;
(1) Because of "Body Filter in Before Junk Classification", uid fetch xx:yy body.peek[] is issued.
(2) upon End of Download of of first UID, filtering of first mail is executed. (subject=test-103)
- Before Junk Classification :
"add of tag_before" is queued
- "Junk Classification" is invoked
- After Junk Classification :
"add of tag_after" is queued
because of "First Mail", mail data is available at top of HTTP/IMAP buffer, "Body Filter" works on first mail.
"add of tag3" is queued "if Body contains ..."
"move to MoveTarget" is queued by "if Body contains ..."
Because "move" is requested, further filter rule is not applied.
(2) upon End of Download of of each UID except first mail, filtering of "Before Junk Classification" only is executed.
subject=test-102/subject=test-101
"add of tag_before" is queued
subject=test-003/subject=test-002/subject=test-001
"add of tag_before" is queued
"add of tag1" is queued (by Body filter)
"add of tag2" is queued (by "if Body contains ...")
"move to MoveTarget" is queued (by "if Body contains ...")
(3) fetch by "uid fetch xx:yy body.peek[]" command completes.
(4) "Junk Classification" is invoked
(5) "After Junk Classification" filtering is invoked for all new mails.
Note: "uid move nn MoveTarget command is not executed yet. These are merely queued.
subject=test-103/subject=test-102/subject=test-101
"add of tag_after" is queued
"if body contains" doen't work becuse of "Filter after Junk Classification" and mail is not stored in offline-store file.
"add of tag4" is queued by "if subject begins with"
"move to MoveTarget" is queued by "if subject begins with"
subject=test-003/subject=test-002/subject=test-001
"add of tag_before" is queued
Quick analysis :
(a) "Filtering of first mail upon download" is different from "filtering of other mails upon download".
(b) "Body filter upon download" works only in "Before Junk Classificaton" phase.
(c) "Move to folder in Before Junk Classification" won't stop further "After Junk Classification" filter aplication on the "Moved" mail.
This is because "Filter Before Junk Classification" and "Filter After Junk Classification" is independent,
"Filter Before Junk Classification" and "Filter After Junk Classification" is currently "per filter rule" attribute. This was introduced by change of(improvement of) "filter rule editing panel layout&design".
IIUC, in original filter design, "Filter Before Junk Classification" and "Filter After Junk Classification" was "messge filter wide" attribute.
Problem of "inconsistent filtering of first new mail due to both 'Body filter in Before Junk Classification' phase and 'Body filter in After Junk Classification' phase" is easily avoided, if "per filter rule Filter Before Junk Classification and Filter After Junk Classification attribute" is removed.
I don't believe "per filter rule Filter Before Junk Classification and Filter After Junk Classification attribute" is mandatory.
Reporter | ||
Updated•10 years ago
|
Attachment #8489771 -
Attachment mime type: text/plain → text/html
Reporter | ||
Comment 7•10 years ago
|
||
If Body is used as condition, or if action requires message body, filter application is executed after download of entire mail data.
Following is seen in IMAP log.
"uid xx:yy ( ... FETCH.BODY.PEEK[])" is issued first.
upon "Normal Message End Download Stream" of ech UID,
message filter for the UID is invoked, and IMAP request by filter action is queued.
> http://mxr.mozilla.org/comm-central/source/mailnews/imap/src/nsImapMailFolder.cpp#668
> 668 // If a body filter is enabled for an offline folder, delay the filter
> 669 // application until after message has been downloaded.
See also code where m_filterListRequiresBody is referred.
> http://mxr.mozilla.org/comm-central/search?string=m_filterListRequiresBody&find=&findi=&filter=^[^\0]*%24&hitlimit=&tree=comm-central
Reporter | ||
Comment 8•10 years ago
|
||
FYI.
Following is copy of Bug 1071754 Comment #1 posted by Kent James.
> "Filter after" uses entirely different code (the FilterAfterTheFact code) than "filter before",
> so it is common that bugs in one do not appear in the other.
> Although that was added to allow the bayes filter to be used, there are other special cases where works, such as this one.
> The bayes filter will not actually occur unless it is selected for the account. Not sure if RSS allows that or not.
Because FilterAfterTheFact code is used for "Filter after junk Classification", "Filter after junk Classification" is similar to "Run Filters on Folder".
Reporter | ||
Comment 9•10 years ago
|
||
Kent James (:rkent), is this bug intended behavior?
Flags: needinfo?(kent)
Comment 10•10 years ago
•
|
||
I spent a few minutes looking at this, and it was not clear what you are saying. Can't you simplify the issue so that you do not need 6 emails and 7 filter rules to demonstrate the problem? I am not sure what "filtering result of first new mail is different from user's expectation" means when looking at so much complexity.
Flags: needinfo?(kent)
Reporter | ||
Comment 11•10 years ago
|
||
(In reply to Kent James (:rkent) from comment #10)
> I spent a few minutes looking at this, and it was not clear what you are saying.
My questions :
Mails are fetched/downloaded in this order : test-103, test-102, test-101, test-003, test-002, test-001
Filter rule is simple : (note: "Move of test-0xx" is in "Before rule", "Move of test-1xx" is in "After rule")
First rule in "Before" == Add tag to mail of "Subject begins with test-" => applied to all mails
Filter before Junk Classification : If Body or Subject is "test-0xx", add tags, move
Filter after Junk Classification : If Body or Subject is "test-1xx", add tags, move
(Q-1) Taken actions should be same on { test-103, test-102, test-101 } and same on { test-003, test-002, test-001 }.
However, taken actions(add tags) on test-103(first mail) was different from taken actions on { test-102, test-101 }.
Why?
(It looks for me that "Body filter in After Classification" works on first mail only.)
(Q-2) Move order which is our normal expectation from filter rule definition :
(case-A)
1. By "Filter before Junk Classification", test-003, test-002, test-001 is moved
2. Then, by "Filter after Junk Classification", test-103, test-102, test-101 is moved
(case-B)
1. By "Filter before Junk Classification" and by "Filter after Junk Classification" on each new mail,
test-103, test-102, test-101, test-003, test-002, test-001 is moved in this order
However, actual "Move order" was :
test-103(==first mail,by after), test-003(before), test-002(before), test-001(before), test-102(after), test-101(after)
Why?
(It looks for me that "both Before rules and After rules" is applied to first mail, before application of "Before rules" to others.)
Updated•4 years ago
|
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•