libwww-perl / HTTP-Message

The HTTP-Message distribution contains classes useful for representing the messages passed in HTTP style communication.

Home Page:https://metacpan.org/pod/HTTP::Message

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regain compatibility with Encode 2.02 and older [rt.cpan.org #63871]

genio opened this issue · comments

Copied from: libwww-perl/libwww-perl#153 :

Migrated from rt.cpan.org#63871 (status was 'new')

Requestors:

--- lib/HTTP/Message.pm~	2010-12-13 12:23:34.000000000 +0100
+++ lib/HTTP/Message.pm	2010-12-13 12:25:39.000000000 +0100
@@ -207,10 +207,10 @@ sub content_charset
     # Unicode BOM
     for ($$cref) {
 	return "UTF-8"     if /^\xEF\xBB\xBF/;
-	return "UTF-32-LE" if /^\xFF\xFE\x00\x00/;
-	return "UTF-32-BE" if /^\x00\x00\xFE\xFF/;
-	return "UTF-16-LE" if /^\xFF\xFE/;
-	return "UTF-16-BE" if /^\xFE\xFF/;
+	return "UTF-32LE" if /^\xFF\xFE\x00\x00/;
+	return "UTF-32BE" if /^\x00\x00\xFE\xFF/;
+	return "UTF-16LE" if /^\xFF\xFE/;
+	return "UTF-16BE" if /^\xFE\xFF/;
     }
 
     if ($self->content_is_xml) {
@@ -357,13 +357,13 @@ sub decoded_content
 	}
 
 	if ($self->content_is_text || (my $is_xml = $self->content_is_xml)) {
-	    my $charset = lc(
+	    my $charset = 
 	        $opt{charset} ||
 		$self->content_type_charset ||
 		$opt{default_charset} ||
 		$self->content_charset ||
 		"ISO-8859-1"
-	    );
+	    ;
 	    unless ($charset =~ /^(?:none|us-ascii|iso-8859-1)\z/) {
 		require Encode;
 		if (do{my $v = $Encode::VERSION; $v =~ s/_//g; $v} < 2.0901 &&

From andk@cpan.org on 2010-12-13 12:04:17:

Attached patch provides a trivial change that makes
HTTP::Message::decoded_content compatible with Encode 2.02 and older.

The charset names used in HTTP::Message were introduced as aliases in
Encode 2.03. The older charset names are still available and this patch
uses those instead of the newer ones.

Of course, the connoisseur will recognize and value the speedup gained
by removing unneeded calls to lc() and unneeded dashes:)

Cheers,

@andk The removal of lc() there will cause the next unless clause to fail, won't it?

commented

I've lost context. The original ticket was 7 years ago against libwww-perl-5.837; it is closed; current seems to be in ETHER/HTTP-Message-6.11.tar.gz. All tests are green. Encode is at 2.88; please provide enough context to make clear what is relevant. Thanks!