Skip to content

Commit

Permalink
Empty \N{} in regex pattern should force /d to /u
Browse files Browse the repository at this point in the history
\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.)
  • Loading branch information
khwilliamson committed Dec 31, 2014
1 parent ec98ebe commit 75697d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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, ".}");
Expand Down
1 change: 1 addition & 0 deletions t/re/re_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 75697d6

Please sign in to comment.