flask/tests
Antonio Larrosa 0049922f2e Fix send_file to work with non-ascii filenames
This commit implements https://tools.ietf.org/html/rfc2231#section-4 in
order to support sending unicode characters. Tested on both Firefox and
Chromium under Linux.

This adds unidecode as a dependency, which might be relaxed by using
.encode('latin-1', 'ignore') but wouldn't be as useful.

Also, added a test for the correct headers to be added.

Previously, using a filename parameter to send_file with unicode characters, it
failed with the next error since HTTP headers don't allow non latin-1 characters.
Error on request:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 186, in execute
    write(b'')
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 152, in write
    self.send_header(key, value)
  File "/usr/lib64/python3.6/http/server.py", line 509, in send_header
    ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict'))
UnicodeEncodeError: 'latin-1' codec can't encode character '\uff0f' in position 58: ordinal not in range(256)

Fixes #1286
2017-03-23 17:30:48 +01:00
..
static Move tests 2014-09-11 22:09:50 +02:00
templates Enable autoescape for render_template_string 2015-07-04 23:41:43 +02:00
test_apps prevent NoAppException when ImportError occurs within imported module 2016-12-30 22:45:53 +01:00
conftest.py Eliminate some resource warnings 2016-06-03 14:29:27 +02:00
test_appctx.py Improve application context popping 2016-05-26 21:46:56 +02:00
test_basic.py Don't rely on X-Requested-With for pretty print json response (#2193) 2017-03-07 10:09:46 +09:00
test_blueprints.py Use pytest.raises() instead of try/catch with asser 0 2016-03-04 13:30:40 +02:00
test_cli.py Add test to showcase that printing a traceback works 2017-03-16 20:56:12 +01:00
test_config.py Fix config.from_pyfile on Python 3 (#2123) 2016-12-26 03:50:47 +01:00
test_deprecations.py Use recwarn everywhere 2016-06-03 13:59:47 +02:00
test_ext.py Added python3.6 support for tests 2017-01-10 11:20:53 -06:00
test_helpers.py Fix send_file to work with non-ascii filenames 2017-03-23 17:30:48 +01:00
test_instance_config.py Happy New Year 2015 2015-01-02 11:35:00 +09:00
test_regression.py Always run gc before leak test 2016-05-22 10:34:48 +02:00
test_reqctx.py Use pytest.raises() instead of try/catch with asser 0 2016-03-04 13:30:40 +02:00
test_signals.py Ignore before_render_template return values 2015-06-17 15:42:39 +02:00
test_subclassing.py Happy New Year 2015 2015-01-02 11:35:00 +09:00
test_templating.py Enable autoescape for render_template_string 2015-07-04 23:41:43 +02:00
test_testing.py Default environ (#2047) 2016-10-12 08:54:24 +02:00
test_user_error_handler.py Handle empty deque on errorhandler lookup. 2015-06-02 16:13:30 -04:00
test_views.py Happy New Year 2015 2015-01-02 11:35:00 +09:00