Unescaping URL Parameter w/ Web.py
Question: Reading an url as follows:

example.com/product/xy&z

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

In the product class on GET I am reading the that product ID pulled (xy&z)
from the URL to create a DB query. Some of those IDs have an '&' in them, when
I receive that value in python it has been escaped. I have had zero luck
unescaping it back so I can run the query correctly. The following do not
work:

    
    
    product = product.replace("&amp;", "&")
    product = HTMLParser.unescape.__func__(HTMLParser,product)
    

Whats the best practice in Web.py or even Python? Whats the best way to even
diagnose this on my own? Thanks!


Answer: I am getting these product ids out of box, see the following code.

    
    
    import web
    
    urls = (
        "/product/(.*)", "Product"
    )
    
    
    class Product:
        def GET(self, product_id):
            return product_id
    
    
    app = web.application(urls, globals())
    
    
    if __name__ == "__main__":
        #app.run()
        assert web.__version__ == "0.37"
        b = app.browser()
        b.open('/product/xy&amp;z')
        assert b.status == 200
        assert "xy&amp;z" in b.data
        assert "xy&z" not in b.data
        b.open('/product/xy&z')
        assert "xy&z" in b.data
    

Please provide failing url that doesn't return desired product id.

