[Python-modules-commits] [flask] 01/05: Import flask_0.12.2.orig.tar.gz

Ondřej Nový onovy at moszumanska.debian.org
Sat Jun 3 12:22:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

onovy pushed a commit to branch master
in repository flask.

commit 846a463e9be7e6e5bfb1fabbed465308171aca54
Author: Ondřej Nový <onovy at debian.org>
Date:   Sat Jun 3 14:20:39 2017 +0200

    Import flask_0.12.2.orig.tar.gz
---
 CHANGES                 |  7 +++++++
 Flask.egg-info/PKG-INFO |  2 +-
 PKG-INFO                |  2 +-
 docs/testing.rst        |  8 +++++---
 flask/__init__.py       |  2 +-
 flask/helpers.py        | 22 ++++++++++++++--------
 tests/test_helpers.py   | 27 +++++++++++++--------------
 7 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/CHANGES b/CHANGES
index 613b818..3456276 100644
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,13 @@ Major release, unreleased
   method returns compressed response by default, and pretty response in
   debug mode.
 
+Version 0.12.2
+--------------
+
+Released on May 16 2017
+
+- Fix a bug in `safe_join` on Windows.
+
 Version 0.12.1
 --------------
 
diff --git a/Flask.egg-info/PKG-INFO b/Flask.egg-info/PKG-INFO
index 42cb125..cb067be 100644
--- a/Flask.egg-info/PKG-INFO
+++ b/Flask.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Flask
-Version: 0.12.1
+Version: 0.12.2
 Summary: A microframework based on Werkzeug, Jinja2 and good intentions
 Home-page: http://github.com/pallets/flask/
 Author: Armin Ronacher
diff --git a/PKG-INFO b/PKG-INFO
index 42cb125..cb067be 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Flask
-Version: 0.12.1
+Version: 0.12.2
 Summary: A microframework based on Werkzeug, Jinja2 and good intentions
 Home-page: http://github.com/pallets/flask/
 Author: Armin Ronacher
diff --git a/docs/testing.rst b/docs/testing.rst
index 0737936..6fd7b50 100644
--- a/docs/testing.rst
+++ b/docs/testing.rst
@@ -41,7 +41,7 @@ In order to test the application, we add a second module
 
         def setUp(self):
             self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
-            flaskr.app.config['TESTING'] = True
+            flaskr.app.testing = True
             self.app = flaskr.app.test_client()
             with flaskr.app.app_context():
                 flaskr.init_db()
@@ -98,8 +98,10 @@ test method to our class, like this::
 
         def setUp(self):
             self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
+            flaskr.app.testing = True
             self.app = flaskr.app.test_client()
-            flaskr.init_db()
+            with flaskr.app.app_context():
+                flaskr.init_db()
 
         def tearDown(self):
             os.close(self.db_fd)
@@ -208,7 +210,7 @@ temporarily.  With this you can access the :class:`~flask.request`,
 functions.  Here is a full example that demonstrates this approach::
 
     import flask
-    
+
     app = flask.Flask(__name__)
 
     with app.test_request_context('/?name=Peter'):
diff --git a/flask/__init__.py b/flask/__init__.py
index 2fcb356..a9a873f 100644
--- a/flask/__init__.py
+++ b/flask/__init__.py
@@ -10,7 +10,7 @@
     :license: BSD, see LICENSE for more details.
 """
 
-__version__ = '0.12.1'
+__version__ = '0.12.2'
 
 # utilities we import from Werkzeug and Jinja2 that are unused
 # in the module but are exported as public interface.
diff --git a/flask/helpers.py b/flask/helpers.py
index c6c2cdd..4bb1d1c 100644
--- a/flask/helpers.py
+++ b/flask/helpers.py
@@ -619,18 +619,24 @@ def safe_join(directory, *pathnames):
     :raises: :class:`~werkzeug.exceptions.NotFound` if one or more passed
             paths fall out of its boundaries.
     """
+
+    parts = [directory]
+
     for filename in pathnames:
         if filename != '':
             filename = posixpath.normpath(filename)
-        for sep in _os_alt_seps:
-            if sep in filename:
-                raise NotFound()
-        if os.path.isabs(filename) or \
-           filename == '..' or \
-           filename.startswith('../'):
+
+        if (
+            any(sep in filename for sep in _os_alt_seps)
+            or os.path.isabs(filename)
+            or filename == '..'
+            or filename.startswith('../')
+        ):
             raise NotFound()
-        directory = os.path.join(directory, filename)
-    return directory
+
+        parts.append(filename)
+
+    return posixpath.join(*parts)
 
 
 def send_from_directory(directory, filename, **options):
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 3e2ea8c..9320ef7 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -515,7 +515,7 @@ class TestSendfile(object):
         assert rv.status_code == 416
         rv.close()
 
-        last_modified = datetime.datetime.fromtimestamp(os.path.getmtime(
+        last_modified = datetime.datetime.utcfromtimestamp(os.path.getmtime(
             os.path.join(app.root_path, 'static/index.html'))).replace(
             microsecond=0)
 
@@ -846,21 +846,20 @@ class TestStreaming(object):
 
 
 class TestSafeJoin(object):
-
     def test_safe_join(self):
         # Valid combinations of *args and expected joined paths.
         passing = (
-            (('a/b/c', ), 'a/b/c'),
-            (('/', 'a/', 'b/', 'c/', ), '/a/b/c'),
-            (('a', 'b', 'c', ), 'a/b/c'),
-            (('/a', 'b/c', ), '/a/b/c'),
-            (('a/b', 'X/../c'), 'a/b/c', ),
-            (('/a/b', 'c/X/..'), '/a/b/c', ),
+            (('a/b/c',), 'a/b/c'),
+            (('/', 'a/', 'b/', 'c/'), '/a/b/c'),
+            (('a', 'b', 'c'), 'a/b/c'),
+            (('/a', 'b/c'), '/a/b/c'),
+            (('a/b', 'X/../c'), 'a/b/c'),
+            (('/a/b', 'c/X/..'), '/a/b/c'),
             # If last path is '' add a slash
-            (('/a/b/c', '', ), '/a/b/c/', ),
+            (('/a/b/c', ''), '/a/b/c/'),
             # Preserve dot slash
-            (('/a/b/c', './', ), '/a/b/c/.', ),
-            (('a/b/c', 'X/..'), 'a/b/c/.', ),
+            (('/a/b/c', './'), '/a/b/c/.'),
+            (('a/b/c', 'X/..'), 'a/b/c/.'),
             # Base directory is always considered safe
             (('../', 'a/b/c'), '../a/b/c'),
             (('/..', ), '/..'),
@@ -874,12 +873,12 @@ class TestSafeJoin(object):
         failing = (
             # path.isabs and ``..'' checks
             ('/a', 'b', '/c'),
-            ('/a', '../b/c', ),
+            ('/a', '../b/c'),
             ('/a', '..', 'b/c'),
             # Boundaries violations after path normalization
-            ('/a', 'b/../b/../../c', ),
+            ('/a', 'b/../b/../../c'),
             ('/a', 'b', 'c/../..'),
-            ('/a', 'b/../../c', ),
+            ('/a', 'b/../../c'),
         )
 
         for args in failing:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/flask.git



More information about the Python-modules-commits mailing list