This is an automated email from the git hooks/post-receive script. gregoa pushed a commit to tag 0.03 in repository libhttp-entity-parser-perl.
commit d93e5cb67964926aef34a4cb3b034235a9bbe9c0 Author: Masahiro Nagano <kazeb...@gmail.com> Date: Fri Feb 7 13:41:53 2014 +0900 tune a bit --- eg/bench.pl | 2 +- lib/HTTP/Entity/Parser.pm | 3 ++- lib/HTTP/Entity/Parser/UrlEncoded.pm | 37 ++++++------------------------------ 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/eg/bench.pl b/eg/bench.pl index e2edbde..7222ab1 100644 --- a/eg/bench.pl +++ b/eg/bench.pl @@ -6,7 +6,7 @@ use HTTP::Entity::Parser; use HTTP::Body; use Benchmark qw/:all/; -my $content = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa'; +my $content = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa&%E6%97%A5%E6%9C%AC%E8%AA%9E=%E3%81%AB%E3%81%BB%E3%82%93%E3%81%94&%E3%81%BB%E3%81%92%E3%81%BB%E3%81%92=%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C'; my $parser = HTTP::Entity::Parser->new; $parser->register('application/x-www-form-urlencoded','HTTP::Entity::Parser::UrlEncoded'); diff --git a/lib/HTTP/Entity/Parser.pm b/lib/HTTP/Entity/Parser.pm index 34b5ce0..b4573e7 100644 --- a/lib/HTTP/Entity/Parser.pm +++ b/lib/HTTP/Entity/Parser.pm @@ -25,7 +25,8 @@ sub get_parser { if (defined $env->{CONTENT_TYPE}) { for my $handler (@{$self->{handlers}}) { - if (index($env->{CONTENT_TYPE}, $handler->[0]) == 0) { + if ( $env->{CONTENT_TYPE} eq $handler->[0] + || index($env->{CONTENT_TYPE}, $handler->[0]) == 0) { return $handler->[1]->new($env, $handler->[2]); } } diff --git a/lib/HTTP/Entity/Parser/UrlEncoded.pm b/lib/HTTP/Entity/Parser/UrlEncoded.pm index c601c4d..938ca60 100644 --- a/lib/HTTP/Entity/Parser/UrlEncoded.pm +++ b/lib/HTTP/Entity/Parser/UrlEncoded.pm @@ -2,49 +2,24 @@ package HTTP::Entity::Parser::UrlEncoded; use strict; use warnings; - -our $DECODE = qr/%([0-9a-fA-F]{2})/; -our %DecodeMap; -for my $num ( 0 .. 255 ) { - my $h = sprintf "%02X", $num; - my $chr = chr $num; - $DecodeMap{ lc $h } = $chr; #%aa - $DecodeMap{ uc $h } = $chr; #%AA - $DecodeMap{ ucfirst lc $h } = $chr; #%Aa - $DecodeMap{ lcfirst uc $h } = $chr; #%aA -} +use WWW::Form::UrlEncoded qw/parse_urlencoded/; sub new { - my $class = shift; - bless { buffer => '' }, $class; + bless [''], shift; } sub add { my $self = shift; if (defined $_[0]) { - $self->{buffer} .= $_[0]; + $self->[0] .= $_[0]; } } sub finalize { - my $self = shift; - my @params; - for my $pair ( split( /[&;] ?/, $self->{buffer}, -1 ) ) { - $pair =~ y/\+/\x20/; - my ($key, $val) = split /=/, $pair, 2; - for ($key, $val) { - if ( ! defined $_ ) { - push @params, ''; - next; - } - s/$DECODE/$DecodeMap{$1}/gs; - push @params, $_; - } - } - - return (\@params, []); + return ([parse_urlencoded($_[0]->[0])], []); } + 1; __END__ @@ -52,7 +27,7 @@ __END__ =head1 NAME -HTTP::Entity::Parser::MultiPart - parser for application/x-www-form-urlencoded +HTTP::Entity::Parser::UrlEncoded - parser for application/x-www-form-urlencoded =head1 SYNOPSIS -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libhttp-entity-parser-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits