Commit graph

180 commits

Author SHA1 Message Date
David Lord
9c7e73e955 refactor session cookie domain logic
cache result of session cookie domain
add warnings for session cookie domain issues
add changelog
2017-05-13 21:59:00 -07:00
José Oliveira
aea3c48d80 show warning if session cookie domain is ip
closes #2007
2017-05-13 21:47:43 -07:00
rocambolesque
e111d8dbf3 Add scheme to url_build error handler parameters 2017-04-20 08:30:07 -07:00
David Lord
50851d6a60 filename can be latin-1, not just ascii
only normalize basic name when utf-8 header is needed
ref #2223
2017-04-12 09:59:25 -07:00
David Lord
100863e4fd style cleanup
break out header parts in test
test for no filename* parameter for ascii header
2017-04-07 18:02:31 -07:00
Antonio Larrosa
cca5c27a67 Keep using only filename if it's valid ascii 2017-04-07 20:34:52 +02:00
Antonio Larrosa
ebce4e2fc3 Remove unidecode dependency and use unicodedata instead
I found a way to remove the unidecode dependency without sacrificing
much by using unicodedata.normalize .
2017-03-30 17:32:21 +02:00
Antonio Larrosa
5e8ac066e4 Fix previous commits to work with python 2 and python 3
Also, parse_options_header seems to interpret filename* so we better
test the actual value used in the headers (and since it's valid
in any order, use a set to compare)
2017-03-24 20:05:01 +01:00
Antonio Larrosa
0d07974a49 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
Kim Blomqvist
c31e0ade9e Disable debug when FLASK_DEBUG=False (#2155)
Convert FLASK_DEBUG envvar to lower before test if in tuple
2017-01-17 07:15:51 -08:00
Joël Charles
f2b945d586 make use of range requests if available in werkzeug (#2031)
* make use of range requests if available in werkzeug

* different logic for testing werkzeug functionality
2016-09-26 12:43:46 +02:00
Markus Unterwaditzer
c60864226f Avoid always-false statement
See https://github.com/pallets/flask/pull/1849/files#r79371299
2016-09-19 23:30:24 +02:00
Bruno Thalmann
f5388fd5b2 Removed unused import. (#2026) 2016-09-18 14:10:00 +02:00
Armin Ronacher
578aa5805a Killed now dead code 2016-09-11 16:57:43 +03:00
Armin Ronacher
830632714c Do not error for unknown files if send_file sends an actual file 2016-09-10 03:33:53 +03:00
Roman
ae649aacaf Fix error in send_file helper (#2003)
* Fix error in send_file (mimetype_filename is not defined)

* fix formatting error message in send_file
2016-09-04 16:28:05 -07:00
Markus Unterwaditzer
a9757f8b1e Properly remove f.name usage in send_file (#1988)
* Properly remove f.name usage in send_file

* Update changelogs

* Fix tests
2016-08-26 03:08:03 +02:00
David Lord
2560444f47 pass value directly to last_modified 2016-06-05 12:42:34 -07:00
Prachi Shirish Khadke
cd408cc462 Add last_modified arg for send_file
Enhancement: Add last_modified arg of type DateTime to send_file.

Fixes pallets/flask#1321
2016-06-05 10:59:17 -07:00
Giampaolo Eusebi
89235f20e4 Make safe_join able to safely join multiple paths 2016-06-04 11:26:16 +02:00
Dan Sully
51c2069872 Remove deprecation warnings for add_etags & mimetype guessing for send_file()
Fix #1849
2016-06-03 14:52:33 +02:00
Armin Ronacher
36e6ec9419 Merge pull request #1813 from pallets/bugfix/scheme
Resolve state issue for url_for with forced scheme
2016-05-26 21:48:20 +02:00
Armin Ronacher
3b98e39768 Implemented simplified CLI interface 2016-05-26 20:07:52 +02:00
Armin Ronacher
d8437ce215 Resolve state issue for url_for with forced scheme
This fixes #1596
2016-05-22 10:45:29 +02:00
David Hou
39534d07d1 Raise BadRequest if static file name is invalid
* Raise BadRequest if static file name is invalid

* Clean up syntax a bit

* Remove unnecessary close()
2016-04-02 21:07:27 +02:00
Shipeng Feng
5e9842dadb Fixed stream_with_context if decorated function has parameters 2016-04-01 16:17:45 -07:00
nivm
3c76c51016 remove 'flask' from etags to obscure server technologies 2016-01-10 12:33:35 +02:00
Timo Furrer
906e72b219 support timedelta for SEND_FILE_MAX_AGE_DEFAULT config variable 2015-10-24 07:04:23 +02:00
lobeck
9d01d60dea Revert "make external_url_handler example py3 compliant" 2015-07-16 13:53:59 +02:00
Christian Becker
29a3533a01 make external_url_handler example py3 compliant
- a raises statement with multiple values is no longer allowed in python 3
2015-07-16 02:45:56 +02:00
Markus Unterwaditzer
d93e9be563 Document static_folder 2015-06-11 19:55:51 +02:00
Keyan Pishdadian
b7225b5fa3 Update send_file() docs to clarify encoding requirement #1286 2015-06-06 07:38:09 +02:00
Markus Unterwaditzer
0339a45c7b Clarify some docs
Fix #1476
2015-05-31 18:59:14 +02:00
Markus Unterwaditzer
0a59ed3a0b Untangle logic a bit 2015-03-05 22:00:27 +01:00
Edward Z. Yang
9209377f03 Remove bad security advice about send_file.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2015-02-07 15:06:51 -08:00
Parkayun
e05771ff60 Happy New Year 2015 2015-01-02 11:35:00 +09:00
defuz
e4043cfb11 docs: :exc:TypeError 2014-11-05 08:16:27 +03:00
defuz
f865a7ffd6 docs: `.html, .py` 2014-11-05 07:52:04 +03:00
defuz
d81e6f85af docs: `Flask-Uploads, X-Forwarded-Host` 2014-11-05 07:23:47 +03:00
defuz
0517016996 docs: `DEBUG, SERVER_NAME, PATH_INFO` 2014-11-05 07:10:49 +03:00
defuz
b5c9ad68dd docs: :file:app.py, :file:yourapp/templates 2014-11-05 06:45:22 +03:00
defuz
f7cbe74c35 docs: `True, False and None` 2014-11-05 06:04:58 +03:00
Petr Zemek
ac5d65385e Remove a redundant "the" in a comment. 2014-10-27 11:54:30 +01:00
Petr Zemek
2593ae00cf Unify the uses of "urls" vs "URLs".
Use "URLs", which is more prevailing in the source code.
2014-10-27 11:36:23 +01:00
Petr Zemek
27d339dc69 Put two spaces before inline comments when there is only one space.
PEP8 (E261) suggests to use at least two spaces before inline comments.
2014-10-27 11:24:15 +01:00
Markus Unterwaditzer
9710a5074d Fix typo 2014-09-06 02:20:44 +02:00
Markus Unterwaditzer
919c4b757b Document building protocol-relative URLs
https://github.com/mitsuhiko/werkzeug/pull/528
2014-08-27 13:34:10 +02:00
Markus Unterwaditzer
1cc77a738a Add documentation about url_for's default scheme
Fix #1129
2014-08-11 11:56:55 +02:00
Carlos E. Garcia
02848ef66b few mispelling errors 2014-04-23 10:46:38 -04:00
Armin Ronacher
b86c09b578 Better support for namespace packages. 2014-04-11 19:59:54 +02:00