b8c914
From 05b9033b464ce8dd2c9b33238f9aa14755d7a91a Mon Sep 17 00:00:00 2001
b8c914
From: Karl Williamson <khw@cpan.org>
b8c914
Date: Sat, 17 Jun 2017 17:56:10 -0600
b8c914
Subject: [PATCH] utf8n_to_uvchr(): Don't display too many bytes in msg
b8c914
MIME-Version: 1.0
b8c914
Content-Type: text/plain; charset=UTF-8
b8c914
Content-Transfer-Encoding: 8bit
b8c914
b8c914
When raising a message about malformed UTF-8, we shouldn't display bytes
b8c914
from the next character, unless those bytes were expected to have been
b8c914
part of the current one.  Tests for this will be added in future commits
b8c914
in ext/XS-APItest/t/utf8_warn_base.pl
b8c914
b8c914
Signed-off-by: Petr Písař <ppisar@redhat.com>
b8c914
---
b8c914
 utf8.c | 4 ++--
b8c914
 1 file changed, 2 insertions(+), 2 deletions(-)
b8c914
b8c914
diff --git a/utf8.c b/utf8.c
b8c914
index ee5405f..e55a6f1 100644
b8c914
--- a/utf8.c
b8c914
+++ b/utf8.c
b8c914
@@ -1428,7 +1428,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
b8c914
                         if (pack_warn) {
b8c914
                             message = Perl_form(aTHX_ "%s: %s (overflows)",
b8c914
                                             malformed_text,
b8c914
-                                            _byte_dump_string(s0, send - s0, 0));
b8c914
+                                            _byte_dump_string(s0, curlen, 0));
b8c914
                         }
b8c914
                     }
b8c914
                 }
b8c914
@@ -1554,7 +1554,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
b8c914
                                 "%s: %s (overlong; instead use %s to represent"
b8c914
                                 " U+%0*" UVXf ")",
b8c914
                                 malformed_text,
b8c914
-                                _byte_dump_string(s0, send - s0, 0),
b8c914
+                                _byte_dump_string(s0, curlen, 0),
b8c914
                                 _byte_dump_string(tmpbuf, e - tmpbuf, 0),
b8c914
                                 ((uv < 256) ? 2 : 4), /* Field width of 2 for
b8c914
                                                          small code points */
b8c914
-- 
b8c914
2.9.4
b8c914