Do not display too many bytes when reporting malformed UTF-8 character

This commit is contained in:
Petr Písař 2017-08-09 13:30:33 +02:00
parent a501e07f4e
commit efc8e989ed
2 changed files with 50 additions and 0 deletions

View File

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

View File

@ -193,6 +193,10 @@ Patch46: perl-5.26.0-t-op-hash.t-fixup-intermittently-failing-test.patch
Patch47: perl-5.27.1-Parse-caret-vars-with-subscripts-the-same-as-normal-.patch
Patch48: perl-5.27.1-add-an-additional-test-for-whitespace-tolerance-in-c.patch
# Do not display too many bytes when reporting malformed UTF-8 character,
# in upstream after 5.27.1
Patch49: perl-5.27.1-utf8n_to_uvchr-Don-t-display-too-many-bytes-in-msg.patch
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@ -2769,6 +2773,7 @@ Perl extension for Version Objects
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch200 -p1
%patch201 -p1
@ -2802,6 +2807,7 @@ perl -x patchlevel.h \
'Fedora Patch45: Fix File::Glob rt131211.t test random failures' \
'Fedora Patch46: Fix t/op/hash.t test random failures' \
'Fedora Patch47: Parse caret variables with subscripts as normal variables inside ${...} escaping (RT#131664)' \
'Fedora Patch49: Do not display too many bytes when reporting malformed UTF-8 character' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
%{nil}
@ -5091,6 +5097,7 @@ popd
- Fix t/op/hash.t test random failures
- Parse caret variables with subscripts as normal variables inside ${...}
escaping (RT#131664)
- Do not display too many bytes when reporting malformed UTF-8 character
* Sat Jul 29 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4:5.26.0-397
- Enable separate debuginfo back