diff options
author | Sean Allred <code@seanallred.com> | 2018-01-28 18:49:24 -0600 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2018-01-28 18:49:24 -0600 |
commit | 07868a94759183341dad28cc13c9c3aa5c4832cb (patch) | |
tree | 5d88c6dbcb3685cfe4a85274a02fb80b881cd2cd | |
parent | 9488c03726464e4bd0ed0b448d203c5c7f8c212f (diff) |
Only test for gzipped data if the data is long enough
-rw-r--r-- | sx-encoding.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sx-encoding.el b/sx-encoding.el index 3ce1d6b..63a3464 100644 --- a/sx-encoding.el +++ b/sx-encoding.el @@ -152,8 +152,10 @@ numbers identifying the gzip file format. See URL `http://www.gzip.org/zlib/rfc-gzip.html'." ;; Credit: http://emacs.stackexchange.com/a/2978 - (equal (substring (string-as-unibyte data) 0 2) - (unibyte-string 31 139))) + (let ((unidata (string-as-unibyte data))) + (when (<= 2 (length unidata)) + (equal (substring unidata 0 2) + (unibyte-string 31 139))))) (defun sx-encoding-gzipped-buffer-p (buffer) "Check if BUFFER is gzip-compressed. |