bool ScriptElementData::shouldExecuteAsJavaScript() const { /* Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only javascript1.1 - javascript1.3. Mozilla 1.8 and WinIE 7 both accept javascript and livescript. WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. We want to accept all the values that either of these browsers accept, but not other values. */ String type = m_scriptElement->typeAttributeValue(); if (!type.isEmpty()) { if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower())) return false; } else { String language = m_scriptElement->languageAttributeValue(); if (!language.isEmpty() && !isSupportedJavaScriptLanguage(language)) return false; } // No type or language is specified, so we assume the script to be JavaScript. // We don't yet support setting event listeners via the 'for' attribute for scripts. // If there is such an attribute it's likely better to not execute the script than to do so // immediately and unconditionally. // FIXME: After <rdar://problem/4471751> / https://bugs.webkit.org/show_bug.cgi?id=16915 are resolved // and we support the for syntax in script tags, this check can be removed and we should just // return 'true' here. String forAttribute = m_scriptElement->forAttributeValue(); return forAttribute.isEmpty(); }
bool ScriptElementData::shouldExecuteAsJavaScript() const { /* Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only javascript1.1 - javascript1.3. Mozilla 1.8 and WinIE 7 both accept javascript and livescript. WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. We want to accept all the values that either of these browsers accept, but not other values. */ String type = m_scriptElement->typeAttributeValue(); if (!type.isEmpty()) return MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower()); String language = m_scriptElement->languageAttributeValue(); if (!language.isEmpty()) return isSupportedJavaScriptLanguage(language); // No type or language is specified, so we assume the script to be JavaScript return true; }