Subject: | extra unescaping ? |
Hi, I'm not sure why there's escaping occuring at this place in the
code. It looks to me that it's causing issues with CGI.pm
What do you think?
Yann
Subject: | http-server-simple.patch |
diff -ru HTTP-Server-Simple-0.23/lib/HTTP/Server/Simple.pm HTTP-Server-Simple-0.23.patched/lib/HTTP/Server/Simple.pm
--- HTTP-Server-Simple-0.23/lib/HTTP/Server/Simple.pm 2006-10-22 23:24:37.000000000 -0700
+++ HTTP-Server-Simple-0.23.patched/lib/HTTP/Server/Simple.pm 2006-10-27 16:58:51.000000000 -0700
@@ -4,7 +4,6 @@
use FileHandle;
use Socket;
use Carp;
-use URI::Escape;
use vars qw($VERSION $bad_request_doc);
$VERSION = '0.23';
@@ -526,7 +525,7 @@
my $uri = $2 || '';
my $protocol = $3 || '';
- return ( $method, uri_unescape( $uri ), $protocol );
+ return ( $method, $uri, $protocol );
}
=head2 parse_headers
diff -ru HTTP-Server-Simple-0.23/t/04cgi.t HTTP-Server-Simple-0.23.patched/t/04cgi.t
--- HTTP-Server-Simple-0.23/t/04cgi.t 2006-10-18 20:29:31.000000000 -0700
+++ HTTP-Server-Simple-0.23.patched/t/04cgi.t 2006-10-27 16:54:46.000000000 -0700
@@ -6,7 +6,7 @@
if ($@) {
plan skip_all => "Data::Dumper not available";
}else {
- plan tests => 20;
+ plan tests => 25;
}
use constant PORT => 13432;
@@ -19,6 +19,7 @@
server_port => 'server_port: '.PORT,
server_software => 'server_software: HTTP::Server::Simple/\d+.\d+',
request_method => 'request_method: GET',
+ param => 'param',
);
my %envvars=(
@@ -46,6 +47,12 @@
select(undef,undef,undef,0.2); # wait a sec
like(fetch("GET / HTTP/1.1",""), '/NOFILE/', 'no file');
+ ## param tests
+ like(fetch("GET /cgitest/param?x=y HTTP/1.1",""), qr/param: y/, "simple param");
+ like(fetch("GET /cgitest/param?x=%3Fnice HTTP/1.1",""), qr/param: \?nice/, "encoded param");
+ like(fetch("GET /cgitest/param?x=%253F HTTP/1.1",""), qr/param: %3F/, "dbl encoded param");
+ like(fetch("GET /cgitest/param?x=%253Fother=%3F= HTTP/1.1",""), qr/param: %3Fother=\?=/, "dbl encoded param");
+
foreach my $method (keys(%methods)) {
like(
fetch("GET /cgitest/$method HTTP/1.1",""),
@@ -155,7 +162,9 @@
print "HTTP/1.0 200 OK\r\n"; # probably OK by now
print "Content-Type: text/html\r\nContent-Length: ";
my $response;
- if($methods{$file}) {
+ if ($file eq 'param') {
+ $response = "param: ". $cgi->param('x');
+ } elsif($methods{$file}) {
$response = "$file: ".$cgi->$file();
} elsif($envvars{$file}) {
$response="$file: $ENV{$file}";