Skip to content

Commit 4a9792e

Browse files
committed
Fix potential parsing error when extracting the received time (#455)
1 parent 2af8af0 commit 4a9792e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ All notable changes to this project will be documented in this file.
1212
- Improved table views for sign rules and DKIM keys (#248, #305).
1313
E.g. it is now possible to delete multiple entries at once.
1414

15+
### Fixes
16+
17+
- Fixed potential parsing error when extracting the received time from the last Received header (#455).
18+
1519
### Other
1620

1721
- Updated default rules and favicons (#440, #444, #447, #457).

modules/msgParser.mjs.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Reads and parses a message.
33
*
4-
* Copyright (c) 2014-2023 Philippe Lieser
4+
* Copyright (c) 2014-2024 Philippe Lieser
55
*
66
* This software is licensed under the terms of the MIT License.
77
*
@@ -248,7 +248,9 @@ export default class MsgParser {
248248
log.warn("Could not find the date time in the Received header");
249249
return null;
250250
}
251-
const dateTimeStr = header.substring(dateTimeStart + 1);
251+
// In Thunderbird (but not Node.js) Date parsing will fail if newlines are before the actual date string.
252+
// We trim all surrounding whitespace to avoid this problem.
253+
const dateTimeStr = header.substring(dateTimeStart + 1).trim();
252254
const dateTime = new Date(dateTimeStr);
253255
if (dateTime.toString() === "Invalid Date") {
254256
log.warn("Could not parse the date time in the Received header");

test/unittest/SpecRunner.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<body>
1010
<div id="mocha"></div>
1111

12-
<script src="https://unpkg.com/chai/chai.js"></script>
13-
<script src="https://unpkg.com/mocha/mocha.js"></script>
14-
<script src="https://unpkg.com/sinon/pkg/sinon.js"></script>
12+
<script src="https://unpkg.com/chai@^4.3.10/chai.js"></script>
13+
<script src="https://unpkg.com/mocha@^10.0.4/mocha.js"></script>
14+
<script src="https://unpkg.com/sinon@^17.0.1/pkg/sinon.js"></script>
1515

1616
<script class="mocha-init">
1717
mocha.setup({ui: "bdd", globals: ["browser"]});

0 commit comments

Comments
 (0)