Ian Ling
Ian Ling

Reputation: 334

Flask: Prevent HTML escaping in the browser's URL bar

I am working on a RESTful API in Flask. It allows wildcards to be used. The problem is that when a URL is entered, such as mysite.com/get/abc*, Flask turns this URL into mysite.com/get/abc%2A, both on the backend and in the browser's URL bar.

This is easy enough to handle on the backend, but how can I prevent the browser's URL bar from containing ugly things like '%2A'?

Upvotes: 1

Views: 339

Answers (1)

Bartosz Marcinkowski
Bartosz Marcinkowski

Reputation: 6861

It is not Flask that turns * into %2A, it is the browser.

Character * is not legal in an URL and there is nothing you can do about it. Browsers must escape illegal characters in sent requests. A browser might leave * in the address bar (and escape it silently), but you should not expect browsers to do so.

Upvotes: 4

Related Questions