]> granicus.if.org Git - php/commitdiff
Fix a case where we could have an encoding conversion exception thrown
authorAndrei Zmievski <andrei@php.net>
Mon, 27 Mar 2006 03:47:50 +0000 (03:47 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 27 Mar 2006 03:47:50 +0000 (03:47 +0000)
while building exception trace args!

Zend/zend_exceptions.c

index cf5a03824c6ba5ba78dedd130a268abc29559826..a070ee296fc0f9a382f40f9df6e36706bdf61a8d 100644 (file)
@@ -385,6 +385,13 @@ static int _build_trace_args(zval **arg, int num_args, va_list args, zend_hash_k
                }
                case IS_UNICODE: {
                        int l_added;
+                       /*
+                        * We do not want to apply current error mode here, since
+                        * zend_make_printable_zval() uses output encoding converter.
+                        * Temporarily set output encoding converter to escape offending
+                        * chars with \uXXXX notation.
+                        */
+                       zend_set_converter_error_mode(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_FROM_UNICODE, ZEND_CONV_ERROR_ESCAPE_JAVA);
                        TRACE_APPEND_CHR('\'');
                        if (Z_USTRLEN_PP(arg) > 15) {
                                TRACE_APPEND_USTRL(Z_USTRVAL_PP(arg), 15);
@@ -396,6 +403,10 @@ static int _build_trace_args(zval **arg, int num_args, va_list args, zend_hash_k
                                TRACE_APPEND_STR("', ");
                                l_added += 3 + 1;
                        }
+                       /*
+                        * Reset output encoding converter error mode.
+                        */
+                       zend_set_converter_error_mode(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_FROM_UNICODE, UG(from_error_mode));
                        while (--l_added) {
                                if ((unsigned char)(*str)[*len - l_added] < 32) {
                                        (*str)[*len - l_added] = '?';