From 5b8511c300b7bec07659a541f36df0c67f4ff91c Mon Sep 17 00:00:00 2001 From: pyrrhlin <1197072+myrrhlin@users.noreply.github.com> Date: Tue, 3 Feb 2026 15:11:17 -0500 Subject: [PATCH] :Filter:ContentType dont try to unpack wide chars closes #168 --- lib/Data/Printer/Filter/ContentType.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Data/Printer/Filter/ContentType.pm b/lib/Data/Printer/Filter/ContentType.pm index d44d537..4c7e45e 100644 --- a/lib/Data/Printer/Filter/ContentType.pm +++ b/lib/Data/Printer/Filter/ContentType.pm @@ -11,6 +11,12 @@ filter 'SCALAR' => sub { my $len = length($$data); return if $len < 22; + # unpack H (below) requires bytes, but $$data could be a perl string + # with multibyte codepoints (and clearly not a HTTP::Message content). + for (my $i = 0; $i < 22; $i++) { + return if ord(substr($$data, $i, 1)) > 255; + } + my $hex = unpack('H22', $$data); my $hex_8 = substr($hex,0,8);