Skip to content
Myr

Merge remote-tracking branch 'origin/1.0-maintenance'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents 4f32c6d, ded7cbe · Browse files · 5 files+39 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+39 added−4 removed

  • tests:+8 added−2 removed
  • other:+31 added−2 removed

5 files+39 added−4 removed

modified:flask/app.py+18 added-1 removed
18 unmodified lines
1920from werkzeug.datastructures import Headers, ImmutableDict21from werkzeug.exceptions import BadRequest, BadRequestKeyError, HTTPException, \22 InternalServerError, MethodNotAllowed, default_exceptions23from werkzeug.routing import BuildError, Map, RequestRedirect, Rule23from werkzeug.routing import BuildError, Map, RequestRedirect, \24 RoutingException, Rule2526from . import cli, json27from ._compat import integer_types, reraise, string_types, text_type28from .config import Config, ConfigAttribute
1602 unmodified lines
1631 """Handles an HTTP exception. By default this will invoke the1632 registered error handlers and fall back to returning the1633 exception as response.16341635 .. versionchanged:: 1.0.31636 ``RoutingException``, used internally for actions such as1637 slash redirects during routing, is not passed to error1638 handlers.16391640 .. versionchanged:: 1.01641 Exceptions are looked up by code *and* by MRO, so1642 ``HTTPExcpetion`` subclasses can be handled with a catch-all1643 handler for the base ``HTTPException``.16441645 .. versionadded:: 0.31646 """1647 # Proxy exceptions don't have error codes. We want to always return1648 # those unchanged as errors1649 if e.code is None:1650 return e16511652 # RoutingExceptions are used internally to trigger routing1653 # actions, such as slash redirects raising RequestRedirect. They1654 # are not raised or handled in user code.1655 if isinstance(e, RoutingException):1656 return e16571658 handler = self._find_error_handler(e)1659 if handler is None:1660 return e1661 return handler(e)
672 unmodified lines
modified:flask/helpers.py+3 added
575 unmodified lines
576 if attachment_filename is None:577 raise TypeError('filename unavailable, required for '578 'sending as attachment')579580 if not isinstance(attachment_filename, text_type):581 attachment_filename = attachment_filename.decode('utf-8')582583 try:584 attachment_filename = attachment_filename.encode('ascii')585 except UnicodeEncodeError:586 filenames = {
484 unmodified lines
modified:tests/test_helpers.py+2 added
678 unmodified lines
679 ('index.html', 'index.html', False),680 (u'Ñandú/pingüino.txt', '"Nandu/pinguino.txt"',681 '%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt'),682 (u'Vögel.txt', 'Vogel.txt', 'V%C3%B6gel.txt'),683 # Native string not marked as Unicode on Python 2684 ('tést.txt', 'test.txt', 't%C3%A9st.txt'),685 ))686 def test_attachment_filename_encoding(self, filename, ascii, utf8):687 rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=filename)688 rv.close()
318 unmodified lines
modified:tests/test_user_error_handler.py+6 added-2 removed
182 unmodified lines
183 @app.route('/forbidden')184 def forbidden():185 raise Forbidden()186187 @app.route("/slash/")188 def slash():189 return "slash"190191 app.register_blueprint(bp, url_prefix='/bp')192193 c = app.test_client()194 assert c.get('/bp/undefined').data == b'bp-default'195 assert c.get('/bp/forbidden').data == b'bp-forbidden'196 assert c.get('/undefined').data == b'default'197 assert c.get('/forbidden').data == b'forbidden'194195198 # Don't handle RequestRedirect raised when adding slash.199 assert c.get("/slash", follow_redirects=True).data == b"slash"
modified:CHANGES.rst+10 added-1 removed
34 unmodified lines
35- :func:`send_file` encodes filenames as ASCII instead of Latin-136 (ISO-8859-1). This fixes compatibility with Gunicorn, which is37 stricter about header encodings than PEP 3333. (`#2766`_)38- Allow custom CLIs using ``FlaskGroup`` to set the debug flag without39 it always being overwritten based on environment variables. (`#2765`_)39 it always being overwritten based on environment variables.40 (`#2765`_)41- ``flask --version`` outputs Werkzeug's version and simplifies the42 Python version. (`#2825`_)43- :func:`send_file` handles an ``attachment_filename`` that is a44 native Python 2 string (bytes) with UTF-8 coded bytes. (`#2933`_)45- A catch-all error handler registered for ``HTTPException`` will not46 handle ``RoutingExcpetion``, which is used internally during47 routing. This fixes the unexpected behavior that had been introduced48 in 1.0. (`#2986`_)4950.. _#2766: https://github.com/pallets/flask/issues/276651.. _#2765: https://github.com/pallets/flask/pull/276552.. _#2825: https://github.com/pallets/flask/pull/282553.. _#2933: https://github.com/pallets/flask/issues/293354.. _#2986: https://github.com/pallets/flask/pull/2986555657Version 1.0.258-------------
911 unmodified lines