Skip to content

Instantly share code, notes, and snippets.

@edgarsj
Created March 23, 2012 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgarsj/2169344 to your computer and use it in GitHub Desktop.
Save edgarsj/2169344 to your computer and use it in GitHub Desktop.
IE inconsistency when receiving Location header with a URL hash
#!/usr/bin/python
#
# Demonstrates IE inconsistency when receiving Location header with a URL hash
#
# It maintains the hash after a POSTing a normal form,
# and loses it after a multipart POST with a file field.
#
# Inconsistency tested on versions IE8, IE9.
#
# 'pip install flask' then run and connect with your browser to port 5000.
from flask import Flask, Response, request, redirect
app = Flask(__name__)
tmpl = """
<!DOCTYPE html>
<html>
<head>
<title>Test IE location hash bug</title>
</head>
<body>
<form method="POST" enctype="multipart/form-data" action="/">
<input type="file" name="ff">
<input type="submit" name="submit" value="multipart">
</form>
<form method="POST" enctype="" action="/">
<input type="submit" name="submit" value="normal">
</form>
</body>
</html>
"""
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
return redirect('/#{}'.format(request.form['submit']))
else:
return Response(tmpl)
if __name__ == '__main__':
app.run(host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment