Guest User

Untitled

a guest
Sep 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/usr/bin/python
  2. #
  3. # Demonstrates IE inconsistency when receiving Location header with a URL hash
  4. #
  5. # It maintains the hash after a POSTing a normal form,
  6. # and loses it after a multipart POST with a file field.
  7. #
  8. # Inconsistency tested on versions IE8, IE9.
  9. #
  10. # 'pip install flask' then run and connect with your browser to port 5000.
  11.  
  12. from flask import Flask, Response, request, redirect
  13.  
  14. app = Flask(__name__)
  15.  
  16. tmpl = """
  17. <!DOCTYPE html>
  18.  
  19. <html>
  20. <head>
  21. <title>Test IE location hash bug</title>
  22. </head>
  23. <body>
  24. <form method="POST" enctype="multipart/form-data" action="/">
  25. <input type="file" name="ff">
  26. <input type="submit" name="submit" value="multipart">
  27. </form>
  28. <form method="POST" enctype="" action="/">
  29. <input type="submit" name="submit" value="normal">
  30. </form>
  31. </body>
  32. </html>
  33. """
  34.  
  35. @app.route('/', methods=['GET', 'POST'])
  36. def index():
  37. if request.method == 'POST':
  38. return redirect('/#{}'.format(request.form['submit']))
  39. else:
  40. return Response(tmpl)
  41.  
  42. if __name__ == '__main__':
  43. app.run(host='0.0.0.0')
Add Comment
Please, Sign In to add comment