HTML::Mason::FakeApache patch for unparsed_uri, etc.
"Daniel Ringwalt" <[email protected]> Tue, 27 Nov 2007 20:57:52 -0600
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch to HTML/Mason/FakeApache.pm:
1. has a working unparsed_uri()
2. has uri() and unparsed_uri() return the same value they would under
Apache::RequestRec
3. has a working filename()
for Mason components running under HTML::Mason::CGIHandler.
--- orig/FakeApache.pm
+++ new/FakeApache.pm
@@ -13,6 +13,7 @@
# In the future we'll probably want to switch this to Apache::Fake or similar
use HTML::Mason::MethodMaker(read_write => [qw(query)]);
+use HTML::Mason::Tools 'taint_is_on';
sub new {
my $class = shift;
@@ -75,11 +76,27 @@
sub uri {
my $self = shift;
- $self->{uri} ||= $self->{query}->script_name . $self->path_info || '';
+ return $self->{uri} if $self->{uri};
+ if (taint_is_on()) {
+ return $self->{query}->path_info();
+ }
+ $self->{uri} = $ENV{SCRIPT_URL};
}
-# Is this available in CGI?
-# sub filename {}
+sub unparsed_uri {
+ my $self = shift;
+
+ return $self->{unparsed_uri} if $self->{unparsed_uri};
+ if (taint_is_on()) {
+ return( $self->{unparsed_uri} = $self->uri . ($self->{query}
+ ->query_string and '?' . $self->{query}->query_string) );
+ }
+ $self->{unparsed_uri} = $ENV{REQUEST_URI};
+}
+
+sub filename {
+ $_[0]->{path_translated} ||= $_[0]->{query}->path_translated();
+}
# "The $r->location method will return the path of the
# <Location> section from which the current "Perl*Handler"
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4