Skip to content

Commit a70fc5e

Browse files
authored
revert #624, alternative fix for encoding/decoding (#625)
related #623
1 parent afa4fdb commit a70fc5e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Formidable.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ class IncomingForm extends EventEmitter {
268268
// ? NOTE(@tunnckocore): filename is an empty string when a field?
269269
if (!part.mime) {
270270
let value = '';
271-
const decoder = new StringDecoder(this.options.encoding);
271+
const decoder = new StringDecoder(
272+
part.transferEncoding || this.options.encoding,
273+
);
272274

273275
part.on('data', (buffer) => {
274276
this._fieldsSize += buffer.length;

src/plugins/multipart.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function createInitMultipart(boundary) {
5454
part.filename = null;
5555
part.mime = null;
5656

57-
part.transferEncoding = 'binary';
57+
part.transferEncoding = this.options.encoding;
5858
part.transferBuffer = '';
5959

6060
headerField = '';
@@ -90,7 +90,8 @@ function createInitMultipart(boundary) {
9090
switch (part.transferEncoding) {
9191
case 'binary':
9292
case '7bit':
93-
case '8bit': {
93+
case '8bit':
94+
case 'utf-8': {
9495
const dataPropagation = (ctx) => {
9596
if (ctx.name === 'partData') {
9697
part.emit('data', ctx.buffer.slice(ctx.start, ctx.end));

0 commit comments

Comments
 (0)