This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Die on malformed isFOO_utf8() input
authorKarl Williamson <khw@cpan.org>
Thu, 8 Dec 2016 04:08:38 +0000 (21:08 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 23 Dec 2016 20:21:31 +0000 (13:21 -0700)
At the p5p core hackathon in November 2016, it was decided to make the
previous deprecation message fatal for malformed input passed to the
isFOO_utf8() macros and friends.

pod/perldelta.pod
pod/perldiag.pod
utf8.c

index 99fb9c7..312252e 100644 (file)
@@ -327,7 +327,8 @@ well.
 
 =item *
 
-XXX
+Calling macros like C<isALPHA_utf8> on malformed UTF-8 have issued a
+deprecation warning since Perl v5.18.  They now die.
 
 =back
 
index c0a717c..13cf13d 100644 (file)
@@ -4671,17 +4671,6 @@ Remember that "my", "our", "local" and "state" bind tighter than comma.
 (F) Parsing code supplied by an extension violated the parser's API in
 a detectable way.
 
-=item Passing malformed UTF-8 to "%s" is deprecated
-
-(D deprecated, utf8) This message indicates a bug either in the Perl
-core or in XS code.  Such code was trying to find out if a character,
-allegedly stored internally encoded as UTF-8, was of a given type, such
-as being punctuation or a digit.  But the character was not encoded in
-legal UTF-8.  The C<%s> is replaced by a string that can be used by
-knowledgeable people to determine what the type being checked against
-was.  If C<utf8> warnings are enabled, a further message is raised,
-giving details of the malformation.
-
 =item Pattern subroutine nesting without pos change exceeded limit in regex
 
 (F) You used a pattern that uses too many nested subpattern calls without
diff --git a/utf8.c b/utf8.c
index 5268730..6b2c128 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2425,16 +2425,12 @@ S_is_utf8_common(pTHX_ const U8 *const p, SV **swash,
      * character without reading beyond the end, and pass that number on to the
      * validating routine */
     if (! isUTF8_CHAR(p, p + UTF8SKIP(p))) {
-        if (ckWARN_d(WARN_UTF8)) {
-            Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED,WARN_UTF8),
-                   "Passing malformed UTF-8 to \"%s\" is deprecated", swashname);
-            if (ckWARN(WARN_UTF8)) {    /* This will output details as to the
-                                           what the malformation is */
-                utf8_to_uvchr_buf(p, p + UTF8SKIP(p), NULL);
-            }
-        }
-        return FALSE;
+        _force_out_malformed_utf8_message(p, p + UTF8SKIP(p),
+                                          0,
+                                          1 /* Die */ );
+        NOT_REACHED; /* NOTREACHED */
     }
+
     if (!*swash) {
         U8 flags = _CORE_SWASH_INIT_ACCEPT_INVLIST;
         *swash = _core_swash_init("utf8",