dougm 02/05/24 09:58:42
Modified: lib/Apache compat.pm
t/response/TestApache compat2.pm
Log:
add Apache::Util::escape_uri compat function and tests
Revision Changes Path
1.50 +7 -0 modperl-2.0/lib/Apache/compat.pm
Index: compat.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- compat.pm 24 May 2002 16:49:29 -0000 1.49
+++ compat.pm 24 May 2002 16:58:41 -0000 1.50
@@ -26,6 +26,7 @@
use Apache::RequestIO ();
use Apache::RequestUtil ();
use Apache::Response ();
+use Apache::Util ();
use Apache::Log ();
use Apache::URI ();
use APR::Table ();
@@ -414,6 +415,12 @@
}
*unescape_uri = \&Apache::unescape_url;
+
+sub escape_uri {
+ my $path = shift;
+ my $r = Apache::compat::request('Apache::Util::escape_uri');
+ Apache::Util::escape_path($path, $r->pool);
+}
sub Apache::URI::parse {
my($class, $r, $uri) = @_;
1.8 +9 -2 modperl-2.0/t/response/TestApache/compat2.pm
Index: compat2.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat2.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- compat2.pm 19 May 2002 11:41:53 -0000 1.7
+++ compat2.pm 24 May 2002 16:58:42 -0000 1.8
@@ -24,7 +24,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 39;
+ plan $r, tests => 41;
$r->send_http_header('text/plain');
@@ -192,8 +192,15 @@
}
}
- my $uri = "http://foo.com/a%20file.html";
+ my $uri = "http://foo.com/a file.html";
+ (my $esc_uri = $uri) =~ s/ /\%20/g;
my $uri2 = $uri;
+
+ $uri = Apache::Util::escape_uri($uri);
+ $uri2 = Apache::Util::escape_path($uri2, $r->pool);
+
+ ok t_cmp($esc_uri, $uri, "Apache::Util::escape_uri");
+ ok t_cmp($esc_uri, $uri2, "Apache::Util::escape_path");
ok t_cmp(Apache::unescape_url($uri),
Apache::Util::unescape_uri($uri2),