fix bug 655578, some custom header filters not working r=rkent

This commit is contained in:
David Bienvenu 2011-06-17 07:13:20 -07:00
Родитель fc3ee816c1
Коммит a2c5c8ea64
4 изменённых файлов: 147 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,82 @@
/*
* This file tests hdr parsing in the filter running context, specifically
* filters on custom headers.
* See https://bugzilla.mozilla.org/show_bug.cgi?id=655578
* for more info.
*
* Original author: David Bienvenu <bienvenu@mozilla.com>
*/
Components.utils.import("resource://gre/modules/Services.jsm");
load("../../../resources/logHelper.js");
load("../../../resources/mailTestUtils.js");
load("../../../resources/asyncTestUtils.js");
// IMAP pump
load("../../../resources/IMAPpump.js");
setupIMAPPump();
// Definition of tests
var tests = [
setupTest,
checkFilterResults,
endTest
]
function run_test()
{
// Create a test filter.
let filterList = gIMAPIncomingServer.getFilterList(null);
let filter = filterList.createFilter("test list-id");
let searchTerm = filter.createTerm();
searchTerm.attrib = Ci.nsMsgSearchAttrib.OtherHeader + 1;
searchTerm.op = Ci.nsMsgSearchOp.Contains;
let value = searchTerm.value;
value.attrib = Ci.nsMsgSearchAttrib.OtherHeader;
value.str = "gnupg-users.gnupg.org";
searchTerm.value = value;
searchTerm.booleanAnd = false;
searchTerm.arbitraryHeader = "List-Id";
filter.appendTerm(searchTerm);
filter.enabled = true;
// create a mark read action
let action = filter.createAction();
action.type = Ci.nsMsgFilterAction.MarkRead;
filter.appendAction(action);
filterList.insertFilterAt(0, filter);
async_run_tests(tests);
}
function setupTest() {
let file = do_get_file("../../../data/bugmail19");
let msgfileuri = Services.io.newFileURI(file).QueryInterface(Ci.nsIFileURL);
gIMAPMailbox.addMessage(new imapMessage(msgfileuri.spec,
gIMAPMailbox.uidnext++, []));
gIMAPInbox.updateFolderWithListener(null, asyncUrlListener);
yield false;
}
function checkFilterResults() {
let msgHdr = firstMsgHdr(gIMAPInbox);
do_check_true(msgHdr.isRead);
yield true;
}
// Cleanup
function endTest() {
teardownIMAPPump();
}
// get the first message header found in a folder
function firstMsgHdr(folder) {
let enumerator = folder.msgDatabase.EnumerateMessages();
if (enumerator.hasMoreElements())
return enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
return null;
}

Просмотреть файл

@ -10,6 +10,7 @@ tail = tail_imap.js
[test_dod.js]
[test_dontStatNoSelect.js]
[test_downloadOffline.js]
[test_filterCustomHeaders.js]
[test_filterNeedsBody.js]
[test_imapAttachmentSaves.js]
[test_imapAuthMethods.js]

Просмотреть файл

@ -1121,9 +1121,12 @@ SEARCH_NEWLINE:
if (*buf == '\r' || *buf == '\n')
{
char *last = buf - writeOffset;
char *saveBuf = buf;
if (*buf == '\r' && buf[1] == '\n')
buf++;
buf++;
// null terminate the left-over slop so we don't confuse msg filters.
*saveBuf = 0;
*last = 0; /* short-circuit const, and null-terminate header. */
}

Просмотреть файл

@ -0,0 +1,61 @@
From - Tue Oct 02 00:26:47 2007
X-UIDL: UID18345-1161858178
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Received: (from root@localhost)
by mrapp51.mozilla.org (8.13.8/8.13.8/Submit) id m47LtAEf007542;
Wed, 7 May 2008 14:55:10 -0700
Date: Wed, 7 May 2008 14:55:10 -0700
Message-Id: <200805072155.m47LtAEf007542@mrapp51.mozilla.org>
To: invalid@example.com
From: PrimaryEmail1@test.invalid
Cc: invalid@example.com
Subject: [Bug 655578] list-id filter broken
X-Bugzilla-Reason: None
X-Bugzilla-Type: newchanged
X-Bugzilla-Watch-Reason: QAcontact filters@mail.bugs
X-Bugzilla-Product: Core
X-Bugzilla-Component: MailNews: Filters
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: bugmail@example.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: --
X-Bugzilla-Assigned-To: nobody@mozilla.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Blocks
In-Reply-To: <bug-397009-254728@https.bugzilla.mozilla.org/>
References: <bug-397009-254728@https.bugzilla.mozilla.org/>
<4DC2493C.4060403@gmx.com>
<BANLkTin2w8LJxYGHV3_5NpFbsiBhrP96XA@mail.gmail.com>
<175221688.20110506234025@my_localhost>
<201105072315.25120@thufir.ingo-kloecker.de>
<BANLkTinacQCd+mZ7fL1THLK55X2+u9g5-w@mail.gmail.com>
<05433510.20110507224940@my_localhost>
<4DC5C015.7050800@sixdemonbag.org>
<BANLkTinv7NvPG9gE1Fha+X+6ZkHzdXdRdg@mail.gmail.com>
<BANLkTi=6zDTsYymc+bUTwPOM2AohJD2wfA@mail.gmail.com>
Reply-To: FOO <bar@foo.com>
List-Id: Help and discussion among users of GnuPG <gnupg-users.gnupg.org>
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
Do not reply to this email. You can add comments to this bug at
https://bugzilla.mozilla.org/show_bug.cgi?id=397009
Some User <bugmail@example.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |432710
--
Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the QA contact of the bug.