Skip to content

Commit 4523d02

Browse files
authored
Alter mime type (#1599)
* Add a "default" MIME type for browser sniffing * Apparently some current browsers only push/sniff this now. Nothing like not following standards \*eyeroll\* * Older browsers still push/sniff `application/` and should retain some compatibility regardless of the state of the browsers interpretation of IANA * Converting to a switch casing... this is likely to be argued about forever... so make it prettier than `if..else` for change tracking Refs: * https://tools.ietf.org/html/rfc4329#page-9 *(IANA ... note the obsolete for `text\javascript`)* * https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types#JavaScript_types *(Note the contradiction)* * https://openuserjs.org/discuss/Selected_file_is_not_JavaScript. *(Report)* Applies to #872 * Remove Opera Presto MIME type * Since this was removed with the TLSv1 EOL Applies to #1599 #1430
1 parent cef73cb commit 4523d02

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

controllers/user.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,14 +1679,16 @@ exports.uploadScript = function (aReq, aRes, aNext) {
16791679
}
16801680

16811681
// Reject non-js file
1682-
if (!(script.type === 'application/javascript'
1683-
|| script.type === 'application/x-javascript')) {
1684-
1685-
statusCodePage(aReq, aRes, aNext, {
1686-
statusCode: 400,
1687-
statusMessage: 'Selected file is not JavaScript.'
1688-
});
1689-
return;
1682+
switch (script.type) {
1683+
case 'application/javascript': // #1599
1684+
case 'text/javascript': // Default
1685+
break; // Acceptable
1686+
default:
1687+
statusCodePage(aReq, aRes, aNext, {
1688+
statusCode: 400,
1689+
statusMessage: 'Selected file is not JavaScript.'
1690+
});
1691+
return;
16901692
}
16911693

16921694
// Reject huge file

0 commit comments

Comments
 (0)