[dl:http] add MIME type and signature for .html files
This commit is contained in:
@@ -469,12 +469,19 @@ MIME_TYPES = {
|
|||||||
"application/x-pdf": "pdf",
|
"application/x-pdf": "pdf",
|
||||||
"application/x-shockwave-flash": "swf",
|
"application/x-shockwave-flash": "swf",
|
||||||
|
|
||||||
|
"text/html": "html",
|
||||||
|
|
||||||
"application/ogg": "ogg",
|
"application/ogg": "ogg",
|
||||||
# https://www.iana.org/assignments/media-types/model/obj
|
# https://www.iana.org/assignments/media-types/model/obj
|
||||||
"model/obj": "obj",
|
"model/obj": "obj",
|
||||||
"application/octet-stream": "bin",
|
"application/octet-stream": "bin",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _signature_html(s):
|
||||||
|
return b"<!doctype html".startswith(s[:14].lower())
|
||||||
|
|
||||||
|
|
||||||
# https://en.wikipedia.org/wiki/List_of_file_signatures
|
# https://en.wikipedia.org/wiki/List_of_file_signatures
|
||||||
SIGNATURE_CHECKS = {
|
SIGNATURE_CHECKS = {
|
||||||
"jpg" : lambda s: s[0:3] == b"\xFF\xD8\xFF",
|
"jpg" : lambda s: s[0:3] == b"\xFF\xD8\xFF",
|
||||||
@@ -505,6 +512,8 @@ SIGNATURE_CHECKS = {
|
|||||||
"7z" : lambda s: s[0:6] == b"\x37\x7A\xBC\xAF\x27\x1C",
|
"7z" : lambda s: s[0:6] == b"\x37\x7A\xBC\xAF\x27\x1C",
|
||||||
"pdf" : lambda s: s[0:5] == b"%PDF-",
|
"pdf" : lambda s: s[0:5] == b"%PDF-",
|
||||||
"swf" : lambda s: s[0:3] in (b"CWS", b"FWS"),
|
"swf" : lambda s: s[0:3] in (b"CWS", b"FWS"),
|
||||||
|
"html": _signature_html,
|
||||||
|
"htm" : _signature_html,
|
||||||
"blend": lambda s: s[0:7] == b"BLENDER",
|
"blend": lambda s: s[0:7] == b"BLENDER",
|
||||||
# unfortunately the Wavefront .obj format doesn't have a signature,
|
# unfortunately the Wavefront .obj format doesn't have a signature,
|
||||||
# so we check for the existence of Blender's comment
|
# so we check for the existence of Blender's comment
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ SAMPLES = {
|
|||||||
("heic", b"????ftypheis"),
|
("heic", b"????ftypheis"),
|
||||||
("heic", b"????ftypheix"),
|
("heic", b"????ftypheix"),
|
||||||
("svg" , b"<?xml"),
|
("svg" , b"<?xml"),
|
||||||
|
("html", b"<!DOCTYPE html><html>...</html>"),
|
||||||
("ico" , b"\x00\x00\x01\x00"),
|
("ico" , b"\x00\x00\x01\x00"),
|
||||||
("cur" , b"\x00\x00\x02\x00"),
|
("cur" , b"\x00\x00\x02\x00"),
|
||||||
("psd" , b"8BPS"),
|
("psd" , b"8BPS"),
|
||||||
|
|||||||
Reference in New Issue
Block a user