haraka-email-message
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -5,2 +5,8 @@ | ||
### [1.1.0] - 2022-09-14 | ||
- Do not insert banner in text attachments, #3 | ||
- chore(climate): configure code climate | ||
### [1.0.0] - 2022-06-24 | ||
@@ -13,1 +19,2 @@ | ||
[1.0.0]: https://github.com/haraka/email-message/releases/tag/1.0.0 | ||
[1.1.0]: https://github.com/haraka/email-message/releases/tag/1.1.0 |
39
index.js
@@ -350,3 +350,3 @@ 'use strict'; | ||
set_banner (banners) { | ||
this.add_filter((ct, enc, buf) => insert_banner(ct, enc, buf, banners)); | ||
this.add_filter((ct, enc, buf, cd) => insert_banner(ct, enc, buf, cd, banners)); | ||
} | ||
@@ -453,6 +453,6 @@ | ||
_empty_filter (ct, enc) { | ||
_empty_filter (ct, enc, cd) { | ||
let new_buf = Buffer.from(''); | ||
this.filters.forEach(filter => { | ||
new_buf = filter(ct, enc, new_buf) || new_buf; | ||
new_buf = filter(ct, enc, new_buf, cd) || new_buf; | ||
}); | ||
@@ -463,11 +463,15 @@ | ||
_emit_buf_fill () { | ||
if (this.buf_fill > 0) { | ||
// see below for why we create a new buffer here. | ||
const to_emit = Buffer.alloc(this.buf_fill); | ||
this.buf.copy(to_emit, 0, 0, this.buf_fill); | ||
this.attachment_stream.emit_data(to_emit); | ||
this.buf_fill = 0; | ||
} | ||
} | ||
force_end () { | ||
if (this.state === 'attachment') { | ||
if (this.buf_fill > 0) { | ||
// see below for why we create a new buffer here. | ||
const to_emit = Buffer.alloc(this.buf_fill); | ||
this.buf.copy(to_emit, 0, 0, this.buf_fill); | ||
this.attachment_stream.emit_data(to_emit); | ||
this.buf_fill = 0; | ||
} | ||
this._emit_buf_fill() | ||
this.attachment_stream.emit_end(true); | ||
@@ -483,9 +487,3 @@ } | ||
if (this.state === 'attachment') { | ||
if (this.buf_fill > 0) { | ||
// see below for why we create a new buffer here. | ||
const to_emit = Buffer.alloc(this.buf_fill); | ||
this.buf.copy(to_emit, 0, 0, this.buf_fill); | ||
this.attachment_stream.emit_data(to_emit); | ||
this.buf_fill = 0; | ||
} | ||
this._emit_buf_fill() | ||
this.attachment_stream.emit_end(); | ||
@@ -506,4 +504,5 @@ } | ||
const cd = this.header.get_decoded('content-disposition') || ''; | ||
if (!this.body_text_encoded_pos) { // nothing to decode | ||
return Buffer.concat([this._empty_filter(ct, enc) || Buffer.from(''), line]); | ||
return Buffer.concat([this._empty_filter(ct, enc, cd) || Buffer.from(''), line]); | ||
} | ||
@@ -749,4 +748,4 @@ if (this.bodytext.length !== 0) return line; // already decoded? | ||
function insert_banner (ct, enc, buf, banners) { | ||
if (!banners || !/^text\//i.test(ct)) { | ||
function insert_banner (ct, enc, buf, cd, banners) { | ||
if (!banners || !/^text\//i.test(ct) || /^attachment/i.test(cd)) { | ||
return; | ||
@@ -753,0 +752,0 @@ } |
{ | ||
"name": "haraka-email-message", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Haraka email message", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182689
1166