[OpenLayers-Users] proxy.cgi is truncating ampersand

Trond Michelsen trondmm-openlayers at crusaders.no
Sat Apr 16 19:01:00 EDT 2011


On Sat, Apr 16, 2011 at 04:55:33PM -0600, Richard Greenwood wrote:
> The proxy.cgi python script is truncating everything after the
> ampersand "&". Specifically, my url:
> http://www.greenwoodmap.com/cgi-bin/proxy.cgi?url=http://records.sublettewyo.com/mapserver/listJSON.php?ts=greenwood&key=value
> And the access_log at records.sublettewyo.com shows:
> 50.16.240.30 - - [16/Apr/2011:16:47:29 -0600] "GET
> /mapserver/listJSON.php?ts=greenwood HTTP/1.1" 200 16118
> 
> Notice that the '&' and everything following it is missing in the access_log.
> I've tried substituting  &  &  \&  '&'  "&" without luck?
> What am I missing?

& is how you escape ampersands in HTML, when you want to escape it
in URLs, you must use %hex notation. i.e. %26. So, the URL should be:

http://www.greenwoodmap.com/cgi-bin/proxy.cgi?url=http://records.sublettewyo.com/mapserver/listJSON.php?ts=greenwood%26key=value

I would actually also escape the "?" and "=" just to be on the safe side

http://www.greenwoodmap.com/cgi-bin/proxy.cgi?url=http://records.sublettewyo.com/mapserver/listJSON.php%3Fts%3Dgreenwood%26key%3Dvalue

Of course, you could also just use the javascript function escape().

var proxy = "http://www.greenwoodmap.com/cgi-bin/proxy.cgi";
var target = "http://records.sublettewyo.com/mapserver/listJSON.php?ts=greenwood&key=value";
var full_url = proxy + "?url=" + escape(target);

-- 
Trond Michelsen


More information about the Users mailing list