From a27010c247fb4e6207e2a36b07d336846753acff Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 15 Mar 2017 09:43:26 +0100 Subject: [PATCH] Correctly change the compression buffer we send. For ie browser, we need to remove the two first bytes. If we make our buffer start two bytes after, we also need to reduce the size of the buffer by two bytes. Else we will read and send two extra junk bytes. Fix #15 --- src/server/kiwix-serve.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 9d241d4..482e9fc 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -167,7 +167,7 @@ bool compress_content(string &content, comprLen = COMPRESSOR_BUFFER_SIZE; compress(compr, &comprLen, (const Bytef*)(content.data()), contentLength); - if (comprLen > 2 && comprLen < contentLength) { + if (comprLen > 2 && comprLen < (contentLength+2)) { /* /!\ Internet Explorer has a bug with deflate compression. It can not handle the first two bytes (compression headers) @@ -175,6 +175,7 @@ bool compress_content(string &content, It has no incidence on other browsers See http://www.subbu.org/blog/2008/03/ie7-deflate-or-not and comments */ compr += 2; + comprLen -= 2; content = string((char *)compr, comprLen); contentLength = comprLen;