Skip to content

Commit 9d98d86

Browse files
committed
deal with Joe's leading escaped hash
1 parent ae4256a commit 9d98d86

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ide/routes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,20 @@ def is_running_locally():
374374
# The rest are the api routes and the main page route
375375
#
376376

377+
@app.before_request
378+
def check_for_escaped_hash():
379+
"""
380+
special case to check for escaped hash at beginning of path. Joe Heafner reported a problem where an URL with a '%23'
381+
immidiately after the first '/' would produce a 404. Unfortunatey this happens before our routes are matched, so we
382+
need to handle it in 'before_request'. Here we just check for this situation and redirect using a regular hash/fragment.
383+
"""
384+
url = flask.request.url
385+
p = urllib.parse.urlparse(url)
386+
if p.path.startswith('/%23'):
387+
newPath = '/#' + p.path[4:]
388+
newURL = urllib.parse.urlunparse(p[0:2]+('/#' + p.path[4:],)+p[3:])
389+
return flask.redirect(newURL)
390+
377391
@app.route('/api/login')
378392
def api_login():
379393
if auth.is_logged_in():

0 commit comments

Comments
 (0)