]> granicus.if.org Git - onig/commitdiff
add ONIG_SYN_ALLOW_INVALID_CODE_END_OF_RANGE
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 30 Jul 2019 05:15:32 +0000 (14:15 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Tue, 30 Jul 2019 05:15:32 +0000 (14:15 +0900)
src/oniguruma.h
src/regparse.c

index 18f700c5e86051df3ec4f22d820edada4c54676f..c5ece42945bf13b986920c4e656c8d0ef749bf21 100644 (file)
@@ -521,6 +521,7 @@ ONIG_EXTERN OnigSyntaxType*   OnigDefaultSyntax;
 #define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC          (1U<<21) /* [..\w..] etc.. */
 #define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC         (1U<<22)
 #define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC     (1U<<23) /* [0-9-a]=[0-9\-a] */
+#define ONIG_SYN_ALLOW_INVALID_CODE_END_OF_RANGE (1U<<26)
 /* syntax (behavior) warning */
 #define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED          (1U<<24) /* [,-,] */
 #define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT    (1U<<25) /* (?:a*)+ */
index e90a8f739e01625cb15051893e0df42c301af1b4..d6beabc1e50f7071d2a156328a8d1a2565ee2ca7 100644 (file)
@@ -77,6 +77,7 @@ OnigSyntaxType OnigSyntaxOniguruma = {
       ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
       ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME |
       ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY |
+      ONIG_SYN_ALLOW_INVALID_CODE_END_OF_RANGE |
       ONIG_SYN_WARN_CC_OP_NOT_ESCAPED |
       ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT )
   , ONIG_OPTION_NONE
@@ -6384,8 +6385,12 @@ parse_char_class(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env)
     val_entry:
       len = ONIGENC_CODE_TO_MBCLEN(env->enc, v);
       if (len < 0) {
-        r = len;
-        goto err;
+        if (state != CCS_RANGE ||
+            ! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_INVALID_CODE_END_OF_RANGE) ||
+            v < 0x100 || ONIGENC_MBC_MAXLEN(env->enc) == 1) {
+          r = len;
+          goto err;
+        }
       }
       in_type = (len == 1 ? CCV_SB : CCV_CODE_POINT);
     val_entry2: