Debian Codegraph @

fastify-busboy/test/dicer-malformed-header.test.js

raw symbols SCIP
1 'use strict'
2
3 const { test } = require('node:test')
4 const Dicer = require('../deps/dicer/lib/Dicer')
5
6 test('dicer-malformed-header', async t => {
7 t.plan(1)
8
9 await t.test('should gracefully handle headers with leading whitespace', async t => {
10 t.plan(3)
11 const d = new Dicer({ boundary: '----WebKitFormBoundaryoo6vortfDzBsDiro' })
12
13 await new Promise((resolve) => {
14 d.on('part', function (p) {
15 p.on('header', function (header) {
16 t.assert.ok(header[' content-disposition'])
17 t.assert.deepStrictEqual(header[' content-disposition'], ['form-data; name="bildbeschreibung"'])
18 })
19 p.on('data', function (data) {
20 })
21 p.on('end', function () {
22 })
23 })
24 d.on('finish', function () {
25 t.assert.ok('finish')
26 resolve()
27 })
28
29 d.write(Buffer.from('------WebKitFormBoundaryoo6vortfDzBsDiro\r\n Content-Disposition: form-data; name="bildbeschreibung"\r\n\r\n\r\n------WebKitFormBoundaryoo6vortfDzBsDiro--'))
30 })
31 })
32 })