CGI-problem

Joonas Paalasmaa joonas at olen.to
Thu Jan 24 06:33:42 EST 2002


olav.viken at kmss.no wrote in message news:<a2od3t$qr5$1 at oslo-nntp.eunet.no>...
> Hi!
> 
> I'm having a problem passing the '#-character' to a cgi-script.
> 
> The cgi script is invoked with a url as this:
> 
> http:/myserver/script.py?link="T:/test.htm#Mark"
> 
> 
> 
> Here part of my python-script
> 
> import cgi,string,os
> 
> all_values=cgi.FieldStorage()
> link=all_values["link"].value
> print link
> 
> this will produce output:
> 
> "T:/test.htm
> 

You have to url encode the parameter before passing it to the script.

>>> import urllib
>>> urllib.quote_plus('"T:/test.htm#Mark"')
'%22T%3A%2Ftest.htm%23Mark%22'



More information about the Python-list mailing list