Merge pull request #3678 from thelounge/renovate/file-type-13.x

Update dependency file-type to v13
This commit is contained in:
Pavel Djundik 2020-01-08 16:22:37 +02:00 committed by GitHub
commit 6164862af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 10 deletions

View File

@ -47,7 +47,7 @@
"cheerio": "1.0.0-rc.3", "cheerio": "1.0.0-rc.3",
"commander": "4.1.0", "commander": "4.1.0",
"express": "4.17.1", "express": "4.17.1",
"file-type": "12.4.2", "file-type": "13.0.2",
"filenamify": "4.1.0", "filenamify": "4.1.0",
"fs-extra": "8.1.0", "fs-extra": "8.1.0",
"got": "10.2.1", "got": "10.2.1",

View File

@ -54,7 +54,7 @@ class Uploader {
express.post("/uploads/new/:token", Uploader.routeUploadFile); express.post("/uploads/new/:token", Uploader.routeUploadFile);
} }
static routeGetFile(req, res) { static async routeGetFile(req, res) {
const name = req.params.name; const name = req.params.name;
const nameRegex = /^[0-9a-f]{16}$/; const nameRegex = /^[0-9a-f]{16}$/;
@ -66,7 +66,7 @@ class Uploader {
const folder = name.substring(0, 2); const folder = name.substring(0, 2);
const uploadPath = Helper.getFileUploadPath(); const uploadPath = Helper.getFileUploadPath();
const filePath = path.join(uploadPath, folder, name); const filePath = path.join(uploadPath, folder, name);
const detectedMimeType = Uploader.getFileType(filePath); const detectedMimeType = await Uploader.getFileType(filePath);
// doesn't exist // doesn't exist
if (detectedMimeType === null) { if (detectedMimeType === null) {
@ -232,12 +232,12 @@ class Uploader {
// Returns null if an error occurred (e.g. file not found) // Returns null if an error occurred (e.g. file not found)
// Returns a string with the type otherwise // Returns a string with the type otherwise
static getFileType(filePath) { static async getFileType(filePath) {
try { try {
const buffer = readChunk.sync(filePath, 0, fileType.minimumBytes); const buffer = readChunk.sync(filePath, 0, fileType.minimumBytes);
// returns {ext, mime} if found, null if not. // returns {ext, mime} if found, null if not.
const file = fileType(buffer); const file = await fileType.fromBuffer(buffer);
// if a file type was detected correctly, return it // if a file type was detected correctly, return it
if (file) { if (file) {

View File

@ -769,6 +769,11 @@
dependencies: dependencies:
defer-to-connect "^1.1.1" defer-to-connect "^1.1.1"
"@tokenizer/token@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@tokenizer/token/-/token-0.1.0.tgz#9ee92540c56ca02e997d65dd14645cf9438c3dcf"
integrity sha512-fXk7a5R+aE8bfDRbfT+xRG2evSatjbljGGSUflfQmqw555My8II/EWly2GmcHaqXF5HCMitBEfSNhCRZCrLGGg==
"@types/cacheable-request@^6.0.1": "@types/cacheable-request@^6.0.1":
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976" resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976"
@ -3477,10 +3482,15 @@ file-entry-cache@^5.0.1:
dependencies: dependencies:
flat-cache "^2.0.1" flat-cache "^2.0.1"
file-type@12.4.2: file-type@13.0.2:
version "12.4.2" version "13.0.2"
resolved "https://registry.yarnpkg.com/file-type/-/file-type-12.4.2.tgz#a344ea5664a1d01447ee7fb1b635f72feb6169d9" resolved "https://registry.yarnpkg.com/file-type/-/file-type-13.0.2.tgz#99baeffc3989e4fdb189534700b6b494e114da74"
integrity sha512-UssQP5ZgIOKelfsaB5CuGAL+Y+q7EmONuiwF3N5HAH0t27rvrttgi6Ra9k/+DVaY9UF6+ybxu5pOXLUdA8N7Vg== integrity sha512-7ZgM94zayCOwYUxUzsyI32TCd4cX1VepB75cqJR3DAnm4WS/lZKxc4LyhbBhCK71XPhZWKvLHD2voVcWeOv0MA==
dependencies:
readable-web-to-node-stream "^2.0.0"
strtok3 "^5.0.1"
token-types "^2.0.0"
typedarray-to-buffer "^3.1.5"
file-uri-to-path@1.0.0: file-uri-to-path@1.0.0:
version "1.0.0" version "1.0.0"
@ -4268,7 +4278,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1:
dependencies: dependencies:
postcss "^7.0.14" postcss "^7.0.14"
ieee754@^1.1.4: ieee754@^1.1.13, ieee754@^1.1.4:
version "1.1.13" version "1.1.13"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==
@ -6434,6 +6444,11 @@ pbkdf2@^3.0.3:
safe-buffer "^5.0.1" safe-buffer "^5.0.1"
sha.js "^2.4.8" sha.js "^2.4.8"
peek-readable@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/peek-readable/-/peek-readable-3.1.0.tgz#250b08b7de09db8573d7fd8ea475215bbff14348"
integrity sha512-KGuODSTV6hcgdZvDrIDBUkN0utcAVj1LL7FfGbM0viKTtCHmtZcuEJ+lGqsp0fTFkGqesdtemV2yUSMeyy3ddA==
performance-now@^2.1.0: performance-now@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@ -7516,6 +7531,11 @@ readable-stream@^3.1.1:
string_decoder "^1.1.1" string_decoder "^1.1.1"
util-deprecate "^1.0.1" util-deprecate "^1.0.1"
readable-web-to-node-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/readable-web-to-node-stream/-/readable-web-to-node-stream-2.0.0.tgz#751e632f466552ac0d5c440cc01470352f93c4b7"
integrity sha512-+oZJurc4hXpaaqsN68GoZGQAQIA3qr09Or4fqEsargABnbe5Aau8hFn6ISVleT3cpY/0n/8drn7huyyEvTbghA==
readdirp@^2.2.1: readdirp@^2.2.1:
version "2.2.1" version "2.2.1"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525"
@ -8542,6 +8562,15 @@ strip-outer@^1.0.1:
dependencies: dependencies:
escape-string-regexp "^1.0.2" escape-string-regexp "^1.0.2"
strtok3@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/strtok3/-/strtok3-5.0.1.tgz#f89e09fa024dff82e39c160faf8d8706c24e7d21"
integrity sha512-AWliiIjyb87onqO8pM+1Hozm+PPcR4YYIWbFUT5OKQ+tOMwgdT8HwJd/IS8v3/gKdAtE5aE2p3FhcWqryuZPLQ==
dependencies:
"@tokenizer/token" "^0.1.0"
debug "^4.1.1"
peek-readable "^3.1.0"
style-search@^0.1.0: style-search@^0.1.0:
version "0.1.0" version "0.1.0"
resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902"
@ -8865,6 +8894,14 @@ toidentifier@1.0.0:
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
token-types@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/token-types/-/token-types-2.0.0.tgz#b23618af744818299c6fbf125e0fdad98bab7e85"
integrity sha512-WWvu8sGK8/ZmGusekZJJ5NM6rRVTTDO7/bahz4NGiSDb/XsmdYBn6a1N/bymUHuWYTWeuLUg98wUzvE4jPdCZw==
dependencies:
"@tokenizer/token" "^0.1.0"
ieee754 "^1.1.13"
toposort@^2.0.2: toposort@^2.0.2:
version "2.0.2" version "2.0.2"
resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330"