From 019c4302ad86fd6981e8abc90cd8cb58003b662c Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 8 Dec 2024 22:36:02 +0100 Subject: Handle tiny files gracefully Lua detection functions used to cause fatal errors on failure to read. We could also reconsider treating detection errors as fatal. --- plugins/gzip.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/gzip.lua') diff --git a/plugins/gzip.lua b/plugins/gzip.lua index 4d8bf15..ae5ccb6 100644 --- a/plugins/gzip.lua +++ b/plugins/gzip.lua @@ -16,7 +16,7 @@ -- local detect = function (c) - return c:read (2) == "\x1f\x8b" + return #c >= 2 and c:read (2) == "\x1f\x8b" end local function latin1_to_utf8 (s) -- cgit v1.2.3-70-g09d2