MCPcopy Index your code
hub / github.com/nodejs/node / parseContentDispositionAttribute

Function parseContentDispositionAttribute

deps/undici/undici.js:6432–6503  ·  view source on GitHub ↗
(input, position)

Source from the content-addressed store, hash-verified

6430 }
6431 __name(multipartFormDataParser, "multipartFormDataParser");
6432 function parseContentDispositionAttribute(input, position) {
6433 if (input[position.position] === 59) {
6434 position.position++;
6435 }
6436 collectASequenceOfBytes(
6437 (char) => char === 32 || char === 9,
6438 input,
6439 position
6440 );
6441 const attributeName = collectASequenceOfBytes(
6442 (char) => isToken(char) && char !== 61 && char !== 42,
6443 // not = or *
6444 input,
6445 position
6446 );
6447 if (attributeName.length === 0) {
6448 return null;
6449 }
6450 const attrNameStr = attributeName.toString("ascii").toLowerCase();
6451 const isExtended = input[position.position] === 42;
6452 if (isExtended) {
6453 position.position++;
6454 }
6455 if (input[position.position] !== 61) {
6456 return null;
6457 }
6458 position.position++;
6459 collectASequenceOfBytes(
6460 (char) => char === 32 || char === 9,
6461 input,
6462 position
6463 );
6464 let value;
6465 if (isExtended) {
6466 const headerValue = collectASequenceOfBytes(
6467 (char) => char !== 32 && char !== 13 && char !== 10 && char !== 59,
6468 // not space, CRLF, or ;
6469 input,
6470 position
6471 );
6472 if (headerValue[0] !== 117 && headerValue[0] !== 85 || // u or U
6473 headerValue[1] !== 116 && headerValue[1] !== 84 || // t or T
6474 headerValue[2] !== 102 && headerValue[2] !== 70 || // f or F
6475 headerValue[3] !== 45 || // -
6476 headerValue[4] !== 56) {
6477 throw parsingError("unknown encoding, expected utf-8''");
6478 }
6479 value = decodeURIComponent(decoder.decode(headerValue.subarray(7)));
6480 } else if (input[position.position] === 34) {
6481 position.position++;
6482 const quotedValue = collectASequenceOfBytes(
6483 (char) => char !== 10 && char !== 13 && char !== 34,
6484 // not LF, CR, or "
6485 input,
6486 position
6487 );
6488 if (input[position.position] !== 34) {
6489 throw parsingError("Closing quote not found");

Callers 1

Calls 5

collectASequenceOfBytesFunction · 0.70
isTokenFunction · 0.70
parsingErrorFunction · 0.70
decodeMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected