kbo*_*sak 5 openid yahoo perl dancer
我编写了一个Net::OpenID::Consumer使用OpenID进行身份验证的Dancer Web应用程序.它适用于Google和MyOpenID,但不适用于Yahoo.当用户尝试使用他们的Yahoo帐户进行身份验证时,HTML::Parser警告:
Parsing of undecoded UTF-8 will give garbage when decoding entities
这个警告杀了我的应用程序(理所当然).
我没有看到Net::OpenID::Consumer与此相关的任何现有错误(或Common).
HTTP标头和HTML元标记都为"声明的id"URI指定UTF-8.
为什么不解码响应HTML::Parser?我错过了一些明显的东西吗
这是相关的代码:
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;
}
};
Run Code Online (Sandbox Code Playgroud)
小智 1
该错误位于Net/OpenID/URIFetch.pm版本 1.14(最新)的第 122-128 行中,它使用原始内容而不是响应对象的解码内容。只需删除手动 gzip 解码并在响应中使用decoded_content 方法即可。
我还没有提交错误报告,请随意。:)
您可以应用以下差异来修复它:
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);
> }
>
Run Code Online (Sandbox Code Playgroud)