-
Notifications
You must be signed in to change notification settings - Fork 3
Description
If you have a track or album image with a literal # in its path, it won't play/show.
This is proving surprisingly annoying to fix (i.e., it's taken more than 15 minutes and I haven't fixed it yet). On the one hand, Flask doesn't escape the #, so it's getting treated as an anchor and not sent over HTTP as part of the path. On the other hand, if you manually escape the # to %23, Flask thwarts you by escaping the percent sign. Furthermore, writing your own redirect function analogous to flask.redirect isn't enough, as the location header isn't escaped there.
Thanks to smaili on Stack Overflow, I found out the URL escaping is getting done in get_wsgi_headers in Werkzeug here. The code, inside the BaseResponse class, checks self.autocorrect_location_header and runs only if that's true. So maybe I can write my own redirect function, but I'll have to
- set the created response object's
autocorrect_location_headerto false, - manually do something like what
autocorrect_location_headerdoes, so that spaces become %20, relative URLs become absolute, etc. — just with the difference of also escaping#.