diff --git a/mimesniff.bs b/mimesniff.bs index c5a5c84..b5af2f0 100644 --- a/mimesniff.bs +++ b/mimesniff.bs @@ -1806,6 +1806,12 @@ algorithm: user agents must use the following MIME type sniffing algorithm:
    +
  1. + If the supplied MIME type is an XML MIME type or HTML MIME type, the + computed MIME type is the supplied MIME type. + + Abort these steps. +
  2. If the supplied MIME type is undefined or if the supplied MIME type's essence is @@ -1826,17 +1832,6 @@ algorithm: rules for distinguishing if a resource is text or binary and abort these steps. -
  3. - If the supplied MIME type is an XML MIME type, the - computed MIME type is the supplied MIME type. - - Abort these steps. - -
  4. - If the supplied MIME type's essence is "text/html", - execute the rules for distinguishing if a resource is a feed or HTML and - abort these steps. -
  5. If the supplied MIME type is an image MIME type supported by the user agent, let matched-type be @@ -2264,9 +2259,6 @@ type: -

    - What about feeds? -

  6. Execute the following steps for each row row in the following table: @@ -2466,279 +2458,6 @@ type: -

    Sniffing a mislabeled feed

    - -

    - To determine whether a feed has been mislabeled as HTML, execute the - following rules for distinguishing if a resource is a feed or - HTML: - -

      -
    1. - Let sequence be the resource header, where - sequence[s] is byte s in - sequence and sequence[0] is the first - byte in sequence. - -
    2. - Let length be the number of bytes in - sequence. - -
    3. - Initialize s to 0. - -
    4. - If length is greater than or equal to 3 and the three - bytes from sequence[0] to - sequence[2] are equal to 0xEF 0xBB 0xBF (UTF-8 BOM), increment - s by 3. - -
    5. - While s is less than length, continuously loop - through these steps: - -
        -
      1. - Enter loop L: - -
          -
        1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
        2. - If sequence[s] is equal to 0x3C - ("<"), increment s by 1 and exit loop - L. - -
        3. - If sequence[s] is not a whitespace - byte, the computed MIME type is the supplied - MIME type. - - Abort these steps. - -
        4. - Increment s by 1. -
        - -
      2. - Enter loop L: - -
          -
        1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
        2. - If length is greater than or equal to s + 3 and - the three bytes from - sequence[s] to - sequence[s + 2] are equal to 0x21 0x2D 0x2D - ("!--"), increment s by 3 and enter loop - M: - -
            -
          1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
          2. - If length is greater than or equal to s + 3 and - the three bytes from - sequence[s] to - sequence[s + 2] are equal to 0x2D 0x2D 0x3E - ("-->"), increment s by 3 and exit - loops M and L. - -
          3. - Increment s by 1. -
          - -
        3. - If length is greater than or equal to s + 1 and - sequence[s] is equal to 0x21 - ("!"), increment s by 1 and enter loop - M: - -
            -
          1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
          2. - If length is greater than or equal to s + 1 and - sequence[s] is equal to 0x3E - (">"), increment s by 1 and exit loops - M and L. - -
          3. - Increment s by 1. -
          - -
        4. - If length is greater than or equal to s + 1 and - sequence[s] is equal to 0x3F - ("?"), increment s by 1 and enter loop - M: - -
            -
          1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
          2. - If length is greater than or equal to s + 2 and - the two bytes from - sequence[s] to - sequence[s + 1] are equal to 0x3F 0x3E - ("?>"), increment s by 2 and exit loops - M and L. - -
          3. - Increment s by 1. -
          - -
        5. - If length is greater than or equal to s + 3 and - the three bytes from - sequence[s] to - sequence[s + 2] are equal to 0x72 0x73 0x73 - ("rss"), the computed MIME type is - "application/rss+xml". - - Abort these steps. - -
        6. - If length is greater than or equal to s + 4 and - the four bytes from - sequence[s] to - sequence[s + 3] are equal to 0x66 0x65 0x65 0x64 - ("feed"), the computed MIME type is - "application/atom+xml". - - Abort these steps. - -
        7. - If length is greater than or equal to s + 7 and - the seven bytes from - sequence[s] to - sequence[s + 6] are equal to 0x72 0x64 0x66 0x3A - 0x52 0x44 0x46 ("rdf:RDF"), increment s - by 7 and enter loop M: - -
            -
          1. - If sequence[s] is undefined, the computed - MIME type is the supplied MIME type. - - Abort these steps. - -
          2. - If length is greater than or equal to s + 24 - and the twenty-four bytes from - sequence[s] to - sequence[s + 23] are equal to 0x68 0x74 0x74 - 0x70 0x3A 0x2F 0x2F 0x70 0x75 0x72 0x6C 0x2E 0x6F 0x72 0x67 0x2F 0x72 - 0x73 0x73 0x2F 0x31 0x2E 0x30 0x2F - ("http://purl.org/rss/1.0/"), increment - s by 24 and enter loop N: - -
              -
            1. - If sequence[s] is undefined, the - computed MIME type is the supplied MIME - type. - - Abort these steps. - -
            2. - If length is greater than or equal to s + 43 - and the forty-three bytes from - sequence[s] to - sequence[s + 42] are equal to 0x68 0x74 0x74 - 0x70 0x3A 0x2F 0x2F 0x77 0x77 0x77 0x2E 0x77 0x33 0x2E 0x6F 0x72 - 0x67 0x2F 0x31 0x39 0x39 0x39 0x2F 0x30 0x32 0x2F 0x32 0x32 0x2D - 0x72 0x64 0x66 0x2D 0x73 0x79 0x6E 0x74 0x61 0x78 0x2D 0x6E 0x73 - 0x23 - ("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), - the computed MIME type is - "application/rss+xml". - - Abort these steps. - -
            3. - Increment s by 1. -
            - -
          3. - If length is greater than or equal to s + 24 - and the twenty-four bytes from - sequence[s] to - sequence[s + 23] are equal to 0x68 0x74 0x74 - 0x70 0x3A 0x2F 0x2F 0x77 0x77 0x77 0x2E 0x77 0x33 0x2E 0x6F 0x72 0x67 - 0x2F 0x31 0x39 0x39 0x39 0x2F 0x30 0x32 0x2F 0x32 0x32 0x2D 0x72 0x64 - 0x66 0x2D 0x73 0x79 0x6E 0x74 0x61 0x78 0x2D 0x6E 0x73 0x23 - ("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), - increment s by 24 and enter loop N: - -
              -
            1. - If sequence[s] is undefined, the - computed MIME type is the supplied MIME - type. - - Abort these steps. - -
            2. - If length is greater than or equal to s + 43 - and the forty-three bytes from - sequence[s] to - sequence[s + 42] are equal to 0x68 0x74 0x74 - 0x70 0x3A 0x2F 0x2F 0x70 0x75 0x72 0x6C 0x2E 0x6F 0x72 0x67 0x2F - 0x72 0x73 0x73 0x2F 0x31 0x2E 0x30 0x2F - ("http://purl.org/rss/1.0/"), the computed - MIME type is "application/rss+xml". - - Abort these steps. - -
            3. - Increment s by 1. -
            - -
          4. - Increment s by 1. -
          - -
        8. - The computed MIME type is the supplied MIME - type. - - Abort these steps. -
        -
      - -
    6. - The computed MIME type is the supplied MIME type. -
    - -

    - It might be more efficient for the user agent to implement the rules - for distinguishing if a resource is a feed or HTML in parallel with - its algorithm for detecting the character encoding of an HTML document. - - -

    Context-specific sniffing