libwww-perl / libwww-perl/HTTP-Message
Regain compatibility with Encode 2.02 and older [rt.cpan.org #63871]
Open
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 32
- Forks
- 63
- Avg merge
- 5h 14m
- Merged PRs (30d)
- 1
Description
Copied from: https://github.com/libwww-perl/libwww-perl/issues/153 :
Migrated from rt.cpan.org#63871 (status was 'new')
Requestors:
- ANDK@cpan.org
--- 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,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/HTTP/Message.pm, focusing on content_charset and decoded_content. Compare the embedded patch and verify that the older charset names and compatibility condition support Encode 2.02 and older without changing the surrounding behavior. Done means HTTP::Message::decoded_content works with those Encode versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100