Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
genio opened this issue Apr 12, 2017 · 2 comments
Open

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

genio opened this issue Apr 12, 2017 · 2 comments

Comments

@genio
Copy link
Member

genio commented Apr 12, 2017

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 [email protected] 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,
@genio
Copy link
Member Author

genio commented Apr 12, 2017

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

@andk
Copy link

andk commented Apr 12, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants