diff options
author | yzrh <yzrh@noema.org> | 2022-12-25 18:03:01 +0000 |
---|---|---|
committer | yzrh <yzrh@noema.org> | 2022-12-25 23:18:17 +0000 |
commit | c2ad6549fb337ce707e04aa441c9b492171a3b9d (patch) | |
tree | 611b43986a0c50d335ba69aafc8ace26cdcaffd3 /src/cnki_zlib.c | |
parent | d2826fa075544ada1fb9f530a375ef85f58c8ea0 (diff) | |
download | melon-c2ad6549fb337ce707e04aa441c9b492171a3b9d.tar.gz melon-c2ad6549fb337ce707e04aa441c9b492171a3b9d.tar.zst |
Handle headless HN and page with no image.
Signed-off-by: yzrh <yzrh@noema.org>
Diffstat (limited to 'src/cnki_zlib.c')
-rw-r--r-- | src/cnki_zlib.c | 9 |
1 files changed, 7 insertions, 2 deletions
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; |