[dl:http] improve HTML signature check (#7697)

https://github.com/mikf/gallery-dl/issues/7697#issuecomment-2990734451

ignore leading whitespace
This commit is contained in:
Mike Fährmann
2025-06-20 14:39:32 +02:00
parent dba45923c8
commit bcfce6b7db
2 changed files with 3 additions and 1 deletions

View File

@@ -486,7 +486,8 @@ MIME_TYPES = {
def _signature_html(s):
return b"<!doctype html".startswith(s[:14].lower())
s = s[:14].lstrip()
return s and b"<!doctype html".startswith(s.lower())
# https://en.wikipedia.org/wiki/List_of_file_signatures

View File

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