summaryrefslogtreecommitdiff
path: root/src/regexec.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-11-09 22:19:08 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-11-09 22:19:08 +0100
commit81f65b49e828952d496c80a991397fdac96feea9 (patch)
tree1256d7d214a97a3c130dc921323392a7f25c2c21 /src/regexec.c
parent4abcda3c3b7d9cb44036840ec0af01d5294dedc5 (diff)
New upstream version 6.1.2upstream/6.1.2
Diffstat (limited to 'src/regexec.c')
-rw-r--r--src/regexec.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/regexec.c b/src/regexec.c
index 70ac89e..7e8d3d1 100644
--- a/src/regexec.c
+++ b/src/regexec.c
@@ -3111,6 +3111,13 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
r = 0;
if (r == 0) {
+ if (ONIG_IS_OPTION_ON(option, ONIG_OPTION_CHECK_VALIDITY_OF_STRING)) {
+ if (! ONIGENC_IS_VALID_MBC_STRING(reg->enc, str, end)) {
+ r = ONIGERR_INVALID_WIDE_CHAR_VALUE;
+ goto end;
+ }
+ }
+
prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
r = match_at(reg, str, end,
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
@@ -3119,6 +3126,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
at, prev, &msa);
}
+ end:
MATCH_ARG_FREE(msa);
return r;
}
@@ -3391,6 +3399,13 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
if (start > end || start < str) goto mismatch_no_msa;
+ if (ONIG_IS_OPTION_ON(option, ONIG_OPTION_CHECK_VALIDITY_OF_STRING)) {
+ if (! ONIGENC_IS_VALID_MBC_STRING(reg->enc, str, end)) {
+ r = ONIGERR_INVALID_WIDE_CHAR_VALUE;
+ goto finish_no_msa;
+ }
+ }
+
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
@@ -3707,7 +3722,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
MATCH_ARG_FREE(msa);
/* If result is mismatch and no FIND_NOT_EMPTY option,
- then the region is not setted in match_at(). */
+ then the region is not set in match_at(). */
if (IS_FIND_NOT_EMPTY(reg->options) && region
#ifdef USE_POSIX_API_REGION_OPTION
&& !IS_POSIX_REGION(option)
@@ -3747,6 +3762,13 @@ onig_scan(regex_t* reg, const UChar* str, const UChar* end,
int rs;
const UChar* start;
+ if (ONIG_IS_OPTION_ON(option, ONIG_OPTION_CHECK_VALIDITY_OF_STRING)) {
+ if (! ONIGENC_IS_VALID_MBC_STRING(reg->enc, str, end))
+ return ONIGERR_INVALID_WIDE_CHAR_VALUE;
+
+ ONIG_OPTION_OFF(option, ONIG_OPTION_CHECK_VALIDITY_OF_STRING);
+ }
+
n = 0;
start = str;
while (1) {