From 76e87c3e336b5e0a9c53dd6e0eec5ddc0508c868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 22 Jul 2016 16:39:12 +0200 Subject: [PATCH 1/2] Do not use mb_strlen on data we know are bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #12397 Signed-off-by: Michal Čihař --- libraries/DisplayResults.php | 2 +- libraries/Linter.php | 4 ++-- libraries/plugins/auth/AuthenticationCookie.php | 2 +- tbl_get_field.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/DisplayResults.php b/libraries/DisplayResults.php index 5dc8c3c877..a24ae288e4 100644 --- a/libraries/DisplayResults.php +++ b/libraries/DisplayResults.php @@ -5250,7 +5250,7 @@ class DisplayResults if (isset($content)) { - $size = mb_strlen($content, '8bit'); + $size = strlen($content); $display_size = Util::formatByteDown($size, 3, 1); $result .= ' - ' . $display_size[0] . ' ' . $display_size[1]; diff --git a/libraries/Linter.php b/libraries/Linter.php index 5d0dd49515..422141e615 100644 --- a/libraries/Linter.php +++ b/libraries/Linter.php @@ -38,7 +38,7 @@ class Linter $str = new UtfString($str); } - // The reason for using the '8bit' parameter is that the length + // The reason for using the strlen is that the length // required is the length in bytes, not characters. // // Given the following string: `????+`, where `?` represents a @@ -51,7 +51,7 @@ class Linter // (which is actually a new line) aren't going to be processed at // all. $len = ($str instanceof UtfString) ? - $str->length() : mb_strlen($len, '8bit'); + $str->length() : strlen($len); $lines = array(0); for ($i = 0; $i < $len; ++$i) { diff --git a/libraries/plugins/auth/AuthenticationCookie.php b/libraries/plugins/auth/AuthenticationCookie.php index 8d753cd7a3..c77dc0f238 100644 --- a/libraries/plugins/auth/AuthenticationCookie.php +++ b/libraries/plugins/auth/AuthenticationCookie.php @@ -712,7 +712,7 @@ class AuthenticationCookie extends AuthenticationPlugin true ); } - if (mb_strlen($this->_cookie_iv, '8bit') < $this->getIVSize()) { + if (strlen($this->_cookie_iv) < $this->getIVSize()) { $this->createIV(); } diff --git a/tbl_get_field.php b/tbl_get_field.php index 3e21c870aa..95f8b67b43 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -52,6 +52,6 @@ if ($result === false) { PMA_downloadHeader( $table . '-' . $_GET['transform_key'] . '.bin', PMA_detectMIME($result), - mb_strlen($result, '8bit') + strlen($result) ); echo $result; From 61150656df98de9be65bd5d4182c36950e74318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 22 Jul 2016 16:40:53 +0200 Subject: [PATCH 2/2] Fixed invalid Content-Length in some HTTP responses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use strlen for calculating HTTP response size, we're interested in bytes not utf-8 chars. Issue #12397 Signed-off-by: Michal Čihař --- ChangeLog | 1 + file_echo.php | 2 +- libraries/PDF.php | 2 +- libraries/plugins/schema/dia/Dia.php | 2 +- libraries/plugins/schema/eps/Eps.php | 2 +- libraries/plugins/schema/svg/Svg.php | 2 +- libraries/tracking.lib.php | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc1653d740..a6ce8b1f2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ phpMyAdmin - ChangeLog 4.6.4 (not yet released) - issue Include X-Robots-Tag header in responses - issue Enfornce numeric field length when creating table +- issue Fixed invalid Content-Length in some HTTP responses 4.6.3 (2016-06-23) - issue #12249 Fixed cookie path on Windows diff --git a/file_echo.php b/file_echo.php index 7c9374b9eb..918e5b046c 100644 --- a/file_echo.php +++ b/file_echo.php @@ -56,7 +56,7 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) { PMA_downloadHeader( $filename, $_REQUEST['type'], - mb_strlen($data) + strlen($data) ); /* Send data */ diff --git a/libraries/PDF.php b/libraries/PDF.php index 4858d7ce29..fb690c6f85 100644 --- a/libraries/PDF.php +++ b/libraries/PDF.php @@ -143,7 +143,7 @@ class PDF extends TCPDF PMA_downloadHeader( $filename, 'application/pdf', - mb_strlen($pdfData) + strlen($pdfData) ); echo $pdfData; } diff --git a/libraries/plugins/schema/dia/Dia.php b/libraries/plugins/schema/dia/Dia.php index f6793d400a..4aad6e067f 100644 --- a/libraries/plugins/schema/dia/Dia.php +++ b/libraries/plugins/schema/dia/Dia.php @@ -181,7 +181,7 @@ class Dia extends XMLWriter PMA_downloadHeader( $fileName, 'application/x-dia-diagram', - mb_strlen($output) + strlen($output) ); print $output; } diff --git a/libraries/plugins/schema/eps/Eps.php b/libraries/plugins/schema/eps/Eps.php index 42ec3a0171..de39521d6f 100644 --- a/libraries/plugins/schema/eps/Eps.php +++ b/libraries/plugins/schema/eps/Eps.php @@ -270,7 +270,7 @@ class Eps PMA_downloadHeader( $fileName, 'image/x-eps', - mb_strlen($output) + strlen($output) ); print $output; } diff --git a/libraries/plugins/schema/svg/Svg.php b/libraries/plugins/schema/svg/Svg.php index d7a4cc9358..0ea3c90adf 100644 --- a/libraries/plugins/schema/svg/Svg.php +++ b/libraries/plugins/schema/svg/Svg.php @@ -193,7 +193,7 @@ class Svg extends XMLWriter PMA_downloadHeader( $fileName, 'image/svg+xml', - mb_strlen($output) + strlen($output) ); print $output; } diff --git a/libraries/tracking.lib.php b/libraries/tracking.lib.php index 6fc9f4253b..09fb33edc2 100644 --- a/libraries/tracking.lib.php +++ b/libraries/tracking.lib.php @@ -1197,7 +1197,7 @@ function PMA_exportAsFileDownload($entries) PMA_downloadHeader( $filename, 'text/x-sql', - mb_strlen($dump) + strlen($dump) ); echo $dump;