Skip to content

Commit cb89675

Browse files
authored
Merge pull request #28 from team-plain/empty-line
Support no empty line before quote header
2 parents d2ff137 + 2e2cc1b commit cb89675

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/Parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Parser {
128128
this._addFragment(fragment, fragments);
129129

130130
fragment = null;
131-
} else if (line.length === 0 && this._isQuoteHeader(lastLine)) {
131+
} else if (this._isQuoteHeader(lastLine)) {
132132
fragment.isQuoted = true;
133133
this._addFragment(fragment, fragments);
134134

test/ParserTest.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,17 @@ describe('the Parser', function () {
449449
assert.equal(/Was this/.test(fragments[1].getContent()), true, "Second fragment has wrong content");
450450
});
451451

452+
it('should parse an email where the quote header does not have a preceeding empty line', function () {
453+
var parser = new Parser();
454+
var fixture = util.getFixture("email_quote_header_without_new_line.txt");
455+
var email = parser.parse(fixture);
456+
var fragments = email.getFragments();
457+
458+
assert.equal(/^ Gran Via, 1, 28004, Madrid$/.test(email.getVisibleText()), true)
459+
assert.equal(/^ Gran Via, 1, 28004, Madrid/.test(fragments[0].getContent()), true, "First fragment has wrong content");
460+
assert.equal(/^ On Wednesday, 23 February 2022/.test(fragments[1].getContent()), true, "Second fragment has wrong content");
461+
});
462+
452463
it('should parse visible text that looks like a quote header (second)', function () {
453464
var parser = new Parser();
454465
var fixture = util.getFixture("email_20.txt");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Gran Via, 1, 28004, Madrid
3+
On Wednesday, 23 February 2022, 14:46:52 CET, Alicia
4+
5+
6+
Hello,
7+
May I get your postal address?
8+
Thanks

0 commit comments

Comments
 (0)