Marlon Abeykoon
Marlon Abeykoon

Reputation: 12475

+ sign eliminates in web.py input parameters (GET request)

I have the following code which takes a input parameter t and return the same value.

import web

urls = (
    '/test(.*)', 'test',

)
class test(web.storage):

    def GET(self,r):
       t = web.input().q
       print t
       return t

if __name__ == "__main__":

    app = web.application(urls, globals())
    app.run()

So this works correctly when I execute the following URL in browser

http://localhost:8080/test?q=word1-word2

But when there is a + sign it eliminates that.

http://localhost:8080/test?q=word1+word2

and returns

word1 word2

where expected result is

word1+word2

How can I prevent this?

Upvotes: 0

Views: 57

Answers (1)

mhawke
mhawke

Reputation: 87124

Try URL encoding the query string:

http://localhost:8080/test?q=word1%2Bword2

as + is used to replace space.

Upvotes: 1

Related Questions