tsoa
This commit is contained in:
11
node_modules/@hapi/content/LICENSE.md
generated
vendored
Executable file
11
node_modules/@hapi/content/LICENSE.md
generated
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) 2014-2022, Project contributors
|
||||
Copyright (c) 2014-2020, Sideway Inc
|
||||
Copyright (c) 2014, Walmart.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
17
node_modules/@hapi/content/README.md
generated
vendored
Normal file
17
node_modules/@hapi/content/README.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
|
||||
|
||||
# @hapi/content
|
||||
|
||||
#### HTTP Content-* headers parsing.
|
||||
|
||||
**content** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
|
||||
|
||||
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://hapi.dev/family/content/)
|
||||
- [Versions status](https://hapi.dev/resources/status/#content) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://hapi.dev/family/content/changelog/)
|
||||
- [Project policies](https://hapi.dev/policies/)
|
||||
- [Free and commercial support options](https://hapi.dev/support/)
|
||||
145
node_modules/@hapi/content/lib/index.js
generated
vendored
Executable file
145
node_modules/@hapi/content/lib/index.js
generated
vendored
Executable file
@@ -0,0 +1,145 @@
|
||||
'use strict';
|
||||
|
||||
const Boom = require('@hapi/boom');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
/*
|
||||
RFC 7231 Section 3.1.1.1
|
||||
|
||||
media-type = type "/" subtype *( OWS ";" OWS parameter )
|
||||
type = token
|
||||
subtype = token
|
||||
parameter = token "=" ( token / quoted-string )
|
||||
*/
|
||||
|
||||
// 1: type/subtype 2: params
|
||||
internals.contentTypeRegex = /^([^\/\s]+\/[^\s;]+)(.*)?$/;
|
||||
|
||||
// 1: "b" 2: b
|
||||
internals.charsetParamRegex = /;\s*charset=(?:"([^"]+)"|([^;"\s]+))/i;
|
||||
|
||||
// 1: "b" 2: b
|
||||
internals.boundaryParamRegex = /;\s*boundary=(?:"([^"]+)"|([^;"\s]+))/i;
|
||||
|
||||
|
||||
exports.type = function (header) {
|
||||
|
||||
if (!header) {
|
||||
throw Boom.badRequest('Invalid content-type header');
|
||||
}
|
||||
|
||||
const match = header.match(internals.contentTypeRegex);
|
||||
if (!match) {
|
||||
throw Boom.badRequest('Invalid content-type header');
|
||||
}
|
||||
|
||||
const result = {
|
||||
mime: match[1].toLowerCase()
|
||||
};
|
||||
|
||||
const params = match[2];
|
||||
if (params) {
|
||||
const param = params.match(internals.charsetParamRegex);
|
||||
if (param) {
|
||||
result.charset = (param[1] || param[2]).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (result.mime.indexOf('multipart/') === 0) {
|
||||
if (params) {
|
||||
const param = params.match(internals.boundaryParamRegex);
|
||||
if (param) {
|
||||
result.boundary = param[1] || param[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.boundary) {
|
||||
throw Boom.badRequest('Invalid content-type header: multipart missing boundary');
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
RFC 6266 Section 4.1 (http://tools.ietf.org/html/rfc6266#section-4.1)
|
||||
|
||||
content-disposition = "Content-Disposition" ":" disposition-type *( ";" disposition-parm )
|
||||
disposition-type = "inline" | "attachment" | token ; case-insensitive
|
||||
disposition-parm = filename-parm | token [ "*" ] "=" ( token | quoted-string | ext-value) ; ext-value defined in [RFC5987], Section 3.2
|
||||
|
||||
Content-Disposition header field values with multiple instances of the same parameter name are invalid.
|
||||
|
||||
Note that due to the rules for implied linear whitespace (Section 2.1 of [RFC2616]), OPTIONAL whitespace
|
||||
can appear between words (token or quoted-string) and separator characters.
|
||||
|
||||
Furthermore, note that the format used for ext-value allows specifying a natural language (e.g., "en"); this is of limited use
|
||||
for filenames and is likely to be ignored by recipients.
|
||||
*/
|
||||
|
||||
|
||||
internals.contentDispositionRegex = /^\s*form-data\s*(?:;\s*(.+))?$/i;
|
||||
|
||||
// 1: name 2: * 3: ext-value 4: quoted 5: token
|
||||
internals.contentDispositionParamRegex = /([^\=\*\s]+)(\*)?\s*\=\s*(?:([^;'"\s]+\'[\w-]*\'[^;\s]+)|(?:\"([^"]*)\")|([^;\s]*))(?:\s*(?:;\s*)|$)/g;
|
||||
|
||||
exports.disposition = function (header) {
|
||||
|
||||
if (!header) {
|
||||
throw Boom.badRequest('Missing content-disposition header');
|
||||
}
|
||||
|
||||
const match = header.match(internals.contentDispositionRegex);
|
||||
if (!match) {
|
||||
throw Boom.badRequest('Invalid content-disposition header format');
|
||||
}
|
||||
|
||||
const parameters = match[1];
|
||||
if (!parameters) {
|
||||
throw Boom.badRequest('Invalid content-disposition header missing parameters');
|
||||
}
|
||||
|
||||
const result = {};
|
||||
parameters.replace(internals.contentDispositionParamRegex, ($0, $1, $2, $3, $4, $5) => {
|
||||
|
||||
if ($1 === '__proto__') {
|
||||
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');
|
||||
}
|
||||
|
||||
let value;
|
||||
|
||||
if ($2) {
|
||||
if (!$3) {
|
||||
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');
|
||||
}
|
||||
|
||||
try {
|
||||
value = decodeURIComponent($3.split('\'')[2]);
|
||||
}
|
||||
catch (err) {
|
||||
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = $4 || $5 || '';
|
||||
}
|
||||
|
||||
if ($1 === 'name' &&
|
||||
value === '__proto__') {
|
||||
|
||||
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');
|
||||
}
|
||||
|
||||
result[$1] = value;
|
||||
});
|
||||
|
||||
if (!result.name) {
|
||||
throw Boom.badRequest('Invalid content-disposition header missing name parameter');
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
35
node_modules/@hapi/content/package.json
generated
vendored
Normal file
35
node_modules/@hapi/content/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@hapi/content",
|
||||
"description": "HTTP Content-* headers parsing",
|
||||
"version": "6.0.0",
|
||||
"repository": "git://github.com/hapijs/content",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"keywords": [
|
||||
"HTTP",
|
||||
"header",
|
||||
"content",
|
||||
"content-type",
|
||||
"content-disposition"
|
||||
],
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"plugin:@hapi/module"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/boom": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "^9.0.0",
|
||||
"@hapi/eslint-plugin": "*",
|
||||
"@hapi/lab": "^25.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L",
|
||||
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
|
||||
},
|
||||
"license": "BSD-3-Clause"
|
||||
}
|
||||
Reference in New Issue
Block a user