Skip to content

Commit 2386f65

Browse files
committed
Always use PCRE for mbstring.http_output_conv_mimetypes
Instead of using either oniguruma or pcre depending on which is available. We always have PCRE, so use it. This ensures consistent behavior.
1 parent 7222315 commit 2386f65

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

ext/mbstring/mbstring.c

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "ext/standard/url.h"
3030
#include "main/php_output.h"
3131
#include "ext/standard/info.h"
32+
#include "ext/pcre/php_pcre.h"
3233

3334
#include "libmbfl/mbfl/mbfilter_8bit.h"
3435
#include "libmbfl/mbfl/mbfilter_pass.h"
@@ -52,23 +53,6 @@
5253

5354
#ifdef HAVE_MBREGEX
5455
# include "php_mbregex.h"
55-
# include "php_onig_compat.h"
56-
# include <oniguruma.h>
57-
# undef UChar
58-
# if !defined(ONIGURUMA_VERSION_INT) || ONIGURUMA_VERSION_INT < 60800
59-
typedef void OnigMatchParam;
60-
#define onig_new_match_param() (NULL)
61-
#define onig_initialize_match_param(x) (void)(x)
62-
#define onig_set_match_stack_limit_size_of_match_param(x, y)
63-
#define onig_set_retry_limit_in_match_of_match_param(x, y)
64-
#define onig_free_match_param(x)
65-
#define onig_search_with_param(reg, str, end, start, range, region, option, mp) \
66-
onig_search(reg, str, end, start, range, region, option)
67-
#define onig_match_with_param(re, str, end, at, region, option, mp) \
68-
onig_match(re, str, end, at, region, option)
69-
# endif
70-
#else
71-
# include "ext/pcre/php_pcre.h"
7256
#endif
7357

7458
#include "zend_multibyte.h"
@@ -513,60 +497,6 @@ static zend_multibyte_functions php_mb_zend_multibyte_functions = {
513497
};
514498
/* }}} */
515499

516-
static void *_php_mb_compile_regex(const char *pattern);
517-
static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len);
518-
static void _php_mb_free_regex(void *opaque);
519-
520-
#ifdef HAVE_MBREGEX
521-
/* {{{ _php_mb_compile_regex */
522-
static void *_php_mb_compile_regex(const char *pattern)
523-
{
524-
php_mb_regex_t *retval;
525-
OnigErrorInfo err_info;
526-
int err_code;
527-
528-
if ((err_code = onig_new(&retval,
529-
(const OnigUChar *)pattern,
530-
(const OnigUChar *)pattern + strlen(pattern),
531-
ONIG_OPTION_IGNORECASE | ONIG_OPTION_DONT_CAPTURE_GROUP,
532-
ONIG_ENCODING_ASCII, &OnigSyntaxPerl, &err_info))) {
533-
OnigUChar err_str[ONIG_MAX_ERROR_MESSAGE_LEN];
534-
onig_error_code_to_str(err_str, err_code, err_info);
535-
php_error_docref(NULL, E_WARNING, "%s: %s", pattern, err_str);
536-
retval = NULL;
537-
}
538-
return retval;
539-
}
540-
/* }}} */
541-
542-
/* {{{ _php_mb_match_regex */
543-
static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
544-
{
545-
OnigMatchParam *mp = onig_new_match_param();
546-
int err;
547-
onig_initialize_match_param(mp);
548-
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_stack_limit))) {
549-
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
550-
}
551-
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_retry_limit))) {
552-
onig_set_retry_limit_in_match_of_match_param(mp, (unsigned int)MBSTRG(regex_retry_limit));
553-
}
554-
/* search */
555-
err = onig_search_with_param((php_mb_regex_t *)opaque, (const OnigUChar *)str,
556-
(const OnigUChar*)str + str_len, (const OnigUChar *)str,
557-
(const OnigUChar*)str + str_len, NULL, ONIG_OPTION_NONE, mp);
558-
onig_free_match_param(mp);
559-
return err >= 0;
560-
}
561-
/* }}} */
562-
563-
/* {{{ _php_mb_free_regex */
564-
static void _php_mb_free_regex(void *opaque)
565-
{
566-
onig_free((php_mb_regex_t *)opaque);
567-
}
568-
/* }}} */
569-
#else
570500
/* {{{ _php_mb_compile_regex */
571501
static void *_php_mb_compile_regex(const char *pattern)
572502
{
@@ -608,7 +538,6 @@ static void _php_mb_free_regex(void *opaque)
608538
pcre2_code_free(opaque);
609539
}
610540
/* }}} */
611-
#endif
612541

613542
/* {{{ php_mb_nls_get_default_detect_order_list */
614543
static int php_mb_nls_get_default_detect_order_list(enum mbfl_no_language lang, enum mbfl_no_encoding **plist, size_t *plist_size)

0 commit comments

Comments
 (0)