summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldiag.pod16
-rw-r--r--regcomp.c6
-rw-r--r--t/re/reg_mesg.t2
3 files changed, 24 insertions, 0 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 1a8a9c7e66..36712cb535 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -3320,6 +3320,22 @@ L<perlfunc/listen>.
form of C<open> does not support pipes, such as C<open($pipe, '|-', @args)>.
Use the two-argument C<open($pipe, '|prog arg1 arg2...')> form instead.
+=item Literal vertical space in [] is illegal except under /x in regex;
+marked by S<<-- HERE> in m/%s/
+
+(F) (only under C<S<use re 'strict'>> or within C<(?[...])>)
+
+Likely you forgot the C</x> modifier or there was a typo in the pattern.
+For example, did you really mean to match a form-feed? If so, all the
+ASCII vertical space control characters are representable by escape
+sequences which won't present such a jarring appearance as your pattern
+does when displayed.
+
+ \r carriage return
+ \f form feed
+ \n line feed
+ \cK vertical tab
+
=item %s: loadable library and perl binaries are mismatched (got handshake key %p, needed %p)
(P) A dynamic loading library C<.so> or C<.dll> was being loaded into the
diff --git a/regcomp.c b/regcomp.c
index 1739dabbb7..50f5ee866e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -16225,6 +16225,12 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
do_posix_warnings ? &posix_warnings : NULL,
TRUE /* checking only */);
}
+ else if ( strict && ! skip_white
+ && ( _generic_isCC(value, _CC_VERTSPACE)
+ || is_VERTWS_cp_high(value)))
+ {
+ vFAIL("Literal vertical space in [] is illegal except under /x");
+ }
else if (value == '\\') {
/* Is a backslash; get the code point of the char after it */
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
index 8e538b6b11..627c039023 100644
--- a/t/re/reg_mesg.t
+++ b/t/re/reg_mesg.t
@@ -391,6 +391,8 @@ my @death_only_under_strict = (
=> 'Unescaped left brace in regex is illegal here {#} m/xa{{#}3\,4}y/',
'default_on/\\${[^\\}]*}/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\\${{#}[^\\}]*}/',
=> 'Unescaped left brace in regex is illegal here {#} m/\\${{#}[^\\}]*}/',
+ '/[a b]/' => "",
+ => 'Literal vertical space in [] is illegal except under /x {#} m/[a {#}b]/',
);
# These need the character 'ネ' as a marker for mark_as_utf8()