[dl:http] add MIME type and signature for .html files

This commit is contained in:
Mike Fährmann
2025-06-12 21:16:34 +02:00
parent e41c317039
commit 8b6bc54e95
2 changed files with 10 additions and 0 deletions

View File

@@ -469,12 +469,19 @@ MIME_TYPES = {
"application/x-pdf": "pdf",
"application/x-shockwave-flash": "swf",
"text/html": "html",
"application/ogg": "ogg",
# https://www.iana.org/assignments/media-types/model/obj
"model/obj": "obj",
"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
SIGNATURE_CHECKS = {
"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",
"pdf" : lambda s: s[0:5] == b"%PDF-",
"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",
# unfortunately the Wavefront .obj format doesn't have a signature,
# so we check for the existence of Blender's comment

View File

@@ -369,6 +369,7 @@ SAMPLES = {
("heic", b"????ftypheis"),
("heic", b"????ftypheix"),
("svg" , b"<?xml"),
("html", b"<!DOCTYPE html><html>...</html>"),
("ico" , b"\x00\x00\x01\x00"),
("cur" , b"\x00\x00\x02\x00"),
("psd" , b"8BPS"),