- Imap:
. Fixed Bug #63126 DISABLE_AUTHENTICATOR ignores array (Remi)
+- Json:
+ . Fixed bug #63588 use php_next_utf8_char and remove duplicate
+ implementation. (Remi)
+
- mysqli:
. Fixed bug #63361 missing header. (Remi)
AC_DEFINE([HAVE_JSON],1 ,[whether to enable JavaScript Object Serialization support])
AC_HEADER_STDC
- PHP_NEW_EXTENSION(json, json.c utf8_to_utf16.c utf8_decode.c JSON_parser.c, $ext_shared)
+ PHP_NEW_EXTENSION(json, json.c utf8_decode.c JSON_parser.c, $ext_shared)
PHP_INSTALL_HEADERS([ext/json], [php_json.h])
PHP_SUBST(JSON_SHARED_LIBADD)
fi
if (PHP_JSON != "no") {
EXTENSION('json', 'json.c', PHP_JSON_SHARED, "");
- ADD_SOURCES(configure_module_dirname, "JSON_parser.c utf8_decode.c utf8_to_utf16.c", "json");
+ ADD_SOURCES(configure_module_dirname, "JSON_parser.c utf8_decode.c", "json");
PHP_INSTALL_HEADERS("ext/json/", "php_json.h");
}
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
+#include "ext/standard/html.h"
#include "ext/standard/php_smart_str.h"
-#include "utf8_to_utf16.h"
#include "JSON_parser.h"
#include "php_json.h"
#include <zend_exceptions.h>
}
/* }}} */
+static int json_utf8_to_utf16(unsigned short *utf16, char utf8[], int len) /* {{{ */
+{
+ size_t pos = 0, us;
+ int j, status;
+
+ for (j=0 ; pos < len ; j++) {
+ us = php_next_utf8_char((const unsigned char *)utf8, len, &pos, &status);
+ if (status != SUCCESS) {
+ return -1;
+ }
+ if (utf16) {
+ /* From http://en.wikipedia.org/wiki/UTF16 */
+ if (us >= 0x10000) {
+ us -= 0x10000;
+ utf16[j++] = (unsigned short)((us >> 10) | 0xd800);
+ utf16[j] = (unsigned short)((us & 0x3ff) | 0xdc00);
+ } else {
+ utf16[j] = (unsigned short)us;
+ }
+ }
+ }
+ return j;
+}
+/* }}} */
+
+
#define REVERSE16(us) (((us & 0xf) << 12) | (((us >> 4) & 0xf) << 8) | (((us >> 8) & 0xf) << 4) | ((us >> 12) & 0xf))
static void json_escape_string(smart_str *buf, char *s, int len, int options TSRMLS_DC) /* {{{ */
}
utf16 = (options & PHP_JSON_UNESCAPED_UNICODE) ? NULL : (unsigned short *) safe_emalloc(len, sizeof(unsigned short), 0);
- ulen = utf8_to_utf16(utf16, s, len);
+ ulen = json_utf8_to_utf16(utf16, s, len);
if (ulen <= 0) {
if (utf16) {
efree(utf16);
utf16 = (unsigned short *) safe_emalloc((str_len+1), sizeof(unsigned short), 1);
- utf16_len = utf8_to_utf16(utf16, str, str_len);
+ utf16_len = json_utf8_to_utf16(utf16, str, str_len);
if (utf16_len <= 0) {
if (utf16) {
efree(utf16);
+++ /dev/null
-/* utf8_to_utf16.c */
-
-/* 2005-12-25 */
-
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-#include "utf8_to_utf16.h"
-#include "utf8_decode.h"
-
-int
-utf8_to_utf16(unsigned short *w, char p[], int length)
-{
- int c;
- int the_index = 0;
- json_utf8_decode utf8;
-
- utf8_decode_init(&utf8, p, length);
- for (;;) {
- c = utf8_decode_next(&utf8);
- if (c < 0) {
- return (c == UTF8_END) ? the_index : UTF8_ERROR;
- }
- if (c < 0x10000) {
- if (w) {
- w[the_index] = (unsigned short)c;
- }
- the_index += 1;
- } else {
- c -= 0x10000;
- if (w) {
- w[the_index] = (unsigned short)(0xD800 | (c >> 10));
- w[the_index + 1] = (unsigned short)(0xDC00 | (c & 0x3FF));
- }
- the_index += 2;
- }
- }
-}
+++ /dev/null
-/* utf8_to_utf16.h */
-
-extern int utf8_to_utf16(unsigned short *w, char p[], int length);