Skip to content

Commit

Permalink
fix: fixed header line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Aug 21, 2024
1 parent 8af531b commit 30d645f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/models/emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const noReplyList = require('reserved-email-addresses-list/no-reply-list.json');
const nodemailer = require('nodemailer');
const pEvent = require('p-event');
const parseErr = require('parse-err');
const splitLines = require('split-lines');
const { Headers, Splitter, Joiner } = require('mailsplit');
const { Iconv } = require('iconv');
const { boolean } = require('boolean');
Expand Down Expand Up @@ -896,7 +895,10 @@ Emails.statics.queue = async function (
//
let from;

const lines = splitLines(headers.headers.toString('binary').trim());
const lines = headers.headers
.toString('binary')
.replace(/[\r\n]+$/, '')
.split(/\r?\n/);

for (const line of lines) {
const value = Buffer.from(line, 'binary').toString();
Expand Down
7 changes: 4 additions & 3 deletions helpers/get-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

const { Buffer } = require('node:buffer');

const splitLines = require('split-lines');

function getHeaders(headers) {
const _headers = {};
const lines = splitLines(headers.headers.toString('binary').trim());
const lines = headers.headers
.toString('binary')
.replace(/[\r\n]+$/, '')
.split(/\r?\n/);

//
// NOTE: we decode header values because
Expand Down

0 comments on commit 30d645f

Please sign in to comment.