Skip to content

Servo's implementation of Sniffing in a style context #207

@TimvdLippe

Description

@TimvdLippe

What is the issue with the MIME Sniffing Standard?

In servo/servo#42037 I have updated Servo's mime classifier to handle a style context. It took a bit to figure out what was the magic incantation, but eventually I ended up with something small that appears to be passing WPT:

supplied_type.clone().unwrap_or_else(|| {
    if no_sniff_flag == NoSniffFlag::On {
        mime::APPLICATION_OCTET_STREAM
    } else {
        mime::TEXT_CSS
    }
})

In other words:

  1. We take the supplied type if it exists
  2. If it doesn't exist and nosniff is passed, we return a dummy value
  3. We fallback to text/css

Note that when an invalid Mime type is passed (text/invalid or broken), then it becomes None, hence we consider it as "doesn't exist".

Not sure what the status of this spec is and whether folks are interested in speccing the "Sniffing in a style context", but hopefully it is useful to know what Servo had to do.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions