summaryrefslogtreecommitdiff
path: root/ext/fetch/21_formdata.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fetch/21_formdata.js')
-rw-r--r--ext/fetch/21_formdata.js31
1 files changed, 15 insertions, 16 deletions
diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js
index 1f0f00088..d905ec7c4 100644
--- a/ext/fetch/21_formdata.js
+++ b/ext/fetch/21_formdata.js
@@ -448,25 +448,24 @@ class MultipartParser {
const prevByte = this.body[i - 1];
const isNewLine = byte === LF && prevByte === CR;
- if (state === 1 || state === 2 || state == 3) {
+ if (state === 1) {
headerText += StringFromCharCode(byte);
}
+
if (state === 0 && isNewLine) {
state = 1;
- } else if (state === 1 && isNewLine) {
- state = 2;
- const headersDone = this.body[i + 1] === CR &&
- this.body[i + 2] === LF;
-
- if (headersDone) {
- state = 3;
+ } else if (
+ state === 1
+ ) {
+ if (
+ isNewLine && this.body[i + 1] === CR &&
+ this.body[i + 2] === LF
+ ) {
+ // end of the headers section
+ state = 2;
+ fileStart = i + 3; // After \r\n
}
- } else if (state === 2 && isNewLine) {
- state = 3;
- } else if (state === 3 && isNewLine) {
- state = 4;
- fileStart = i + 1;
- } else if (state === 4) {
+ } else if (state === 2) {
if (this.boundaryChars[boundaryIndex] !== byte) {
boundaryIndex = 0;
} else {
@@ -487,7 +486,7 @@ class MultipartParser {
const latin1Filename = MapPrototypeGet(disposition, "filename");
const latin1Name = MapPrototypeGet(disposition, "name");
- state = 5;
+ state = 3;
// Reset
boundaryIndex = 0;
headerText = "";
@@ -510,7 +509,7 @@ class MultipartParser {
formData.append(name, core.decode(content));
}
}
- } else if (state === 5 && isNewLine) {
+ } else if (state === 3 && isNewLine) {
state = 1;
}
}