From c2ad6549fb337ce707e04aa441c9b492171a3b9d Mon Sep 17 00:00:00 2001 From: yzrh Date: Sun, 25 Dec 2022 18:03:01 +0000 Subject: Handle headless HN and page with no image. Signed-off-by: yzrh --- src/cnki_zlib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/cnki_zlib.c') diff --git a/src/cnki_zlib.c b/src/cnki_zlib.c index edff141..075456b 100644 --- a/src/cnki_zlib.c +++ b/src/cnki_zlib.c @@ -13,12 +13,17 @@ int cnki_zlib(char **dst, int *dst_size, const char * restrict src, int src_size) { + uint8_t padding = 0; int32_t size; - memcpy(&size, src + 20, 4); + + if (strncmp(src + 8, "COMPRESSTEXT", 12) == 0) + padding = 8; + + memcpy(&size, src + 12 + padding, 4); *dst_size = size; - if (strinflate(dst, size, src + 24, src_size - 24) != 0) + if (strinflate(dst, size, src + 16 + padding, src_size - 16 - padding) != 0) return 1; return 0; -- cgit v1.2.3