Revert "Changements dans les modules (nouvelle version Express, mysql, ..)"

This reverts commit bdab795506.
This commit is contained in:
2023-11-23 16:13:50 +01:00
parent 756f928ced
commit 5b0d68d66f
818 changed files with 35968 additions and 82263 deletions

View File

@@ -1,11 +1,14 @@
/*!
* content-disposition
* Copyright(c) 2014 Douglas Christopher Wilson
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Module exports.
* @public
*/
module.exports = contentDisposition
@@ -13,43 +16,50 @@ module.exports.parse = parse
/**
* Module dependencies.
* @private
*/
var basename = require('path').basename
var Buffer = require('safe-buffer').Buffer
/**
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
* @private
*/
var encodeUriAttrCharRegExp = /[\x00-\x20"'\(\)*,\/:;<=>?@\[\\\]\{\}\x7f]/g
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g // eslint-disable-line no-control-regex
/**
* RegExp to match percent encoding escape.
* @private
*/
var hexEscapeRegExp = /%[0-9A-Fa-f]{2}/
var hexEscapeReplaceRegExp = /%([0-9A-Fa-f]{2})/g
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/
var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g
/**
* RegExp to match non-latin1 characters.
* @private
*/
var nonLatin1RegExp = /[^\x20-\x7e\xa0-\xff]/g
var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
/**
* RegExp to match quoted-pair in RFC 2616
*
* quoted-pair = "\" CHAR
* CHAR = <any US-ASCII character (octets 0 - 127)>
* @private
*/
var qescRegExp = /\\([\u0000-\u007f])/g;
var QESC_REGEXP = /\\([\u0000-\u007f])/g // eslint-disable-line no-control-regex
/**
* RegExp to match chars that must be quoted-pair in RFC 2616
* @private
*/
var quoteRegExp = /([\\"])/g
var QUOTE_REGEXP = /([\\"])/g
/**
* RegExp for various RFC 2616 grammar
@@ -73,11 +83,12 @@ var quoteRegExp = /([\\"])/g
* HT = <US-ASCII HT, horizontal-tab (9)>
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
* OCTET = <any 8-bit sequence of data>
* @private
*/
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g
var textRegExp = /^[\x20-\x7e\x80-\xff]+$/
var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
var PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g // eslint-disable-line no-control-regex
var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/
var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/
/**
* RegExp for various RFC 5987 grammar
@@ -98,9 +109,10 @@ var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
* attr-char = ALPHA / DIGIT
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
* / "^" / "_" / "`" / "|" / "~"
* @private
*/
var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+\-\.^_`|~])+)$/
var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/
/**
* RegExp for various RFC 6266 grammar
@@ -113,9 +125,10 @@ var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]
* disp-ext-parm = token "=" value
* | ext-token "=" ext-value
* ext-token = <the characters in token, followed by "*">
* @private
*/
var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/
var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/ // eslint-disable-line no-control-regex
/**
* Create an attachment Content-Disposition header.
@@ -125,10 +138,10 @@ var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/
* @param {string} [options.type=attachment]
* @param {string|boolean} [options.fallback=true]
* @return {string}
* @api public
* @public
*/
function contentDisposition(filename, options) {
function contentDisposition (filename, options) {
var opts = options || {}
// get type
@@ -147,10 +160,10 @@ function contentDisposition(filename, options) {
* @param {string} [filename]
* @param {string|boolean} [fallback=true]
* @return {object}
* @api private
* @private
*/
function createparams(filename, fallback) {
function createparams (filename, fallback) {
if (filename === undefined) {
return
}
@@ -170,7 +183,7 @@ function createparams(filename, fallback) {
throw new TypeError('fallback must be a string or boolean')
}
if (typeof fallback === 'string' && nonLatin1RegExp.test(fallback)) {
if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
throw new TypeError('fallback must be ISO-8859-1 string')
}
@@ -178,7 +191,7 @@ function createparams(filename, fallback) {
var name = basename(filename)
// determine if name is suitable for quoted string
var isQuotedString = textRegExp.test(name)
var isQuotedString = TEXT_REGEXP.test(name)
// generate fallback name
var fallbackName = typeof fallback !== 'string'
@@ -187,7 +200,7 @@ function createparams(filename, fallback) {
var hasFallback = typeof fallbackName === 'string' && fallbackName !== name
// set extended filename parameter
if (hasFallback || !isQuotedString || hexEscapeRegExp.test(name)) {
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
params['filename*'] = name
}
@@ -208,14 +221,14 @@ function createparams(filename, fallback) {
* @param {string} obj.type
* @param {object} [obj.parameters]
* @return {string}
* @api private
* @private
*/
function format(obj) {
function format (obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
throw new TypeError('invalid type')
}
@@ -242,15 +255,15 @@ function format(obj) {
}
/**
* Decode a RFC 6987 field value (gracefully).
* Decode a RFC 5987 field value (gracefully).
*
* @param {string} str
* @return {string}
* @api private
* @private
*/
function decodefield(str) {
var match = extValueRegExp.exec(str)
function decodefield (str) {
var match = EXT_VALUE_REGEXP.exec(str)
if (!match) {
throw new TypeError('invalid extended field value')
@@ -261,14 +274,14 @@ function decodefield(str) {
var value
// to binary string
var binary = encoded.replace(hexEscapeReplaceRegExp, pdecode)
var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode)
switch (charset) {
case 'iso-8859-1':
value = getlatin1(binary)
break
case 'utf-8':
value = new Buffer(binary, 'binary').toString('utf8')
value = Buffer.from(binary, 'binary').toString('utf8')
break
default:
throw new TypeError('unsupported charset in extended field')
@@ -282,12 +295,12 @@ function decodefield(str) {
*
* @param {string} val
* @return {string}
* @api private
* @private
*/
function getlatin1(val) {
function getlatin1 (val) {
// simple Unicode -> ISO-8859-1 transformation
return String(val).replace(nonLatin1RegExp, '?')
return String(val).replace(NON_LATIN1_REGEXP, '?')
}
/**
@@ -295,15 +308,15 @@ function getlatin1(val) {
*
* @param {string} string
* @return {object}
* @api private
* @public
*/
function parse(string) {
function parse (string) {
if (!string || typeof string !== 'string') {
throw new TypeError('argument string is required')
}
var match = dispositionTypeRegExp.exec(string)
var match = DISPOSITION_TYPE_REGEXP.exec(string)
if (!match) {
throw new TypeError('invalid type format')
@@ -319,12 +332,12 @@ function parse(string) {
var value
// calculate index to start at
index = paramRegExp.lastIndex = match[0].substr(-1) === ';'
index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
? index - 1
: index
// match parameters
while (match = paramRegExp.exec(string)) {
while ((match = PARAM_REGEXP.exec(string))) {
if (match.index !== index) {
throw new TypeError('invalid parameter format')
}
@@ -357,7 +370,7 @@ function parse(string) {
// remove quotes and escapes
value = value
.substr(1, value.length - 2)
.replace(qescRegExp, '$1')
.replace(QESC_REGEXP, '$1')
}
params[key] = value
@@ -376,10 +389,10 @@ function parse(string) {
* @param {string} str
* @param {string} hex
* @return {string}
* @api private
* @private
*/
function pdecode(str, hex) {
function pdecode (str, hex) {
return String.fromCharCode(parseInt(hex, 16))
}
@@ -388,17 +401,14 @@ function pdecode(str, hex) {
*
* @param {string} char
* @return {string}
* @api private
* @private
*/
function pencode(char) {
var hex = String(char)
function pencode (char) {
return '%' + String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
}
/**
@@ -406,13 +416,13 @@ function pencode(char) {
*
* @param {string} val
* @return {string}
* @api private
* @private
*/
function qstring(val) {
function qstring (val) {
var str = String(val)
return '"' + str.replace(quoteRegExp, '\\$1') + '"'
return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
}
/**
@@ -420,24 +430,29 @@ function qstring(val) {
*
* @param {string} val
* @return {string}
* @api private
* @private
*/
function ustring(val) {
function ustring (val) {
var str = String(val)
// percent encode as UTF-8
var encoded = encodeURIComponent(str)
.replace(encodeUriAttrCharRegExp, pencode)
.replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)
return 'UTF-8\'\'' + encoded
}
/**
* Class for parsed Content-Disposition header for v8 optimization
*
* @public
* @param {string} type
* @param {object} parameters
* @constructor
*/
function ContentDisposition(type, parameters) {
function ContentDisposition (type, parameters) {
this.type = type
this.parameters = parameters
}