Socket
Socket
Sign inDemoInstall

@tinyhttp/content-disposition

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/content-disposition - npm Package Compare versions

Comparing version 2.0.8 to 2.0.9

32

dist/index.js

@@ -16,4 +16,2 @@ const ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;

class ContentDisposition {
type;
parameters;
constructor(type, parameters) {

@@ -36,4 +34,5 @@ this.type = type;

}) {
if (!type || typeof type !== "string" || !TOKEN_REGEXP.test(type))
if (!type || typeof type !== "string" || !TOKEN_REGEXP.test(type)) {
throw new TypeError("invalid type");
}
let string = String(type).toLowerCase();

@@ -55,4 +54,5 @@ if (parameters && typeof parameters === "object") {

fallback = true;
if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback))
if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
throw new TypeError("fallback must be ISO-8859-1 string");
}
const name = basename(filename);

@@ -62,6 +62,8 @@ const isQuotedString = TEXT_REGEXP.test(name);

const hasFallback = typeof fallbackName === "string" && fallbackName !== name;
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name))
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
params["filename*"] = name;
if (isQuotedString || hasFallback)
}
if (isQuotedString || hasFallback) {
params.filename = hasFallback ? fallbackName : name;
}
return params;

@@ -80,9 +82,12 @@ }

let value;
const binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode);
switch (charset) {
case "iso-8859-1":
value = getlatin1(binary);
value = getlatin1(encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode));
break;
case "utf-8":
value = Buffer.from(binary, "binary").toString("utf8");
try {
value = decodeURIComponent(encoded);
} catch {
throw new TypeError("invalid encoded utf-8");
}
break;

@@ -111,4 +116,5 @@ default:

value = match[2];
if (names.indexOf(key) !== -1)
if (names.indexOf(key) !== -1) {
throw new TypeError("invalid duplicate parameter");
}
names.push(key);

@@ -123,8 +129,10 @@ if (key.indexOf("*") + 1 === key.length) {

continue;
if (value[0] === '"')
if (value[0] === '"') {
value = value.substr(1, value.length - 2).replace(QESC_REGEXP, "$1");
}
params[key] = value;
}
if (index !== -1 && index !== string.length)
if (index !== -1 && index !== string.length) {
throw new TypeError("invalid parameter format");
}
return new ContentDisposition(type, params);

@@ -131,0 +139,0 @@ }

{
"name": "@tinyhttp/content-disposition",
"description": "content-disposition rewrite in TypeScript",
"version": "2.0.8",
"version": "2.0.9",
"license": "MIT",

@@ -6,0 +6,0 @@ "homepage": "https://tinyhttp.v1rtl.site",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc