Created
March 23, 2012 10:25
-
-
Save edgarsj/2169344 to your computer and use it in GitHub Desktop.
IE inconsistency when receiving Location header with a URL hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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