You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Justin Harrison <sh...@doublebagel.com> on 2002/10/08 23:22:47 UTC

Embperl problem?

Hi!

I am having a small difficulty.

When a user loads a page it checks for certain conditions. If these
conditions are not met, it redirects the user with this code:

[- $redirecturl = $ENV{HTTP_HOST} . $ENV{REQUEST_URI} -]

[- $http_headers_out{'Location'} =
"http://whatever/script2.embperl?redirect=http://$redirecturl" -]

The problem is that if the documented was requested with a query string,
and the query string had multiple parameters, for example:

http://whatever/script1.embperl?cat=1&jesus=2, when it redirects it to
script2, with this URL Format:
http://whatever/script2.embperl?redirect=http://whatever/script1.embperl
?cat=1&jesus=2, embperl seems to get confused? And $fdat{redirect} is
empty on script 2?

Justin


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Embperl problem?

Posted by Gerald Richter <ri...@ecos.de>.
Hi!
>
> You are going to want to url encode $redirecturl to do that safely.

Yes

> Something like:
>
> SWC::WebUtil::RedirectTemp("/login.html?redirect=" .
> uri_escape($ENV{REQUEST_URI}, '^-A-Za-z0-9./_'));
>

Embperl 1.3.4 and 2.0b8 has an undocumented (should be in the docs in the
next release) method to do escaping:

[-
$r = shift ;

# second parameter: 1 html escape, 2 url escape (same as $escmode)
$escaped = $r -> Escape ($ENV{REQUEST_URI}, 2) ;
-]

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Embperl problem?

Posted by Justin Harrison <sh...@doublebagel.com>.
Hah!

I encoded it and it now works!

Thank you!

> -----Original Message-----
> From: Kee Hinckley [mailto:nazgul@somewhere.com] 
> Sent: Tuesday, October 08, 2002 6:26 PM
> To: Justin Harrison
> Cc: embperl@perl.apache.org
> Subject: Re: Embperl problem?
> 
> 
> At 5:22 PM -0400 10/8/02, Justin Harrison wrote:
> >Hi!
> >
> >I am having a small difficulty.
> >
> >When a user loads a page it checks for certain conditions. If these 
> >conditions are not met, it redirects the user with this code:
> >
> >[- $redirecturl = $ENV{HTTP_HOST} . $ENV{REQUEST_URI} -]
> >
> >[- $http_headers_out{'Location'} = 
> >"http://whatever/script2.embperl?redirect=http://$redirecturl" -]
> 
> You are going to want to url encode $redirecturl to do that safely. 
> Something like:
> 
> SWC::WebUtil::RedirectTemp("/login.html?redirect=" . 
> uri_escape($ENV{REQUEST_URI}, '^-A-Za-z0-9./_'));
> 
> -- 
> 
> Kee Hinckley - Somewhere.Com, LLC http://consulting.somewhere.com/
> 
> I'm not sure which upsets me more: that people are so 
> unwilling to accept responsibility for their own actions, or 
> that they are so eager to regulate everyone else's.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Embperl problem?

Posted by Kee Hinckley <na...@somewhere.com>.
At 5:22 PM -0400 10/8/02, Justin Harrison wrote:
>Hi!
>
>I am having a small difficulty.
>
>When a user loads a page it checks for certain conditions. If these
>conditions are not met, it redirects the user with this code:
>
>[- $redirecturl = $ENV{HTTP_HOST} . $ENV{REQUEST_URI} -]
>
>[- $http_headers_out{'Location'} =
>"http://whatever/script2.embperl?redirect=http://$redirecturl" -]

You are going to want to url encode $redirecturl to do that safely. 
Something like:

SWC::WebUtil::RedirectTemp("/login.html?redirect=" . 
uri_escape($ENV{REQUEST_URI}, '^-A-Za-z0-9./_'));

-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org