From: Jarkko Hietaniemi Date: Tue, 9 Jul 2002 00:17:49 +0000 (+0000) Subject: MIME::QuotedPrint is for bytes only; from Gisle. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b13872386a1592fb39e4c9e14ec614f70a5c8533;p=p5sagit%2Fp5-mst-13.2.git MIME::QuotedPrint is for bytes only; from Gisle. p4raw-id: //depot/perl@17429 --- diff --git a/ext/MIME/Base64/QuotedPrint.pm b/ext/MIME/Base64/QuotedPrint.pm index 0b93f20..ad0d7e1 100644 --- a/ext/MIME/Base64/QuotedPrint.pm +++ b/ext/MIME/Base64/QuotedPrint.pm @@ -72,11 +72,16 @@ require Exporter; @ISA = qw(Exporter); @EXPORT = qw(encode_qp decode_qp); +use Carp qw(croak); + $VERSION = sprintf("%d.%02d", q$Revision: 2.3 $ =~ /(\d+)\.(\d+)/); sub encode_qp ($) { my $res = shift; + croak("The Quoted-Printable encoding is only defined for bytes") + if $res =~ /[^\0-\xFF]/; + # Do not mention ranges such as $res =~ s/([^ \t\n!-<>-~])/sprintf("=%02X", ord($1))/eg; # since that will not even compile on an EBCDIC machine (where ord('!') > ord('<')). if (ord('A') == 193) { # EBCDIC style machine diff --git a/ext/MIME/Base64/t/quoted-print.t b/ext/MIME/Base64/t/quoted-print.t index 1a7f9e4..97e525e 100644 --- a/ext/MIME/Base64/t/quoted-print.t +++ b/ext/MIME/Base64/t/quoted-print.t @@ -71,7 +71,7 @@ y. -- H. L. Mencken"], # line width ); -$notests = @tests + 2; +$notests = @tests + 3; print "1..$notests\n"; $testno = 0; @@ -111,3 +111,5 @@ print "not " unless decode_qp("foo \r\n\r\nfoo =\r\n\r\nfoo=20\r\n\r\n") eq "foo\r\n\r\nfoo \r\nfoo \r\n\r\n"; $testno++; print "ok $testno\n"; +print "not " if eval { encode_qp("XXX \x{100}") } || $@ !~ /^The Quoted-Printable encoding is only defined for bytes/; +$testno++; print "ok $testno\n";