summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2014-02-20 17:48:38 +0100
committerBob Weinand <bobwei9@hotmail.com>2014-02-20 17:48:38 +0100
commitca313caa4bb84d86c4f0b37493791fe27ee869af (patch)
tree279f50338922dae7ad9dd236d0a2bae324b3619c /Zend/zend_exceptions.c
parent143bb29c1ac3f959f44b8fe59adef4d1840bc393 (diff)
parentafa03a470ef90a53f2b59a8175f77afdb6b5a651 (diff)
downloadphp-git-ca313caa4bb84d86c4f0b37493791fe27ee869af.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r--Zend/zend_exceptions.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index e973a67a92..9b7d3689c6 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -360,6 +360,11 @@ ZEND_METHOD(error_exception, getSeverity)
} \
}
+
+#define TRACE_ARG_APPEND(vallen) \
+ *str = (char*)erealloc(*str, *len + 1 + vallen); \
+ memcpy((*str) + *len - l_added + 1 + vallen, (*str) + *len - l_added + 1, l_added);
+
/* }}} */
static int _build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
@@ -371,7 +376,7 @@ static int _build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list args, z
len = va_arg(args, int*);
/* the trivial way would be to do:
- * conver_to_string_ex(arg);
+ * convert_to_string_ex(arg);
* append it and kill the now tmp arg.
* but that could cause some E_NOTICE and also damn long lines.
*/
@@ -394,8 +399,58 @@ static int _build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list args, z
l_added += 3 + 1;
}
while (--l_added) {
- if ((*str)[*len - l_added] < 32) {
- (*str)[*len - l_added] = '?';
+ unsigned char chr = (*str)[*len - l_added];
+ if (chr < 32 || chr == '\\' || chr > 126) {
+ (*str)[*len - l_added] = '\\';
+
+ switch (chr) {
+ case '\n':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 'n';
+ break;
+ case '\r':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 'r';
+ break;
+ case '\t':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 't';
+ break;
+ case '\f':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 'f';
+ break;
+ case '\v':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 'v';
+ break;
+#ifndef PHP_WIN32
+ case '\e':
+#else
+ case VK_ESCAPE:
+#endif
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = 'e';
+ break;
+ case '\\':
+ TRACE_ARG_APPEND(1);
+ (*str)[++(*len) - l_added] = '\\';
+ break;
+ default:
+ TRACE_ARG_APPEND(3);
+ (*str)[*len - l_added + 1] = 'x';
+ if ((chr >> 4) < 10) {
+ (*str)[*len - l_added + 2] = (chr >> 4) + '0';
+ } else {
+ (*str)[*len - l_added + 2] = (chr >> 4) + 'A' - 10;
+ }
+ if (chr % 16 < 10) {
+ (*str)[*len - l_added + 3] = chr % 16 + '0';
+ } else {
+ (*str)[*len - l_added + 3] = chr % 16 + 'A' - 10;
+ }
+ *len += 3;
+ }
}
}
break;