scottmac                                 Mon, 27 Jul 2009 03:43:38 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=286385

Log:
MFH: Add error constant when json_encode detects an invalid UTF-8 sequence.

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/json/JSON_parser.h
    U   php/php-src/branches/PHP_5_3/ext/json/json.c

Modified: php/php-src/branches/PHP_5_3/ext/json/JSON_parser.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/json/JSON_parser.h 2009-07-27 03:31:00 UTC 
(rev 286384)
+++ php/php-src/branches/PHP_5_3/ext/json/JSON_parser.h 2009-07-27 03:43:38 UTC 
(rev 286385)
@@ -24,6 +24,7 @@
     PHP_JSON_ERROR_STATE_MISMATCH,
     PHP_JSON_ERROR_CTRL_CHAR,
     PHP_JSON_ERROR_SYNTAX,
+    PHP_JSON_ERROR_UTF8
 };

 extern JSON_parser new_JSON_parser(int depth);

Modified: php/php-src/branches/PHP_5_3/ext/json/json.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/json/json.c        2009-07-27 03:31:00 UTC 
(rev 286384)
+++ php/php-src/branches/PHP_5_3/ext/json/json.c        2009-07-27 03:43:38 UTC 
(rev 286385)
@@ -301,6 +301,7 @@
                        efree(utf16);
                }
                if (len < 0) {
+                       JSON_G(error_code) = PHP_JSON_ERROR_UTF8;
                        if (!PG(display_errors)) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Invalid UTF-8 sequence in argument");
                        }
@@ -413,6 +414,7 @@

 PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options 
TSRMLS_DC) /* {{{ */
 {
+       JSON_G(error_code) = PHP_JSON_ERROR_NONE;
        switch (Z_TYPE_P(val))
        {
                case IS_NULL:

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to