Skip to content

Commit

Permalink
fix(imap): fixed string conversion to utf8 vs binary (closes #563) (#564
Browse files Browse the repository at this point in the history
)

* fix: fixed string conversion to uf8 vs binary (closes #563)

@andris9 this is a core bug that needs merged/fixed

details are in #563 

calling `compiled + "something"` will result in the buffer being converted to utf8 instead of binary, since the default buffer.toString is utf8

* fix: update imap composer for `compiled` types

Ref #564 and #563
  • Loading branch information
titanism committed Nov 30, 2023
1 parent 28bdc76 commit ee2708e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion imap-core/lib/imap-composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ class IMAPComposer extends Transform {
);
}

this.push(Buffer.from(compiled + '\r\n', 'binary'));
// <https://github.com/nodemailer/wildduck/issues/563>
// <https://github.com/nodemailer/wildduck/pull/564
if (typeof compiled === 'object') {
this.push(compiled);
this.push('\r\n');
} else if (typeof compiled === 'string') {
this.push(Buffer.from(compiled + '\r\n', 'binary'));
} else {
return done(new TypeError('"compiled" was not an object or string'));
}

done();
}

Expand Down

0 comments on commit ee2708e

Please sign in to comment.