How can I avoid coding errors using Net :: OpenID :: Consumer with Yahoo OpenIDs?

I wrote a Dancer web application that uses Net::OpenID::Consumerto use OpenID for authentication. It works well with Google and MyOpenID, but not with Yahoo. When a user tries to authenticate his Yahoo account, he HTML::Parserwarns:

Parsing of undecoded UTF-8 will give garbage when decoding entities

and this warning kills my application (rightfully).

I do not see any existing errors with Net::OpenID::Consumer(or Common) that relate to this.
The HTTP headers and HTML meta tags indicate UTF-8 for the URI of the declared identifier.
Why the answer will not be decoded for HTML::Parser? Am I missing something?

Here is the relevant code:

get '/openid_landing' => sub {
    my $params = params();
    my $csr = Net::OpenID::Consumer->new(
        ua => LWP::UserAgent->new(),
        consumer_secret => $secret,
        params => $params,
    );  
    my $id = $params->{'openid.claimed_id'};

    if (my $setup_url = $csr->user_setup_url) {
        redirect $setup_url;

    } elsif ($csr->user_cancel) {
        redirect uri_for('/');

    } elsif (my $vident = $csr->verified_identity) {
       # verified identity, log in or register user
       ...

    } else {
        die "Error validating identity: " . $csr->err;
    } 
};
+5
source share
2

Net/OpenID/URIFetch.pm 122-128 1.14 () . gzip- decoded_content .

, .:)

diff, :

122c122
<         my $content = $res->decoded_content;
---
>         my $content = $res->content;
125a126,129
>         if ($res->content_encoding && $res->content_encoding eq 'gzip') {
>             $content = Compress::Zlib::memGunzip($content);
>         }
>
+1

HTML:: Parser, TreeBuilder , TreeBuilder, decode_utf8:

use HTML::TreeBuilder;
use Encode;
my $contents = ...;
my $htree = HTML::TreeBuilder->new_from_content(decode_utf8 $contents);

:

http://metacpan.org/pod/HTML::TreeBuilder#new-from-content

http://search.cpan.org/dist/HTML-Parser/Parser.pm

0

All Articles