[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-07-14 22:59:03 +00:00
commit ef43072848
2 changed files with 12 additions and 9 deletions

View file

@ -1393,16 +1393,16 @@ _BINARY_CHAR_DIVISOR = 8
# text/*; matched by signature because their replacement-char density alone can
# be low (e.g. a PDF whose first chunk is mostly ASCII object/xref syntax).
_BINARY_MAGIC = (
b"%PDF-", # PDF
b"PK\x03\x04", # zip / docx / xlsx / pptx / epub / jar
b"%PDF-", # PDF
b"PK\x03\x04", # zip / docx / xlsx / pptx / epub / jar
b"\x89PNG\r\n\x1a\n", # PNG
b"\xff\xd8\xff", # JPEG
b"\xff\xd8\xff", # JPEG
b"GIF87a",
b"GIF89a",
b"\x1f\x8b", # gzip
b"BZh", # bzip2
b"\xfd7zXZ\x00", # xz
b"\x28\xb5\x2f\xfd", # zstd
b"\x1f\x8b", # gzip
b"BZh", # bzip2
b"\xfd7zXZ\x00", # xz
b"\x28\xb5\x2f\xfd", # zstd
)
@ -1413,6 +1413,7 @@ def _looks_binary(text: str) -> bool:
_MIN_BINARY_CHARS, len(text) // _BINARY_CHAR_DIVISOR
)
_USER_AGENTS = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",

View file

@ -148,8 +148,10 @@ def test_compression_mislabeled_as_text_caught_by_magic(monkeypatch, magic):
def test_latin1_text_without_charset_kept(monkeypatch):
# Accent-dense cp1252 text with no declared charset decodes to many U+FFFD as
# UTF-8; the cp1252 retry must keep it instead of dropping it as binary.
body = ("Muller lauft uber die Strasse: schoene, groesse. MARKERWORD ".replace("ue", "ü")
+ "äöüß éèà ") * 30
body = (
"Muller lauft uber die Strasse: schoene, groesse. MARKERWORD ".replace("ue", "ü")
+ "äöüß éèà "
) * 30
out = _fetch_with(monkeypatch, body.encode("cp1252"), "text/plain")
assert "binary content" not in out
assert "MARKERWORD" in out