diff options
author | Luke <luke.wilde@live.co.uk> | 2021-03-11 03:54:36 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-11 08:30:02 +0100 |
commit | 4477a0d6fdf3afcecb1ff86d4cd83746950f6b20 (patch) | |
tree | 49a03c47e02e25e84ca3eddc522510115188e089 | |
parent | 929c90f8c8c38e9fa845c41e7530b3bdc4b4f128 (diff) | |
download | serenity-4477a0d6fdf3afcecb1ff86d4cd83746950f6b20.zip |
LibWeb: Remove FIXME in is_javascript_mime_type_essence_match
This was misleading. The spec just wants us to check a string matches
a string in the JavaScript MIME type essence list. It doesn't want us
to parse the string as a MIME type to then use its essence for the
check.
Renames "mime_type" to "string" to make this less misleading.
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 2498d5f167..a1247c5a47 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -106,12 +106,10 @@ void HTMLScriptElement::execute_script() } // https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match -static bool is_javascript_mime_type_essence_match(const String& mime_type) +static bool is_javascript_mime_type_essence_match(const String& string) { - // FIXME: This operates on the whole mime type, instead of just the essence. https://mimesniff.spec.whatwg.org/#mime-type-essence - // It'd probably be best to make a helper class for mime types, since there is a whole spec about mime types. - auto lowercase_mime_type = mime_type.to_lowercase(); - return lowercase_mime_type.is_one_of("application/ecmascript", "application/javascript", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", "text/javascript", "text/javascript1.0", "text/javascript1.1", "text/javascript1.2", "text/javascript1.3", "text/javascript1.4", "text/javascript1.5", "text/jscript", "text/livescript", "text/x-ecmascript", "text/x-javascript"); + auto lowercase_string = string.to_lowercase(); + return lowercase_string.is_one_of("application/ecmascript", "application/javascript", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", "text/javascript", "text/javascript1.0", "text/javascript1.1", "text/javascript1.2", "text/javascript1.3", "text/javascript1.4", "text/javascript1.5", "text/jscript", "text/livescript", "text/x-ecmascript", "text/x-javascript"); } // https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script |