Solved

Passing query strings within a query string

Posted on 1998-07-19
2
147 Views
Last Modified: 2013-12-25
/cgibin/redirect.cgi?url=http://www.digitalriver.com/dr/v2/ec_Main.Entry?SP=10007&SID=6370&CID=0

When I run the above script to redirect on link, the query string in the url to be redirected to seems to get cut off at the =. How can I solve this?
0
Comment
Question by:djschaper
2 Comments
 
LVL 28

Expert Comment

by:sybe
Comment Utility
use urlencode to encode the querystring, for example with Javascript escape()
0
 
LVL 6

Accepted Solution

by:
alamo earned 50 total points
Comment Utility
When you run a redirect like this, you can't use standard QUERY_STRING processing in your redirect script, because the query string in the redirected url has to be decoded at the final destination, not by you. If you urlencode the querystring your cgi has to decode and then reencode or information will be lost- it's quite tricky, and can easily fail. And it's unnecessary.

The easy way to do it is to change the url to:

/cgibin/redirect.cgi?http://www.digitalriver.com/dr/v2/ec_Main.Entry?SP=10007&SID=6370&CID=0

notice the url= part is gone. Now, in redirect.cgi don't do any QUERY_STRING processing at all, just do the redirect (shown in perl, if you are using something else the idea is the same):

print "Location: $ENV{QUERY_STRING}\n\n";

If you really must have additional fields encoded as part of your redirect url, either place them at the start of the QUERY_STRING and process them specially, or put them into PATH_INFO so they are separate.

Hope this helps!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now