fix: cap filename tokens at the full 200-char limit, not 80

renderRaw (and the attachment-template renderer) sanitised each {token}
with sanitizePart's default 80-char cap, so a single long token such as
{subject} was truncated to 80 — well before the documented 200-char
filename limit, which was therefore unreachable per token. Introduce a
FILENAME_MAX_LEN (200) constant and use it for the per-token cap so the
overall limit governs. Adds tests.
This commit is contained in:
Stefan Hildebrandt
2026-06-21 19:28:57 +02:00
committed by Linus Rath
parent ddb596affc
commit 5306f7c548
2 changed files with 17 additions and 12 deletions
+4 -4
View File
@@ -41,11 +41,11 @@ describe('emailExportFilename', () => {
expect(emailExportFilename(makeEmail({}), '{unknown_token}')).toBe('email.eml');
});
it('CHARACTERISATION: per-token sanitise caps each value at 80 chars', () => {
// sanitizePart defaults to maxLen=80, applied per {token} during render —
// so a single long {subject} is truncated to 80 well before the 200 cap.
it('lets a single long token reach the 200-char filename cap', () => {
// Each {token} is now capped at FILENAME_MAX_LEN (200), so the overall
// filename limit governs instead of an earlier 80-char per-token cap.
const out = emailExportFilename(makeEmail({ subject: 'a'.repeat(300) }), '{subject}');
expect(out).toBe('a'.repeat(80) + '.eml');
expect(out).toBe('a'.repeat(200) + '.eml');
});
});