Пример #1
0
bool CSSStyleSheetResource::canUseSheet(MIMETypeCheck mimeTypeCheck) const {
    if (errorOccurred())
        return false;

    // This check exactly matches Firefox. Note that we grab the Content-Type
    // header directly because we want to see what the value is BEFORE content
    // sniffing. Firefox does this by setting a "type hint" on the channel. This
    // implementation should be observationally equivalent.
    //
    // This code defaults to allowing the stylesheet for non-HTTP protocols so
    // folks can use standards mode for local HTML documents.
    if (mimeTypeCheck == MIMETypeCheck::Lax)
        return true;
    AtomicString contentType = httpContentType();
    return contentType.isEmpty() || equalIgnoringCase(contentType, "text/css") ||
           equalIgnoringCase(contentType, "application/x-unknown-content-type");
}
Пример #2
0
bool ScriptResource::mimeTypeAllowedByNosniff() const {
  return parseContentTypeOptionsHeader(response().httpHeaderField(
             HTTPNames::X_Content_Type_Options)) != ContentTypeOptionsNosniff ||
         MIMETypeRegistry::isSupportedJavaScriptMIMEType(httpContentType());
}