com php-src: Fix #61362: Exception::getTraceAsString and ::__toString scramble Unicode: Zend/tests/bug 61362.phpt Zend/zend_exceptions.c

From: Date: Wed, 17 Jun 2015 20:31:07 +0000
Subject: com php-src: Fix #61362: Exception::getTraceAsString and ::__toString scramble Unicode: Zend/tests/bug 61362.phpt Zend/zend_exceptions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87343@lists.php.net to get a copy of this message
Commit: 653c869348b7626d43a30f67be9362fbcce10d2b Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 17 Jun 2015 16:56:04 +0200 Committer: Nikita Popov <nikic@php.net> Wed, 17 Jun 2015 22:31:07 +0200 Parents: 269acaa363cab7de8705b060ba9b1e32322fb0f4 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=653c869348b7626d43a30f67be9362fbcce10d2b Log: Fix #61362: Exception::getTraceAsString and ::__toString scramble Unicode The logic in smart_str_append_escaped() relies on unsigned values of c, so we have to declare it as such. Bugs: https://bugs.php.net/61362 Changed paths: A Zend/tests/bug61362.phpt M Zend/zend_exceptions.c Diff: diff --git a/Zend/tests/bug61362.phpt b/Zend/tests/bug61362.phpt new file mode 100644 index 0000000..af216b5 --- /dev/null +++ b/Zend/tests/bug61362.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #61362 (Exception::getTraceAsString, Exception::__toString not able to handle unicode) +--FILE-- +<?php +function test($arg){ + throw new Exception(); +} + +try { + test('тест'); +} +catch(Exception $e) { + echo $e->getTraceAsString(), "\n"; + echo (string)$e; +} +?> +--EXPECTF-- +#0 %s(%d): test('\xD1\x82\xD0\xB5\xD1\x81\xD1\x82') +#1 {main} +Exception in %s:%d +Stack trace: +#0 %s(%d): test('\xD1\x82\xD0\xB5\xD1\x81\xD1\x82') +#1 {main} diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index e731e21..cf18084 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -427,7 +427,7 @@ static void smart_str_append_escaped(smart_str *str, const char *s, size_t l) { str->s->len += len; for (i = 0; i < l; ++i) { - char c = s[i]; + unsigned char c = s[i]; if (c < 32 || c == '\\' || c > 126) { *res++ = '\\'; switch (c) {

« previous php.cvs (#87343) next »