summaryrefslogtreecommitdiff
path: root/ext/mbstring
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mbstring')
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfilter.c50
-rw-r--r--ext/mbstring/mb_gpc.c4
-rw-r--r--ext/mbstring/mbstring.c6
-rw-r--r--ext/mbstring/mbstring.h4
-rw-r--r--ext/mbstring/oniguruma/regparse.c1
-rw-r--r--ext/mbstring/php_mbregex.c13
-rw-r--r--ext/mbstring/php_mbregex.h4
-rw-r--r--ext/mbstring/php_unicode.c2
-rw-r--r--ext/mbstring/php_unicode.h2
-rw-r--r--ext/mbstring/tests/bug40685.phpt20
-rw-r--r--ext/mbstring/tests/bug52931.phpt2
-rw-r--r--ext/mbstring/tests/empty_pattern.phpt18
12 files changed, 110 insertions, 16 deletions
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c
index 34e33644b..8f2c8bb14 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfilter.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c
@@ -2702,6 +2702,53 @@ collector_decode_htmlnumericentity(int c, void *data)
return c;
}
+int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
+{
+ struct collector_htmlnumericentity_data *pc = (struct collector_htmlnumericentity_data *)filter;
+ int n, s, r, d;
+
+ if (pc->status) {
+ switch (pc->status) {
+ case 1: /* '&' */
+ (*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
+ break;
+ case 2: /* '#' */
+ (*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
+ (*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
+ break;
+ case 3: /* '0'-'9' */
+ (*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
+ (*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
+
+ s = pc->cache;
+ r = 1;
+ n = pc->digit;
+ while (n > 0) {
+ r *= 10;
+ n--;
+ }
+ s %= r;
+ r /= 10;
+ while (r > 0) {
+ d = s/r;
+ s %= r;
+ r /= 10;
+ (*pc->decoder->filter_function)(mbfl_hexchar_table[d], pc->decoder);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ pc->status = 0;
+ pc->cache = 0;
+ pc->digit = 0;
+
+ return 0;
+}
+
mbfl_string *
mbfl_html_numeric_entity(
mbfl_string *string,
@@ -2739,7 +2786,8 @@ mbfl_html_numeric_entity(
encoder = mbfl_convert_filter_new(
string->no_encoding,
mbfl_no_encoding_wchar,
- collector_decode_htmlnumericentity, 0, &pc);
+ collector_decode_htmlnumericentity,
+ (int (*)(void*))mbfl_filt_decode_htmlnumericentity_flush, &pc);
}
if (pc.decoder == NULL || encoder == NULL) {
mbfl_convert_filter_delete(encoder);
diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c
index b6a681a59..70fbbb4e0 100644
--- a/ext/mbstring/mb_gpc.c
+++ b/ext/mbstring/mb_gpc.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mb_gpc.c 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: mb_gpc.c 321634 2012-01-01 13:15:04Z felipe $ */
/* {{{ includes */
#ifdef HAVE_CONFIG_H
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 7520ee171..51ff3fd6f 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c 313665 2011-07-25 11:42:53Z felipe $ */
+/* $Id: mbstring.c 321634 2012-01-01 13:15:04Z felipe $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -3017,7 +3017,7 @@ PHP_FUNCTION(mb_detect_encoding)
/* make encoding list */
list = NULL;
size = 0;
- if (ZEND_NUM_ARGS() >= 2 && Z_STRVAL_P(encoding_list)) {
+ if (ZEND_NUM_ARGS() >= 2 && !ZVAL_IS_NULL(encoding_list)) {
switch (Z_TYPE_P(encoding_list)) {
case IS_ARRAY:
if (!php_mb_parse_encoding_array(encoding_list, &list, &size, 0 TSRMLS_CC)) {
diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h
index ac5b35a9c..173bb6c44 100644
--- a/ext/mbstring/mbstring.h
+++ b/ext/mbstring/mbstring.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.h 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: mbstring.h 321634 2012-01-01 13:15:04Z felipe $ */
/*
* PHP 4 Multibyte String module "mbstring" (currently only for Japanese)
diff --git a/ext/mbstring/oniguruma/regparse.c b/ext/mbstring/oniguruma/regparse.c
index af5c8593e..abf2cc1cb 100644
--- a/ext/mbstring/oniguruma/regparse.c
+++ b/ext/mbstring/oniguruma/regparse.c
@@ -4980,6 +4980,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
CCLASS_SET_SHARE(&(NCCLASS(*np)));
new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key));
+ xmemcpy(new_key, &key, sizeof(type_cclass_key));
onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
(st_data_t )*np);
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 66dda4bcb..8c2fd7abd 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mbregex.c 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: php_mbregex.c 321634 2012-01-01 13:15:04Z felipe $ */
#ifdef HAVE_CONFIG_H
@@ -1245,14 +1245,19 @@ PHP_FUNCTION(mb_ereg_search_init)
{
size_t argc = ZEND_NUM_ARGS();
zval *arg_str;
- char *arg_pattern, *arg_options;
- int arg_pattern_len, arg_options_len;
+ char *arg_pattern = NULL, *arg_options = NULL;
+ int arg_pattern_len = 0, arg_options_len = 0;
OnigSyntaxType *syntax = NULL;
OnigOptionType option;
if (zend_parse_parameters(argc TSRMLS_CC, "z|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
return;
}
+
+ if (argc > 1 && arg_pattern_len == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty pattern");
+ RETURN_FALSE;
+ }
option = MBREX(regex_default_options);
syntax = MBREX(regex_default_syntax);
diff --git a/ext/mbstring/php_mbregex.h b/ext/mbstring/php_mbregex.h
index 9819b7c79..2fac06e35 100644
--- a/ext/mbstring/php_mbregex.h
+++ b/ext/mbstring/php_mbregex.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mbregex.h 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: php_mbregex.h 321634 2012-01-01 13:15:04Z felipe $ */
#ifndef _PHP_MBREGEX_H
#define _PHP_MBREGEX_H
diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c
index cb04e55d2..99430d1aa 100644
--- a/ext/mbstring/php_unicode.c
+++ b/ext/mbstring/php_unicode.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h
index 2b64f973e..015073afd 100644
--- a/ext/mbstring/php_unicode.h
+++ b/ext/mbstring/php_unicode.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/mbstring/tests/bug40685.phpt b/ext/mbstring/tests/bug40685.phpt
new file mode 100644
index 000000000..420b916bc
--- /dev/null
+++ b/ext/mbstring/tests/bug40685.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #40685 (mb_decode_numericentity() removes '&' in the string)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+$map = array(0, 0x10FFFF, 0, 0xFFFFFF);
+var_dump(mb_decode_numericentity('&', $map, 'UTF-8'));
+var_dump(mb_decode_numericentity('&&&', $map, 'UTF-8'));
+var_dump(mb_decode_numericentity('&#', $map, 'UTF-8'));
+var_dump(mb_decode_numericentity('&#61', $map, 'UTF-8'));
+var_dump(mb_decode_numericentity('&#61;', $map, 'UTF-8'));
+?>
+--EXPECTF--
+string(1) "&"
+string(3) "&&&"
+string(2) "&#"
+string(4) "&#61"
+string(1) "="
+
diff --git a/ext/mbstring/tests/bug52931.phpt b/ext/mbstring/tests/bug52931.phpt
index 9669d884c..52efd03de 100644
--- a/ext/mbstring/tests/bug52931.phpt
+++ b/ext/mbstring/tests/bug52931.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #52931 (strripos not overloaded with function overloading enabled)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--INI--
mbstring.func_overload = 7
mbstring.internal_encoding = utf-8
diff --git a/ext/mbstring/tests/empty_pattern.phpt b/ext/mbstring/tests/empty_pattern.phpt
new file mode 100644
index 000000000..e395604f8
--- /dev/null
+++ b/ext/mbstring/tests/empty_pattern.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Check for empty pattern
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+
+mb_ereg_search_init("","","");
+mb_split("","");
+mb_ereg_search_regs();
+
+?>
+--EXPECTF--
+Warning: mb_ereg_search_init(): Empty pattern in %s on line %d
+
+Warning: mb_split(): Empty regular expression in %s on line %d
+
+Warning: mb_ereg_search_regs(): No regex given in %s on line %d