From 3aba5a938064a87146ab2f23472f1f47004028c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Urrutia?= Date: Thu, 26 Sep 2024 10:40:26 -0300 Subject: [PATCH] @tus/server: update reMimeType por compliance with RFC1341 --- packages/server/src/handlers/GetHandler.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/server/src/handlers/GetHandler.ts b/packages/server/src/handlers/GetHandler.ts index ec11bbe3..1900f0a4 100644 --- a/packages/server/src/handlers/GetHandler.ts +++ b/packages/server/src/handlers/GetHandler.ts @@ -9,7 +9,17 @@ import type {RouteHandler} from '../types' export class GetHandler extends BaseHandler { paths: Map = new Map() - reMimeType = /^[a-z]+\/[a-z0-9\-\+\.]+$/ + /** + * reMimeType is a RegExp for check mime-type form compliance with RFC1341 + * for support mime-type and extra parameters, for example: + * + * ``` + * text/plain; charset=utf-8 + * ``` + * + * See: https://datatracker.ietf.org/doc/html/rfc1341 (Page 6) + */ + reMimeType = /^(?:application|audio|example|font|haptics|image|message|model|multipart|text|video|x-(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+))\/([0-9A-Za-z!#$%&'*+.^_`|~-]+)((?:[ ]*;[ ]*[0-9A-Za-z!#$%&'*+.^_`|~-]+=(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+|"(?:[^"\\]|\.)*"))*)$/ /** * mimeInlineBrowserWhitelist is a set containing MIME types which should be