File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,15 @@ We strongly recommend that you upgrade pip to version 9+ of pip before upgrading
2222 ``pip --version ``.
2323
2424
25+ .. _release-6.1.5 :
26+
27+ 6.1.5
28+ -----
29+
30+ 6.1.5 is a security release, fixing one vulnerability:
31+
32+ - Fix open redirect vulnerability GHSA-c7vm-f5p4-8fqh (CVE to be assigned)
33+
2534.. _release-6.1.4 :
2635
27366.1.4
Original file line number Diff line number Diff line change @@ -854,13 +854,18 @@ def get(self):
854854
855855class TrailingSlashHandler (web .RequestHandler ):
856856 """Simple redirect handler that strips trailing slashes
857-
857+
858858 This should be the first, highest priority handler.
859859 """
860-
860+
861861 def get (self ):
862- self .redirect (self .request .uri .rstrip ('/' ))
863-
862+ path , * rest = self .request .uri .partition ("?" )
863+ # trim trailing *and* leading /
864+ # to avoid misinterpreting repeated '//'
865+ path = "/" + path .strip ("/" )
866+ new_uri = "" .join ([path , * rest ])
867+ self .redirect (new_uri )
868+
864869 post = put = get
865870
866871
@@ -911,6 +916,7 @@ def get(self):
911916 url = sep .join ([self ._url , self .request .query ])
912917 self .redirect (url , permanent = self ._permanent )
913918
919+
914920class PrometheusMetricsHandler (IPythonHandler ):
915921 """
916922 Return prometheus metrics for this notebook server
Original file line number Diff line number Diff line change 33from nose .tools import assert_regex , assert_not_regex
44
55from notebook .base .handlers import path_regex
6+ from notebook .utils import url_path_join
7+ from .launchnotebook import NotebookTestBase
68
79# build regexps that tornado uses:
810path_pat = re .compile ('^' + '/x%s' % path_regex + '$' )
911
12+
1013def test_path_regex ():
1114 for path in (
1215 '/x' ,
@@ -30,3 +33,18 @@ def test_path_regex_bad():
3033 '/y/x/foo' ,
3134 ):
3235 assert_not_regex (path , path_pat )
36+
37+
38+ class RedirectTestCase (NotebookTestBase ):
39+ def test_trailing_slash (self ):
40+ for uri , expected in (
41+ ("/notebooks/mynotebook/" , "/notebooks/mynotebook" ),
42+ ("////foo///" , "/foo" ),
43+ ("//example.com/" , "/example.com" ),
44+ ("/has/param/?hasparam=true" , "/has/param?hasparam=true" ),
45+ ):
46+ r = self .request ("GET" , uri , allow_redirects = False )
47+ print (uri , expected )
48+ assert r .status_code == 302
49+ assert "Location" in r .headers
50+ assert r .headers ["Location" ] == url_path_join (self .url_prefix , expected )
You can’t perform that action at this time.
0 commit comments