Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement sync formdata parser #2911

Merged
merged 11 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! off-by-one
KhafraDev committed Mar 3, 2024

Verified

This commit was signed with the committer’s verified signature.
kvikshaug Ali Kaafarani
commit fe9e5ed4c6fbc19b7940d022dfe24bad90e8749c
2 changes: 1 addition & 1 deletion lib/web/fetch/formdata-parser.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
* @see https://andreubotella.github.io/multipart-form-data/#multipart-form-data-boundary
* @param {string} boundary
*/
function validateBoundary (boundary) {

Check failure on line 20 in lib/web/fetch/formdata-parser.js

GitHub Actions / lint

'validateBoundary' is defined but never used
const length = boundary.length

// - its length is greater or equal to 27 and lesser or equal to 70, and
@@ -52,7 +52,7 @@
* @param {string} [encoding='utf-8']
* @param {boolean} [isFilename=false]
*/
function escapeFormDataName (name, encoding = 'utf-8', isFilename = false) {

Check failure on line 55 in lib/web/fetch/formdata-parser.js

GitHub Actions / lint

'escapeFormDataName' is defined but never used
// 1. If isFilename is true:
if (isFilename) {
// 1.1. Set name to the result of converting name into a scalar value string.
@@ -291,7 +291,7 @@
if (input.indexOf(filenameBuffer, position.position) === position.position) {
// 1. Advance position so it points at the byte after the next 0x22 (") byte
// (the one in the sequence of bytes matched above).
position.position += 13
position.position += 12

// 2. Set filename to the result of parsing a multipart/form-data name given
// input and position, if the result is not failure. Otherwise, return failure.

Unchanged files with check annotations Beta

/* globals AbortController */

Check failure on line 1 in test/fetch/client-fetch.js

GitHub Actions / test (18, ubuntu-latest)

test/fetch/client-fetch.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms', code: 'ERR_TEST_FAILURE' }

Check failure on line 1 in test/fetch/client-fetch.js

GitHub Actions / test (20, ubuntu-latest)

test/fetch/client-fetch.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/fetch/client-fetch.js

GitHub Actions / test (21, ubuntu-latest)

test/fetch/client-fetch.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }
'use strict'
strictEqual(form.get('field1').name, 'a/b/c/foo.txt')
})
test('urlencoded formData', (t, done) => {

Check failure on line 294 in test/fetch/client-fetch.js

GitHub Actions / test (18, ubuntu-latest)

urlencoded formData

[Error [ERR_TEST_FAILURE]: failed running after hook] { failureType: 'hookFailed', cause: AssertionError [ERR_ASSERTION]: The plan was not completed at TestContext.autoEnd (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:25:14) at TestHook.runInAsyncScope (node:async_hooks:203:9) at TestHook.run (node:internal/test_runner/test:631:25) at TestHook.run (node:internal/test_runner/test:856:18) at TestHook.run (node:internal/util:530:12) at node:internal/test_runner/test:565:20 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async node:internal/test_runner/test:564:9 at async Test.runHook (node:internal/test_runner/test:563:7) at async after (node:internal/test_runner/test:591:9) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 1, expected: 2, operator: 'strictEqual' }, code: 'ERR_TEST_FAILURE' }

Check failure on line 294 in test/fetch/client-fetch.js

GitHub Actions / test (20, ubuntu-latest)

urlencoded formData

[Error [ERR_TEST_FAILURE]: failed running after hook] { code: 'ERR_TEST_FAILURE', failureType: 'hookFailed', cause: AssertionError [ERR_ASSERTION]: The plan was not completed at TestContext.autoEnd (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:25:14) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:631:25) at TestHook.run (node:internal/test_runner/test:856:18) at TestHook.run (node:internal/util:531:12) at node:internal/test_runner/test:565:20 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async node:internal/test_runner/test:564:9 at async Test.runHook (node:internal/test_runner/test:563:7) at async after (node:internal/test_runner/test:591:9) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 1, expected: 2, operator: 'strictEqual' } }

Check failure on line 294 in test/fetch/client-fetch.js

GitHub Actions / test (21, ubuntu-latest)

urlencoded formData

[Error [ERR_TEST_FAILURE]: failed running after hook] { code: 'ERR_TEST_FAILURE', failureType: 'hookFailed', cause: AssertionError [ERR_ASSERTION]: The plan was not completed at TestContext.autoEnd (/home/runner/work/undici/undici/node_modules/@matteo.collina/tspl/tspl.js:25:14) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:631:25) at TestHook.run (node:internal/test_runner/test:856:18) at TestHook.run (node:internal/util:522:12) at node:internal/test_runner/test:565:20 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async node:internal/test_runner/test:564:9 at async Test.runHook (node:internal/test_runner/test:563:7) at async after (node:internal/test_runner/test:591:9) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 1, expected: 2, operator: 'strictEqual' } }
const { strictEqual } = tspl(t, { plan: 2 })
const server = createServer((req, res) => {