From 75697d6e4ef98ece405210de48e7529d01b619bf Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 21 Dec 2014 22:02:30 -0700 Subject: [PATCH] Empty \N{} in regex pattern should force /d to /u \N{} is for Unicode names, even if the name is actually omitted. (Accepting an empty name is, I believe, an accident, and now is supported only for backwards compatibility.) --- regcomp.c | 3 ++- t/re/re_tests | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/regcomp.c b/regcomp.c index e6ddb803aae9..c2521a97ccee 100644 --- a/regcomp.c +++ b/regcomp.c @@ -11174,6 +11174,8 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state, regnode** node_p, vFAIL("\\N{NAME} must be resolved by the lexer"); } + RExC_uni_semantics = 1; /* Unicode named chars imply Unicode semantics */ + if (endbrace == RExC_parse) { /* empty: \N{} */ if (node_p) { *node_p = reg_node(pRExC_state,NOTHING); @@ -11185,7 +11187,6 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state, regnode** node_p, return 0; } - RExC_uni_semantics = 1; /* Unicode named chars imply Unicode semantics */ RExC_parse += 2; /* Skip past the 'U+' */ endchar = RExC_parse + strcspn(RExC_parse, ".}"); diff --git a/t/re/re_tests b/t/re/re_tests index 0341f77f2c9b..dcac974de23a 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1433,6 +1433,7 @@ foo(\h)bar foo\tbar y $1 \t # Verify that \N{U+...} forces Unicode rules /\N{U+41}\x{c1}/i a\x{e1} y $& a\x{e1} /[\N{U+41}\x{c1}]/i \x{e1} y $& \x{e1} +/\N{}\xe4/i \xc4 y $& \xc4 # Empty \N{} should change /d to /u [\s][\S] \x{a0}\x{a0} n - - # Unicode complements should not match same character