From c18129f319041571ecf4ffd087e30f0134426a8e Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Mon, 10 Oct 2022 16:30:00 +0200 Subject: [PATCH] use parseMimeType in normalizeType --- ext/web/09_file.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ext/web/09_file.js b/ext/web/09_file.js index d01858c922ed8e..21b6de1a4fff71 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -25,9 +25,7 @@ MathMax, MathMin, ObjectPrototypeIsPrototypeOf, - RegExpPrototypeTest, StringPrototypeCharAt, - StringPrototypeToLowerCase, StringPrototypeSlice, Symbol, SymbolFor, @@ -35,6 +33,7 @@ TypeError, Uint8Array, } = window.__bootstrap.primordials; + const mimesniff = window.__bootstrap.mimesniff; const consoleInternal = window.__bootstrap.console; // TODO(lucacasonato): this needs to not be hardcoded and instead depend on @@ -144,11 +143,8 @@ * @returns {string} */ function normalizeType(str) { - let normalizedType = str; - if (!RegExpPrototypeTest(/^[\x20-\x7E]*$/, str)) { - normalizedType = ""; - } - return StringPrototypeToLowerCase(normalizedType); + const mime = mimesniff.parseMimeType(str); + return mime !== null ? mimesniff.serializeMimeType(mime) : ""; } /**