Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

PATH_INFO Backup and IIS Middleware Patch #300

Closed
wants to merge 6 commits into from

2 participants

@KnowZero

This is to address issue #284 and allow IIS to work while also making PATH_INFO accessible to middleware prior to destruction via PLACK_PATH_INFO

@miyagawa
Owner

PLACK_PATH_INFO isn't a great name to set this up and also kind of violates the PSGI spec. If I were to do it, i would use plack.PATH_INFO_ORIGINAL.

@KnowZero

So make it $env->{'plack.PATH_INFO_ORIGINAL'} ?

@miyagawa
Owner

Sounds better to me yes.

@KnowZero

ok, done!

@miyagawa
Owner

Can you squash them into one commit and force push? The changes are dirty.

@miyagawa
Owner

I'm still not sure if this is the right thing to do - Can resurrecting PATH_INFO from REQUEST_URI be pushed to a piece of middleware and then IIS/lighttpd/apache middleware can do whatever they want to do, instead of doing it inside FCGI?

@KnowZero

If you mean putting:

my($path, $query) = ( $env->{REQUEST_URI} =~ /^([^?]*)(?:\?(.*))?$/s );
for ($path, $query) { s/\#.*$// if defined && length } # dumb clients sending URI fragments

my $newpath = URI::Escape::uri_unescape($path);

Inside a middleware?

That said this issue effects only FCGI so is making a middleware specific to FCGI make any sense?

But you just reminded me of a flaw in my code which I am going to fix right now. :/

@miyagawa
Owner

That said this issue effects only FCGI so is making a middleware specific to FCGI make any sense?

IIS6 and Lighttpd fix middleware already exists solely to fix FCGI environments.

@KnowZero

Oh, so those middleware are not needed outside of FCGI?

@KnowZero

Because if that is the case, then yes it makes most sense just to modify each middleware individually.

@miyagawa
Owner

Not needed, because if you don't use FCGI SCRIPT_NAME and PATH_INFO are NOT built by lighttpd or IIS anyway.

@KnowZero

If that is the case then I guess I'll just modify IIS6 middleware with this:

my($path, $query) = ( $env->{REQUEST_URI} =~ /^([^?])(?:\?(.))?$/s );
for ($path, $query) { s/#.*$// if defined && length } # dumb clients sending URI fragments

$env->{PATH_INFO} = URI::Escape::uri_unescape($path);

and that should do it.

@miyagawa miyagawa closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  lib/Plack/Handler/FCGI.pm
@@ -113,7 +113,7 @@ sub run {
# lighttpd munges multiple slashes in PATH_INFO into one. Try recovering it
my $uri = URI->new("http://localhost" . $env->{REQUEST_URI});
- $env->{PATH_INFO} = uri_unescape($uri->path);
+ $env->{PATH_INFO} = $env->{'plack.PATH_INFO_ORIGINAL'} = uri_unescape($uri->path);
$env->{PATH_INFO} =~ s/^\Q$env->{SCRIPT_NAME}\E//;
if ($env->{SERVER_SOFTWARE} && $env->{SERVER_SOFTWARE} =~ m!lighttpd[-/]1\.(\d+\.\d+)!) {
View
2  lib/Plack/Middleware/IIS6ScriptNameFix.pm
@@ -7,7 +7,7 @@ sub call {
my($self, $env) = @_;
if ($env->{SERVER_SOFTWARE} && $env->{SERVER_SOFTWARE} =~ /IIS\/[6-9]\.[0-9]/) {
- my @script_name = split(m!/!, $env->{PATH_INFO});
+ my @script_name = split(m!/!, $env->{'plack.PATH_INFO_ORIGINAL'}||$env->{'PATH_INFO'} );
my @path_translated = split(m!/|\\\\?!, $env->{PATH_TRANSLATED});
my @path_info;
Something went wrong with that request. Please try again.