-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gene Hightower
committed
Mar 29, 2024
1 parent
7ea5c48
commit 3502c31
Showing
2 changed files
with
41 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,127 +4,139 @@ describe("address-list", () => { | |
it("another single addr-spec", () => { | ||
const msg_text = Buffer.from(`From: "Write Brothers Inc." <[email protected]> (mailto:[email protected])\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("another valid addr-spec", () => { | ||
const msg_text = Buffer.from(`From: pete.(A nice \) chap)[email protected] (his host is silly)\r\n`); | ||
const msg_text = Buffer.from(`From: pete.(A nice \\) chap)[email protected] (his host is silly)\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("yet another valid addr-spec", () => { | ||
const msg_text = Buffer.from(`From: Pete(A nice \\) chap) <[email protected] (his host is silly)>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("another valid but ugly addr-spec", () => { | ||
const msg_text = Buffer.from(`From: (this *is* valid in RFC-5322 grammar and MUST be accepted and parsed by a conformant receiver.) just."not"[email protected]\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("very lax domain syntax", () => { | ||
const msg_text = Buffer.from(`From: foo@[Almost anything in here!]\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single addr-spec", () => { | ||
const msg_text = Buffer.from(`From: [email protected]\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("list of two addr-specs", () => { | ||
const msg_text = Buffer.from(`From: [email protected], [email protected]\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr", () => { | ||
const msg_text = Buffer.from(`From: Mr Foo <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, addr with quoted string", () => { | ||
const msg_text = Buffer.from(`From: Mr Foo <"mr foo"@example.com>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, addr with quoted string including angle brackets", () => { | ||
const msg_text = Buffer.from(`From: Mr Foo <"mr <foo-bar> foo"@example.com>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, addr with quoted string including backslash escape", () => { | ||
const msg_text = Buffer.from(`From: Mr Foo <"mr \\<foo-bar\\> foo"@example.com>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name with quoted-string", () => { | ||
const msg_text = Buffer.from(`From: "Mr. Foo" <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name with quoted-string", () => { | ||
const msg_text = Buffer.from(`From: "Foo, Mr" <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name with multiple quoted-strings", () => { | ||
const msg_text = Buffer.from(`From: "Mr." "Foo" <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name with .", () => { | ||
const msg_text = Buffer.from(`From: Mr. Foo <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name with ,", () => { | ||
const msg_text = Buffer.from(`From: One, Two <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("single name-addr, display-name as an address", () => { | ||
const msg_text = Buffer.from(`From: [email protected] <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("list of two name-addrs", () => { | ||
const msg_text = Buffer.from(`From: Joe Foo <[email protected]>, Bar Baz <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("list of two name-addrs with quoted-strings", () => { | ||
const msg_text = Buffer.from(`From: "Joe Foo" <[email protected]>, "Bar Baz" <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("quoted semicolon", () => { | ||
const msg_text = Buffer.from(`From: "one; two" <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("emtpy group", () => { | ||
const msg_text = Buffer.from(`From: Undisclosed:;\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("address group", () => { | ||
const msg_text = Buffer.from(`From: Disclosed:[email protected], [email protected];\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
it("adapted from Programming Internet Email", () => { | ||
const msg_text = Buffer.from(`To: Fred. (The Eliminator) <[email protected]>\r\n`); | ||
const msg_text = Buffer.from(`To: Fred . (The Eliminator) <[email protected]>\r\n`); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["to"][0].parsed); | ||
expect(msg.hdr_idx["to"][0].parsed !== null); | ||
}); | ||
|
||
// Not sure if this should be accepted. | ||
|
@@ -133,7 +145,7 @@ describe("address-list", () => { | |
`From: Foo <[email protected]>, Disclosed:[email protected], [email protected];,,,, Undisclosed:;\r\n` | ||
); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
|
||
// Not sure if this should be accepted. | ||
|
@@ -142,7 +154,7 @@ describe("address-list", () => { | |
`From: Test User <[email protected]>; Disclosed:[email protected], [email protected];,,,, Undisclosed:; [email protected];\r\n` | ||
); | ||
const msg = new Message(msg_text, MessageType.part); | ||
expect(msg.hdr_idx["from"][0].parsed); | ||
expect(msg.hdr_idx["from"][0].parsed !== null); | ||
}); | ||
}); | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ describe("test internal methods of Message class", () => { | |
const key = "received"; | ||
expect(msg.hdr_idx[key].length).toEqual(3); | ||
|
||
expect(msg.hdr_idx[key][0].parsed !== null); | ||
expect(msg.hdr_idx[key][1].parsed === null); // missing ';' before date | ||
expect(msg.hdr_idx[key][2].parsed !== null); | ||
|
||
msg._set_field(key, "for <[email protected]> ; Tue, 14 Aug 2012 17:34:56 -0500 (CST)"); | ||
msg.rewrite_headers(); | ||
|
||
|