From 10418d1fe4b0d65fe020eafe3911feb5ad5e2bd6 Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Tue, 30 Apr 2024 09:08:39 +0200 Subject: [PATCH 01/30] fix: move util.isArray to Array.isArray (#564) --- lib/form_data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/form_data.js b/lib/form_data.js index 9c07e32c..82267ee1 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -60,7 +60,7 @@ FormData.prototype.append = function(field, value, options) { } // https://github.com/felixge/node-form-data/issues/38 - if (util.isArray(value)) { + if (Array.isArray(value)) { // Please convert your array into string // the way web server expects it this._error(new Error('Arrays are not supported.')); From 8bc1eb78b6b6f2d91574fe307544c47c795d0004 Mon Sep 17 00:00:00 2001 From: Jaikanth J <31009437+jaikanthjay46@users.noreply.github.com> Date: Tue, 19 Apr 2022 00:39:40 +0530 Subject: [PATCH 02/30] fix (npmignore): ignore temporary build files (#532) They increase the size of the package and don't add any value --- .npmignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.npmignore b/.npmignore index 31fcb79e..f6eab27b 100644 --- a/.npmignore +++ b/.npmignore @@ -7,3 +7,6 @@ sftp-config.json coverage/ node_modules/ test/ + +yarn.lock +README.md.bak From edb555a811f6f7e4668db4831551cf41c1de1cac Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Tue, 30 Apr 2024 09:08:39 +0200 Subject: [PATCH 03/30] fix: move util.isArray to Array.isArray (#564) --- lib/form_data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/form_data.js b/lib/form_data.js index cf836b0b..93164426 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -60,7 +60,7 @@ FormData.prototype.append = function(field, value, options) { } // https://github.com/felixge/node-form-data/issues/38 - if (util.isArray(value)) { + if (Array.isArray(value)) { // Please convert your array into string // the way web server expects it this._error(new Error('Arrays are not supported.')); From fed02210dbb2b44cbb8a798a508b3e79d0b9a511 Mon Sep 17 00:00:00 2001 From: Jaikanth J <31009437+jaikanthjay46@users.noreply.github.com> Date: Tue, 19 Apr 2022 00:39:40 +0530 Subject: [PATCH 04/30] fix (npmignore): ignore temporary build files (#532) They increase the size of the package and don't add any value --- .npmignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.npmignore b/.npmignore index 31fcb79e..f6eab27b 100644 --- a/.npmignore +++ b/.npmignore @@ -7,3 +7,6 @@ sftp-config.json coverage/ node_modules/ test/ + +yarn.lock +README.md.bak From 3a9d480232dbcbc07260ad84c3da4975d9a3ae9e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 19 Sep 2024 17:38:37 -0700 Subject: [PATCH 05/30] [eslint] clean up ignores --- .eslintignore | 2 -- .eslintrc | 7 ++++++- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 510731c1..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/* -index.d.ts diff --git a/.eslintrc b/.eslintrc index 63de4775..111719d6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,5 +39,10 @@ }, "env": { "node": true - } + }, + "ignorePatterns": [ + "node_modules/*", + "index.d.ts", + "coverage", + ] } diff --git a/package.json b/package.json index 7423f200..770ceea4 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "pretest": "rimraf coverage test/tmp", "test": "istanbul cover test/run.js", "posttest": "istanbul report lcov text", - "lint": "eslint lib/*.js test/*.js test/integration/*.js", + "lint": "eslint --ext=js,mjs .", "report": "istanbul report lcov text", "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", "ci-test": "npm run test && npm run browser && npm run report", From 3217b3ded8e382e51171d5c74c6038a21cc54440 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 19 Sep 2024 17:38:37 -0700 Subject: [PATCH 06/30] [eslint] clean up ignores --- .eslintignore | 2 -- .eslintrc | 7 ++++++- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 510731c1..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/* -index.d.ts diff --git a/.eslintrc b/.eslintrc index 63de4775..111719d6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,5 +39,10 @@ }, "env": { "node": true - } + }, + "ignorePatterns": [ + "node_modules/*", + "index.d.ts", + "coverage", + ] } diff --git a/package.json b/package.json index a2fcb88d..45939b5e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "pretest": "rimraf coverage test/tmp", "test": "istanbul cover test/run.js", "posttest": "istanbul report lcov text", - "lint": "eslint lib/*.js test/*.js test/integration/*.js", + "lint": "eslint --ext=js,mjs .", "report": "istanbul report lcov text", "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", "ci-test": "npm run test && npm run browser && npm run report", From 806eda77740e6e3c67c7815afb216f2e1f187ba5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Sep 2024 22:01:47 -0700 Subject: [PATCH 07/30] [Tests] migrate from travis to GHA --- .github/workflows/node-aught.yml | 14 +++++++++ .github/workflows/node-pretest.yml | 10 +++++++ .github/workflows/node-tens.yml | 14 +++++++++ .github/workflows/rebase.yml | 22 ++++++++++++++ .github/workflows/require-allow-edits.yml | 18 ++++++++++++ .travis.yml | 36 ----------------------- package.json | 11 ++++--- 7 files changed, 85 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/node-aught.yml create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node-tens.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/node-aught.yml b/.github/workflows/node-aught.yml new file mode 100644 index 00000000..10946efb --- /dev/null +++ b/.github/workflows/node-aught.yml @@ -0,0 +1,14 @@ +name: 'Tests: node.js < 10' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '>= 0.12 < 10' + type: minors + command: npm run ci-test diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 00000000..88d49f9b --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,10 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/pretest.yml@main diff --git a/.github/workflows/node-tens.yml b/.github/workflows/node-tens.yml new file mode 100644 index 00000000..f39714e0 --- /dev/null +++ b/.github/workflows/node-tens.yml @@ -0,0 +1,14 @@ +name: 'Tests: node.js >= 10' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '>= 10' + type: minors + command: npm run ci-test diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 00000000..18181913 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,22 @@ +name: Automatic Rebase + +on: [pull_request_target] + +permissions: + contents: read + +jobs: + _: + permissions: + contents: write # for ljharb/rebase to push code to rebase + pull-requests: read # for ljharb/rebase to get info about PR + + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 00000000..a685b8ac --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,18 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +permissions: + contents: read + +jobs: + _: + permissions: + pull-requests: read # for ljharb/require-allow-edits to check 'allow edits' on PR + + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7cf751a3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -sudo: false - -language: node_js -node_js: - - "4" - - "6" - - "8" - - "10" - - "12" - -os: -- osx -- linux -- windows - -install: - - travis_retry npm install - -script: - - uname -a - - node --version - - npm --version - - if [ "$TRAVIS_OS_NAME" != "windows" ]; then npm run ci-lint; fi - - if [ "$TRAVIS_OS_NAME" = "windows" ]; then npm run test; else npm run ci-test; fi - - npm run check - -after_success: - - "cat coverage/lcov.info | ./node_modules/.bin/coveralls" - -notifications: - webhooks: - urls: - - "https://webhooks.gitter.im/e/3569d7edff0d38f93cd7" - on_success: always - on_failure: always - on_start: false diff --git a/package.json b/package.json index 770ceea4..e9ca1137 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,16 @@ "browser": "./lib/browser", "typings": "./index.d.ts", "scripts": { - "pretest": "rimraf coverage test/tmp", - "test": "istanbul cover test/run.js", - "posttest": "istanbul report lcov text", + "pretest": "npm run lint", + "pretests-only": "rimraf coverage test/tmp", + "tests-only": "istanbul cover test/run.js", + "posttests-only": "istanbul report lcov text", + "test": "npm run tests-only", + "posttest": "npx npm@'>=10.2' audit --production", "lint": "eslint --ext=js,mjs .", "report": "istanbul report lcov text", "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", - "ci-test": "npm run test && npm run browser && npm run report", + "ci-test": "npm run tests-only && npm run browser && npm run report", "predebug": "rimraf coverage test/tmp", "debug": "verbose=1 ./test/run.js", "browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage", From 8fdb3bc6b5d001f8909a9fca391d1d1d97ef1d79 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Sep 2024 22:01:47 -0700 Subject: [PATCH 08/30] [Tests] migrate from travis to GHA --- .github/workflows/node-aught.yml | 14 +++++++++ .github/workflows/node-pretest.yml | 10 +++++++ .github/workflows/node-tens.yml | 14 +++++++++ .github/workflows/rebase.yml | 22 ++++++++++++++ .github/workflows/require-allow-edits.yml | 18 ++++++++++++ .travis.yml | 35 ----------------------- package.json | 11 ++++--- 7 files changed, 85 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/node-aught.yml create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node-tens.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/node-aught.yml b/.github/workflows/node-aught.yml new file mode 100644 index 00000000..d0f17ab9 --- /dev/null +++ b/.github/workflows/node-aught.yml @@ -0,0 +1,14 @@ +name: 'Tests: node.js < 10' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '>= 6 < 10' + type: minors + command: npm run ci-test diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 00000000..88d49f9b --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,10 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/pretest.yml@main diff --git a/.github/workflows/node-tens.yml b/.github/workflows/node-tens.yml new file mode 100644 index 00000000..f39714e0 --- /dev/null +++ b/.github/workflows/node-tens.yml @@ -0,0 +1,14 @@ +name: 'Tests: node.js >= 10' + +on: [pull_request, push] + +permissions: + contents: read + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '>= 10' + type: minors + command: npm run ci-test diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 00000000..18181913 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,22 @@ +name: Automatic Rebase + +on: [pull_request_target] + +permissions: + contents: read + +jobs: + _: + permissions: + contents: write # for ljharb/rebase to push code to rebase + pull-requests: read # for ljharb/rebase to get info about PR + + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 00000000..a685b8ac --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,18 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +permissions: + contents: read + +jobs: + _: + permissions: + pull-requests: read # for ljharb/require-allow-edits to check 'allow edits' on PR + + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f22a5d90..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -sudo: false - -language: node_js -node_js: - - "6" - - "8" - - "10" - - "12" - -os: -- osx -- linux -- windows - -install: - - travis_retry npm install - -script: - - uname -a - - node --version - - npm --version - - if [ "$TRAVIS_OS_NAME" != "windows" ]; then npm run ci-lint; fi - - if [ "$TRAVIS_OS_NAME" = "windows" ]; then npm run test; else npm run ci-test; fi - - npm run check - -after_success: - - "cat coverage/lcov.info | ./node_modules/.bin/coveralls" - -notifications: - webhooks: - urls: - - "https://webhooks.gitter.im/e/3569d7edff0d38f93cd7" - on_success: always - on_failure: always - on_start: false diff --git a/package.json b/package.json index 45939b5e..218a4246 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,16 @@ "browser": "./lib/browser", "typings": "./index.d.ts", "scripts": { - "pretest": "rimraf coverage test/tmp", - "test": "istanbul cover test/run.js", - "posttest": "istanbul report lcov text", + "pretest": "npm run lint", + "pretests-only": "rimraf coverage test/tmp", + "tests-only": "istanbul cover test/run.js", + "posttests-only": "istanbul report lcov text", + "test": "npm run tests-only", + "posttest": "npx npm@'>=10.2' audit --production", "lint": "eslint --ext=js,mjs .", "report": "istanbul report lcov text", "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", - "ci-test": "npm run test && npm run browser && npm run report", + "ci-test": "npm run tests-only && npm run browser && npm run report", "predebug": "rimraf coverage test/tmp", "debug": "verbose=1 ./test/run.js", "browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage", From 3fc1a9b62ddf1fe77a2bd6bd3476e4c0a9e01a88 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 21 Sep 2024 15:22:46 -0700 Subject: [PATCH 09/30] [Dev Deps] downgrade `cross-spawn` see 19add50a --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9ca1137..fa31a0ce 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "browserify": "^13.1.1", "browserify-istanbul": "^2.0.0", "coveralls": "^3.0.4", - "cross-spawn": "^6.0.5", + "cross-spawn": "^4.0.2", "eslint": "^6.0.1", "fake": "^0.2.2", "far": "^0.0.7", From c499f76f1faac1ddbf210c45217038e4c1e02337 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 21 Sep 2024 15:33:09 -0700 Subject: [PATCH 10/30] [Fix] `Buffer.from` and `Buffer.alloc` require node 4+ Introduced by #419 --- lib/form_data.js | 3 ++- package.json | 3 ++- test/integration/test-get-buffer.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/form_data.js b/lib/form_data.js index 82267ee1..b1b20c90 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -8,6 +8,7 @@ var fs = require('fs'); var mime = require('mime-types'); var asynckit = require('asynckit'); var populate = require('./populate.js'); +var Buffer = require('safe-buffer').Buffer; // eslint-disable-line no-shadow // Public API module.exports = FormData; @@ -314,7 +315,7 @@ FormData.prototype.getBoundary = function() { }; FormData.prototype.getBuffer = function() { - var dataBuffer = new Buffer.alloc( 0 ); + var dataBuffer = new Buffer.alloc(0); var boundary = this.getBoundary(); // Create the form content. Add Line breaks to the end of data. diff --git a/package.json b/package.json index fa31a0ce..4e62d4ff 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" + "mime-types": "^2.1.12", + "safe-buffer": "^5.2.1" }, "devDependencies": { "@types/node": "^12.0.10", diff --git a/test/integration/test-get-buffer.js b/test/integration/test-get-buffer.js index cca6fa0a..eb076341 100644 --- a/test/integration/test-get-buffer.js +++ b/test/integration/test-get-buffer.js @@ -1,3 +1,7 @@ +'use strict'; + +var Buffer = require('safe-buffer').Buffer; // eslint-disable-line no-shadow + var common = require('../common'); var assert = common.assert; From 7020dd4c1260370abc40e86e3dfe49c5d576fbda Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 10 Oct 2024 12:46:01 +0900 Subject: [PATCH 11/30] Bumped version 2.5.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e62d4ff..4a7cae77 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "form-data", "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", - "version": "2.5.1", + "version": "2.5.2", "repository": { "type": "git", "url": "git://github.com/form-data/form-data.git" From f06b0d85d10bc942b3bf586b01ace6e874ac61b3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 10 Oct 2024 12:48:34 +0900 Subject: [PATCH 12/30] v3.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 218a4246..9ced4589 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "form-data", "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", - "version": "3.0.1", + "version": "3.0.2", "repository": { "type": "git", "url": "git://github.com/form-data/form-data.git" From e997b908b4e0337d8c2794561569341122be38dc Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 13 Feb 2025 19:00:00 +0100 Subject: [PATCH 13/30] =?UTF-8?q?[Fix]=20set=C2=A0`Symbol.toStringTag`=20w?= =?UTF-8?q?hen=C2=A0available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #396 --- lib/form_data.js | 2 ++ package.json | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/form_data.js b/lib/form_data.js index a96f0fa5..85f0a7ec 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -8,6 +8,7 @@ var fs = require('fs'); var Stream = require('stream').Stream; var mime = require('mime-types'); var asynckit = require('asynckit'); +var setToStringTag = require('es-set-tostringtag'); var populate = require('./populate.js'); // Public API @@ -499,3 +500,4 @@ FormData.prototype._error = function(err) { FormData.prototype.toString = function () { return '[object FormData]'; }; +setToStringTag(FormData, 'FormData'); diff --git a/package.json b/package.json index 9bd12c95..4666b9a2 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,12 @@ "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" }, "devDependencies": { + "@types/combined-stream": "^1.0.6", + "@types/mime-types": "^2.1.4", "@types/node": "^12.0.10", "browserify": "^13.1.1", "browserify-istanbul": "^2.0.0", From fb66cb740e29fb170eee947d4be6fdf82d6659af Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 11:03:14 -0800 Subject: [PATCH 14/30] [Dev Deps] update `@types/node`, `browserify`, `coveralls`, `cross-spawn`, `eslint`, `formidable`, `in-publish`, `pkgfiles`, `pre-commit`, `puppeteer`, `request`, `tape`, `typescript` --- package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4666b9a2..ba0a3059 100644 --- a/package.json +++ b/package.json @@ -49,26 +49,26 @@ "devDependencies": { "@types/combined-stream": "^1.0.6", "@types/mime-types": "^2.1.4", - "@types/node": "^12.0.10", - "browserify": "^13.1.1", + "@types/node": "^12.20.55", + "browserify": "^13.3.0", "browserify-istanbul": "^2.0.0", - "coveralls": "^3.0.4", - "cross-spawn": "^6.0.5", - "eslint": "^6.0.1", + "coveralls": "^3.1.1", + "cross-spawn": "^6.0.6", + "eslint": "^6.8.0", "fake": "^0.2.2", "far": "^0.0.7", - "formidable": "^1.0.17", - "in-publish": "^2.0.0", + "formidable": "^1.2.6", + "in-publish": "^2.0.1", "is-node-modern": "^1.0.0", "istanbul": "^0.4.5", "obake": "^0.1.2", - "puppeteer": "^1.19.0", - "pkgfiles": "^2.3.0", - "pre-commit": "^1.1.3", - "request": "^2.88.0", + "pkgfiles": "^2.3.2", + "pre-commit": "^1.2.2", + "puppeteer": "^1.20.0", + "request": "^2.88.2", "rimraf": "^2.7.1", - "tape": "^4.6.2", - "typescript": "^3.5.2" + "tape": "^5.9.0", + "typescript": "^3.9.10" }, "license": "MIT" } From df3c1e6f0937f47a782dc4573756a54987f31dde Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 11:46:18 -0800 Subject: [PATCH 15/30] [Refactor] use `Object.prototype.hasOwnProperty.call` --- lib/form_data.js | 42 ++++++++++---------- test/common.js | 19 +++++---- test/integration/test-custom-content-type.js | 15 ++++--- test/integration/test-pipe.js | 15 ++++--- test/integration/test-ranged-filestream.js | 20 +++++----- 5 files changed, 53 insertions(+), 58 deletions(-) diff --git a/lib/form_data.js b/lib/form_data.js index 85f0a7ec..3479d18c 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -103,7 +103,7 @@ FormData.prototype._trackLength = function(header, value, options) { FormData.LINE_BREAK.length; // empty or either doesn't have path or not an http response or not a stream - if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) { + if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) && !(value instanceof Stream))) { return; } @@ -114,8 +114,7 @@ FormData.prototype._trackLength = function(header, value, options) { }; FormData.prototype._lengthRetriever = function(value, callback) { - - if (value.hasOwnProperty('fd')) { + if (Object.prototype.hasOwnProperty.call(value, 'fd')) { // take read range into a account // `end` = Infinity –> read file till the end @@ -150,11 +149,11 @@ FormData.prototype._lengthRetriever = function(value, callback) { } // or http response - } else if (value.hasOwnProperty('httpVersion')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { callback(null, +value.headers['content-length']); // or request stream http://github.com/mikeal/request - } else if (value.hasOwnProperty('httpModule')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) { // wait till response come back value.on('response', function(response) { value.pause(); @@ -194,22 +193,23 @@ FormData.prototype._multiPartHeader = function(field, value, options) { var header; for (var prop in headers) { - if (!headers.hasOwnProperty(prop)) continue; - header = headers[prop]; + if (Object.prototype.hasOwnProperty.call(headers, prop)) { + header = headers[prop]; - // skip nullish headers. - if (header == null) { - continue; - } + // skip nullish headers. + if (header == null) { + continue; + } - // convert all headers to arrays. - if (!Array.isArray(header)) { - header = [header]; - } + // convert all headers to arrays. + if (!Array.isArray(header)) { + header = [header]; + } - // add non-empty headers. - if (header.length) { - contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + // add non-empty headers. + if (header.length) { + contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + } } } @@ -230,7 +230,7 @@ FormData.prototype._getContentDisposition = function(value, options) { // formidable and the browser add a name property // fs- and request- streams have path property filename = path.basename(options.filename || value.name || value.path); - } else if (value.readable && value.hasOwnProperty('httpVersion')) { + } else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { // or try http response filename = path.basename(value.client._httpMessage.path || ''); } @@ -258,7 +258,7 @@ FormData.prototype._getContentType = function(value, options) { } // or if it's http-reponse - if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) { + if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { contentType = value.headers['content-type']; } @@ -299,7 +299,7 @@ FormData.prototype.getHeaders = function(userHeaders) { }; for (header in userHeaders) { - if (userHeaders.hasOwnProperty(header)) { + if (Object.prototype.hasOwnProperty.call(userHeaders, header)) { formHeaders[header.toLowerCase()] = userHeaders[header]; } } diff --git a/test/common.js b/test/common.js index 7da855c1..f3d63719 100644 --- a/test/common.js +++ b/test/common.js @@ -40,7 +40,7 @@ common.testFields = function (FIELDS, callback) { var incomingForm = new IncomingForm({uploadDir: common.dir.tmp}); incomingForm.parse(req); - + common.actions.checkForm(incomingForm, FIELDS, function (fieldsChecked) { // keep track of number of the processed fields callback(fieldsPassed - fieldsChecked); @@ -55,18 +55,17 @@ common.testFields = function (FIELDS, callback) { common.actions = {}; // generic form field population -common.actions.populateFields = function(form, fields) -{ +common.actions.populateFields = function (form, fields) { var field; for (var name in fields) { - if (!fields.hasOwnProperty(name)) { continue; } - - field = fields[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(fields, name)) { + field = fields[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } }; diff --git a/test/integration/test-custom-content-type.js b/test/integration/test-custom-content-type.js index d8c1b765..534fdfbd 100644 --- a/test/integration/test-custom-content-type.js +++ b/test/integration/test-custom-content-type.js @@ -67,16 +67,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value, field.options); } - form.append(name, field.value, field.options); } // custom params object passed to submit diff --git a/test/integration/test-pipe.js b/test/integration/test-pipe.js index c3360efc..1b41a02b 100644 --- a/test/integration/test-pipe.js +++ b/test/integration/test-pipe.js @@ -49,16 +49,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } var req = http.request({ diff --git a/test/integration/test-ranged-filestream.js b/test/integration/test-ranged-filestream.js index bac1d259..8fa0cafe 100644 --- a/test/integration/test-ranged-filestream.js +++ b/test/integration/test-ranged-filestream.js @@ -80,20 +80,18 @@ server.listen(common.port, function() { // add test subjects to the form for (name in testSubjects) { - if (!testSubjects.hasOwnProperty(name)) { - continue; - } - - options = {encoding: 'utf8'}; + if (Object.prototype.hasOwnProperty.call(testSubjects, name)) { + options = {encoding: 'utf8'}; - if (testSubjects[name].start) { options.start = testSubjects[name].start; } - if (testSubjects[name].end) { options.end = testSubjects[name].end; } + if (testSubjects[name].start) { options.start = testSubjects[name].start; } + if (testSubjects[name].end) { options.end = testSubjects[name].end; } - form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); + form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); - // calculate data size - testSubjects[name].readSize = 0; - testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + // calculate data size + testSubjects[name].readSize = 0; + testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + } } form.submit('http://localhost:' + common.port + '/', function(err, res) { From f80033f564aa08f3f1a9928030a56fdc92161708 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 13 Feb 2025 19:00:00 +0100 Subject: [PATCH 16/30] =?UTF-8?q?[Fix]=20set=C2=A0`Symbol.toStringTag`=20w?= =?UTF-8?q?hen=C2=A0available=20(#573)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #396 --- lib/form_data.js | 2 ++ package.json | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/form_data.js b/lib/form_data.js index b1b20c90..93a96ade 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -7,6 +7,7 @@ var parseUrl = require('url').parse; var fs = require('fs'); var mime = require('mime-types'); var asynckit = require('asynckit'); +var setToStringTag = require('es-set-tostringtag'); var populate = require('./populate.js'); var Buffer = require('safe-buffer').Buffer; // eslint-disable-line no-shadow @@ -482,3 +483,4 @@ FormData.prototype._error = function(err) { FormData.prototype.toString = function () { return '[object FormData]'; }; +setToStringTag(FormData, 'FormData'); diff --git a/package.json b/package.json index 4a7cae77..de2c2e4b 100644 --- a/package.json +++ b/package.json @@ -43,10 +43,13 @@ "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", + "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12", "safe-buffer": "^5.2.1" }, "devDependencies": { + "@types/combined-stream": "^1.0.6", + "@types/mime-types": "^2.1.4", "@types/node": "^12.0.10", "browserify": "^13.1.1", "browserify-istanbul": "^2.0.0", From 819f6b7a543306a891fca37c3a06d0ff4a734422 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 12:15:26 -0800 Subject: [PATCH 17/30] [Dev Deps] update `@types/node`, `browserify`, `coveralls`, `eslint`, `formidable`, `in-publish`, `phantomjs-prebuilt`, `pkgfiles`, `pre-commit`, `request`, `tape`, `typescript` --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index de2c2e4b..709cf47c 100644 --- a/package.json +++ b/package.json @@ -50,26 +50,26 @@ "devDependencies": { "@types/combined-stream": "^1.0.6", "@types/mime-types": "^2.1.4", - "@types/node": "^12.0.10", - "browserify": "^13.1.1", + "@types/node": "^12.20.55", + "browserify": "^13.3.0", "browserify-istanbul": "^2.0.0", - "coveralls": "^3.0.4", + "coveralls": "^3.1.1", "cross-spawn": "^4.0.2", - "eslint": "^6.0.1", + "eslint": "^6.8.0", "fake": "^0.2.2", "far": "^0.0.7", - "formidable": "^1.0.17", - "in-publish": "^2.0.0", + "formidable": "^1.2.6", + "in-publish": "^2.0.1", "is-node-modern": "^1.0.0", "istanbul": "^0.4.5", "obake": "^0.1.2", - "phantomjs-prebuilt": "^2.1.13", - "pkgfiles": "^2.3.0", - "pre-commit": "^1.1.3", - "request": "^2.88.0", + "phantomjs-prebuilt": "^2.1.16", + "pkgfiles": "^2.3.2", + "pre-commit": "^1.2.2", + "request": "^2.88.2", "rimraf": "^2.7.1", - "tape": "^4.6.2", - "typescript": "^3.5.2" + "tape": "^5.9.0", + "typescript": "^3.9.10" }, "license": "MIT" } From 6e682d4bd41de7e80de41e3c4ee10f23fcc3dd00 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 11:46:18 -0800 Subject: [PATCH 18/30] [Refactor] use `Object.prototype.hasOwnProperty.call` --- lib/form_data.js | 42 ++++++++++---------- test/common.js | 19 +++++---- test/integration/test-custom-content-type.js | 15 ++++--- test/integration/test-pipe.js | 15 ++++--- test/integration/test-ranged-filestream.js | 20 +++++----- 5 files changed, 53 insertions(+), 58 deletions(-) diff --git a/lib/form_data.js b/lib/form_data.js index 93a96ade..fb342d3f 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -103,7 +103,7 @@ FormData.prototype._trackLength = function(header, value, options) { FormData.LINE_BREAK.length; // empty or either doesn't have path or not an http response - if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) { + if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) )) { return; } @@ -114,8 +114,7 @@ FormData.prototype._trackLength = function(header, value, options) { }; FormData.prototype._lengthRetriever = function(value, callback) { - - if (value.hasOwnProperty('fd')) { + if (Object.prototype.hasOwnProperty.call(value, 'fd')) { // take read range into a account // `end` = Infinity –> read file till the end @@ -150,11 +149,11 @@ FormData.prototype._lengthRetriever = function(value, callback) { } // or http response - } else if (value.hasOwnProperty('httpVersion')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { callback(null, +value.headers['content-length']); // or request stream http://github.com/mikeal/request - } else if (value.hasOwnProperty('httpModule')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) { // wait till response come back value.on('response', function(response) { value.pause(); @@ -194,22 +193,23 @@ FormData.prototype._multiPartHeader = function(field, value, options) { var header; for (var prop in headers) { - if (!headers.hasOwnProperty(prop)) continue; - header = headers[prop]; + if (Object.prototype.hasOwnProperty.call(headers, prop)) { + header = headers[prop]; - // skip nullish headers. - if (header == null) { - continue; - } + // skip nullish headers. + if (header == null) { + continue; + } - // convert all headers to arrays. - if (!Array.isArray(header)) { - header = [header]; - } + // convert all headers to arrays. + if (!Array.isArray(header)) { + header = [header]; + } - // add non-empty headers. - if (header.length) { - contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + // add non-empty headers. + if (header.length) { + contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + } } } @@ -230,7 +230,7 @@ FormData.prototype._getContentDisposition = function(value, options) { // formidable and the browser add a name property // fs- and request- streams have path property filename = path.basename(options.filename || value.name || value.path); - } else if (value.readable && value.hasOwnProperty('httpVersion')) { + } else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { // or try http response filename = path.basename(value.client._httpMessage.path || ''); } @@ -258,7 +258,7 @@ FormData.prototype._getContentType = function(value, options) { } // or if it's http-reponse - if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) { + if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { contentType = value.headers['content-type']; } @@ -299,7 +299,7 @@ FormData.prototype.getHeaders = function(userHeaders) { }; for (header in userHeaders) { - if (userHeaders.hasOwnProperty(header)) { + if (Object.prototype.hasOwnProperty.call(userHeaders, header)) { formHeaders[header.toLowerCase()] = userHeaders[header]; } } diff --git a/test/common.js b/test/common.js index 7da855c1..f3d63719 100644 --- a/test/common.js +++ b/test/common.js @@ -40,7 +40,7 @@ common.testFields = function (FIELDS, callback) { var incomingForm = new IncomingForm({uploadDir: common.dir.tmp}); incomingForm.parse(req); - + common.actions.checkForm(incomingForm, FIELDS, function (fieldsChecked) { // keep track of number of the processed fields callback(fieldsPassed - fieldsChecked); @@ -55,18 +55,17 @@ common.testFields = function (FIELDS, callback) { common.actions = {}; // generic form field population -common.actions.populateFields = function(form, fields) -{ +common.actions.populateFields = function (form, fields) { var field; for (var name in fields) { - if (!fields.hasOwnProperty(name)) { continue; } - - field = fields[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(fields, name)) { + field = fields[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } }; diff --git a/test/integration/test-custom-content-type.js b/test/integration/test-custom-content-type.js index d8c1b765..534fdfbd 100644 --- a/test/integration/test-custom-content-type.js +++ b/test/integration/test-custom-content-type.js @@ -67,16 +67,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value, field.options); } - form.append(name, field.value, field.options); } // custom params object passed to submit diff --git a/test/integration/test-pipe.js b/test/integration/test-pipe.js index c3360efc..1b41a02b 100644 --- a/test/integration/test-pipe.js +++ b/test/integration/test-pipe.js @@ -49,16 +49,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } var req = http.request({ diff --git a/test/integration/test-ranged-filestream.js b/test/integration/test-ranged-filestream.js index bac1d259..8fa0cafe 100644 --- a/test/integration/test-ranged-filestream.js +++ b/test/integration/test-ranged-filestream.js @@ -80,20 +80,18 @@ server.listen(common.port, function() { // add test subjects to the form for (name in testSubjects) { - if (!testSubjects.hasOwnProperty(name)) { - continue; - } - - options = {encoding: 'utf8'}; + if (Object.prototype.hasOwnProperty.call(testSubjects, name)) { + options = {encoding: 'utf8'}; - if (testSubjects[name].start) { options.start = testSubjects[name].start; } - if (testSubjects[name].end) { options.end = testSubjects[name].end; } + if (testSubjects[name].start) { options.start = testSubjects[name].start; } + if (testSubjects[name].end) { options.end = testSubjects[name].end; } - form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); + form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); - // calculate data size - testSubjects[name].readSize = 0; - testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + // calculate data size + testSubjects[name].readSize = 0; + testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + } } form.submit('http://localhost:' + common.port + '/', function(err, res) { From 6b1ca1dc7362a1b1c3a99a885516cca4b7eb817f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 12:17:18 -0800 Subject: [PATCH 19/30] [Deps] update `combined-stream`, `mime-types` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 709cf47c..e1c0b3d2 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,9 @@ }, "dependencies": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", + "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", - "mime-types": "^2.1.12", + "mime-types": "^2.1.35", "safe-buffer": "^5.2.1" }, "devDependencies": { From b170ee2b22b4c695c363b811c0c553d2fb1bbd79 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 12:18:12 -0800 Subject: [PATCH 20/30] Only apps should have lockfiles --- .gitignore | 5 +++++ .npmrc | 1 + 2 files changed, 6 insertions(+) create mode 100644 .npmrc diff --git a/.gitignore b/.gitignore index 5790d187..6d8a8023 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,8 @@ package-lock.json coverage/ node_modules/ test/tmp/ + +# Only apps should have lockfiles +npm-shrinkwrap.json +package-lock.json +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false From 9dbe192be3db215eac4d9c0b980470a5c2c030c6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 13:25:13 -0800 Subject: [PATCH 21/30] [Dev Deps] pin `request` which via `tough-cookie` ^2.4 depends on `psl` See https://github.com/lupomontero/psl/issues/341 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e1c0b3d2..6347e0f5 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "phantomjs-prebuilt": "^2.1.16", "pkgfiles": "^2.3.2", "pre-commit": "^1.2.2", - "request": "^2.88.2", + "request": "~2.87.0", "rimraf": "^2.7.1", "tape": "^5.9.0", "typescript": "^3.9.10" From 9457283e1dce6122adc908fdd7442cfc54cabe7a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 13:54:25 -0800 Subject: [PATCH 22/30] Bumped version 2.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6347e0f5..0e32d312 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "form-data", "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", - "version": "2.5.2", + "version": "2.5.3", "repository": { "type": "git", "url": "git://github.com/form-data/form-data.git" From b82f59093cdbadb4b7ec0922d33ae7ab048b82ff Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 12:18:12 -0800 Subject: [PATCH 23/30] Only apps should have lockfiles --- .gitignore | 5 +++++ .npmrc | 1 + 2 files changed, 6 insertions(+) create mode 100644 .npmrc diff --git a/.gitignore b/.gitignore index 5790d187..6d8a8023 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,8 @@ package-lock.json coverage/ node_modules/ test/tmp/ + +# Only apps should have lockfiles +npm-shrinkwrap.json +package-lock.json +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false From 8261fcb8bf5944d30ae3bd04b91b71d6a9932ef4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 13:59:27 -0800 Subject: [PATCH 24/30] [Dev Deps] update `@types/node`, `browserify`, `coveralls`, `cross-spawn`, `eslint`, `formidable`, `in-publish`, `pkgfiles`, `pre-commit`, `puppeteer`, `request`, `tape`, `typescript` --- package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 9ced4589..ddbfdb1d 100644 --- a/package.json +++ b/package.json @@ -46,26 +46,26 @@ "mime-types": "^2.1.12" }, "devDependencies": { - "@types/node": "^12.0.10", - "browserify": "^13.1.1", + "@types/node": "^12.20.55", + "browserify": "^13.3.0", "browserify-istanbul": "^2.0.0", - "coveralls": "^3.0.4", - "cross-spawn": "^6.0.5", - "eslint": "^6.0.1", + "coveralls": "^3.1.1", + "cross-spawn": "^6.0.6", + "eslint": "^6.8.0", "fake": "^0.2.2", "far": "^0.0.7", - "formidable": "^1.0.17", - "in-publish": "^2.0.0", + "formidable": "^1.2.6", + "in-publish": "^2.0.1", "is-node-modern": "^1.0.0", "istanbul": "^0.4.5", "obake": "^0.1.2", - "puppeteer": "^1.19.0", - "pkgfiles": "^2.3.0", - "pre-commit": "^1.1.3", - "request": "^2.88.0", + "pkgfiles": "^2.3.2", + "pre-commit": "^1.2.2", + "puppeteer": "^1.20.0", + "request": "^2.88.2", "rimraf": "^2.7.1", - "tape": "^4.6.2", - "typescript": "^3.5.2" + "tape": "^5.9.0", + "typescript": "^3.9.10" }, "license": "MIT" } From 5a5bafee894fead10da49e1fa2b084e17f2e1034 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 14:02:36 -0800 Subject: [PATCH 25/30] [Deps] update `mime-types` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ddbfdb1d..82a523e7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" + "mime-types": "^2.1.35" }, "devDependencies": { "@types/node": "^12.20.55", From 7fecefe4ba8f775634aff86a698776ad95ecffb5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 11:46:18 -0800 Subject: [PATCH 26/30] [Refactor] use `Object.prototype.hasOwnProperty.call` --- lib/form_data.js | 42 ++++++++++---------- test/common.js | 19 +++++---- test/integration/test-custom-content-type.js | 15 ++++--- test/integration/test-pipe.js | 15 ++++--- test/integration/test-ranged-filestream.js | 20 +++++----- 5 files changed, 53 insertions(+), 58 deletions(-) diff --git a/lib/form_data.js b/lib/form_data.js index 93164426..b28bf162 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -101,7 +101,7 @@ FormData.prototype._trackLength = function(header, value, options) { FormData.LINE_BREAK.length; // empty or either doesn't have path or not an http response - if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) { + if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) )) { return; } @@ -112,8 +112,7 @@ FormData.prototype._trackLength = function(header, value, options) { }; FormData.prototype._lengthRetriever = function(value, callback) { - - if (value.hasOwnProperty('fd')) { + if (Object.prototype.hasOwnProperty.call(value, 'fd')) { // take read range into a account // `end` = Infinity –> read file till the end @@ -148,11 +147,11 @@ FormData.prototype._lengthRetriever = function(value, callback) { } // or http response - } else if (value.hasOwnProperty('httpVersion')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { callback(null, +value.headers['content-length']); // or request stream http://github.com/mikeal/request - } else if (value.hasOwnProperty('httpModule')) { + } else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) { // wait till response come back value.on('response', function(response) { value.pause(); @@ -192,22 +191,23 @@ FormData.prototype._multiPartHeader = function(field, value, options) { var header; for (var prop in headers) { - if (!headers.hasOwnProperty(prop)) continue; - header = headers[prop]; + if (Object.prototype.hasOwnProperty.call(headers, prop)) { + header = headers[prop]; - // skip nullish headers. - if (header == null) { - continue; - } + // skip nullish headers. + if (header == null) { + continue; + } - // convert all headers to arrays. - if (!Array.isArray(header)) { - header = [header]; - } + // convert all headers to arrays. + if (!Array.isArray(header)) { + header = [header]; + } - // add non-empty headers. - if (header.length) { - contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + // add non-empty headers. + if (header.length) { + contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; + } } } @@ -228,7 +228,7 @@ FormData.prototype._getContentDisposition = function(value, options) { // formidable and the browser add a name property // fs- and request- streams have path property filename = path.basename(options.filename || value.name || value.path); - } else if (value.readable && value.hasOwnProperty('httpVersion')) { + } else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { // or try http response filename = path.basename(value.client._httpMessage.path || ''); } @@ -256,7 +256,7 @@ FormData.prototype._getContentType = function(value, options) { } // or if it's http-reponse - if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) { + if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) { contentType = value.headers['content-type']; } @@ -297,7 +297,7 @@ FormData.prototype.getHeaders = function(userHeaders) { }; for (header in userHeaders) { - if (userHeaders.hasOwnProperty(header)) { + if (Object.prototype.hasOwnProperty.call(userHeaders, header)) { formHeaders[header.toLowerCase()] = userHeaders[header]; } } diff --git a/test/common.js b/test/common.js index 7da855c1..f3d63719 100644 --- a/test/common.js +++ b/test/common.js @@ -40,7 +40,7 @@ common.testFields = function (FIELDS, callback) { var incomingForm = new IncomingForm({uploadDir: common.dir.tmp}); incomingForm.parse(req); - + common.actions.checkForm(incomingForm, FIELDS, function (fieldsChecked) { // keep track of number of the processed fields callback(fieldsPassed - fieldsChecked); @@ -55,18 +55,17 @@ common.testFields = function (FIELDS, callback) { common.actions = {}; // generic form field population -common.actions.populateFields = function(form, fields) -{ +common.actions.populateFields = function (form, fields) { var field; for (var name in fields) { - if (!fields.hasOwnProperty(name)) { continue; } - - field = fields[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(fields, name)) { + field = fields[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } }; diff --git a/test/integration/test-custom-content-type.js b/test/integration/test-custom-content-type.js index d8c1b765..534fdfbd 100644 --- a/test/integration/test-custom-content-type.js +++ b/test/integration/test-custom-content-type.js @@ -67,16 +67,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value, field.options); } - form.append(name, field.value, field.options); } // custom params object passed to submit diff --git a/test/integration/test-pipe.js b/test/integration/test-pipe.js index c3360efc..1b41a02b 100644 --- a/test/integration/test-pipe.js +++ b/test/integration/test-pipe.js @@ -49,16 +49,15 @@ server.listen(common.port, function() { var form = new FormData(); - var field; for (var name in FIELDS) { - if (!FIELDS.hasOwnProperty(name)) { continue; } - - field = FIELDS[name]; - // important to append ReadStreams within the same tick - if ((typeof field.value == 'function')) { - field.value = field.value(); + if (Object.prototype.hasOwnProperty.call(FIELDS, name)) { + var field = FIELDS[name]; + // important to append ReadStreams within the same tick + if ((typeof field.value == 'function')) { + field.value = field.value(); + } + form.append(name, field.value); } - form.append(name, field.value); } var req = http.request({ diff --git a/test/integration/test-ranged-filestream.js b/test/integration/test-ranged-filestream.js index bac1d259..8fa0cafe 100644 --- a/test/integration/test-ranged-filestream.js +++ b/test/integration/test-ranged-filestream.js @@ -80,20 +80,18 @@ server.listen(common.port, function() { // add test subjects to the form for (name in testSubjects) { - if (!testSubjects.hasOwnProperty(name)) { - continue; - } - - options = {encoding: 'utf8'}; + if (Object.prototype.hasOwnProperty.call(testSubjects, name)) { + options = {encoding: 'utf8'}; - if (testSubjects[name].start) { options.start = testSubjects[name].start; } - if (testSubjects[name].end) { options.end = testSubjects[name].end; } + if (testSubjects[name].start) { options.start = testSubjects[name].start; } + if (testSubjects[name].end) { options.end = testSubjects[name].end; } - form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); + form.append(name, testSubjects[name].fsStream = fs.createReadStream(common.dir.fixture + '/' + testSubjects[name].file, options)); - // calculate data size - testSubjects[name].readSize = 0; - testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + // calculate data size + testSubjects[name].readSize = 0; + testSubjects[name].fsStream.on('data', readSizeAccumulator.bind(testSubjects[name])); + } } form.submit('http://localhost:' + common.port + '/', function(err, res) { From 84ca1d6006d65abe7b73c3e99b023aeb353e1e12 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 13 Feb 2025 19:00:00 +0100 Subject: [PATCH 27/30] =?UTF-8?q?[Fix]=20set=C2=A0`Symbol.toStringTag`=20w?= =?UTF-8?q?hen=C2=A0available=20(#573)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #396 --- lib/form_data.js | 2 ++ package.json | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/form_data.js b/lib/form_data.js index b28bf162..39222e58 100644 --- a/lib/form_data.js +++ b/lib/form_data.js @@ -7,6 +7,7 @@ var parseUrl = require('url').parse; var fs = require('fs'); var mime = require('mime-types'); var asynckit = require('asynckit'); +var setToStringTag = require('es-set-tostringtag'); var populate = require('./populate.js'); // Public API @@ -496,3 +497,4 @@ FormData.prototype._error = function(err) { FormData.prototype.toString = function () { return '[object FormData]'; }; +setToStringTag(FormData, 'FormData'); diff --git a/package.json b/package.json index 82a523e7..64721e68 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.35" }, "devDependencies": { From e5df7f24383342264bd73dee3274818a40d04065 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 13:25:13 -0800 Subject: [PATCH 28/30] [Dev Deps] pin `request` which via `tough-cookie` ^2.4 depends on `psl` See https://github.com/lupomontero/psl/issues/341 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64721e68..d7937a39 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "pkgfiles": "^2.3.2", "pre-commit": "^1.2.2", "puppeteer": "^1.20.0", - "request": "^2.88.2", + "request": "~2.87.0", "rimraf": "^2.7.1", "tape": "^5.9.0", "typescript": "^3.9.10" From e46f09bb5338bff090f5cceea5119a8b37c9b147 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 14:59:35 -0800 Subject: [PATCH 29/30] v3.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d7937a39..37fb8a97 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "form-data", "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", - "version": "3.0.2", + "version": "3.0.3", "repository": { "type": "git", "url": "git://github.com/form-data/form-data.git" From 7465e1337244831e91f9a2413a2bf49bdc2a2e04 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Feb 2025 15:23:04 -0800 Subject: [PATCH 30/30] v4.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 377ecc82..47fc92b7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "form-data", "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", - "version": "4.0.1", + "version": "4.0.2", "repository": { "type": "git", "url": "git://github.com/form-data/form-data.git"