[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:
@@ -486,7 +486,8 @@ MIME_TYPES = {
|
|||||||
|
|
||||||
|
|
||||||
def _signature_html(s):
|
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
|
# https://en.wikipedia.org/wiki/List_of_file_signatures
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ SAMPLES = {
|
|||||||
("heic", b"????ftypheix"),
|
("heic", b"????ftypheix"),
|
||||||
("svg" , b"<?xml"),
|
("svg" , b"<?xml"),
|
||||||
("html", b"<!DOCTYPE html><html>...</html>"),
|
("html", b"<!DOCTYPE html><html>...</html>"),
|
||||||
|
("html", b" \n \n\r\t\n <!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