You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/06/03 16:05:24 UTC
[allura] 02/12: [#8361] only strings for dispatch paths
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 84a477c5fef2cd6617a4c671132479c9da4a1a8a
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri May 8 17:19:48 2020 -0400
[#8361] only strings for dispatch paths
---
Allura/allura/controllers/rest.py | 6 +++++-
Allura/allura/tests/functional/test_root.py | 7 +++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index a243f62..ee6548e 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -309,6 +309,10 @@ def nbhd_lookup_first_path(nbhd, name, current_user, remainder, api=False):
prefix = nbhd.shortname_prefix
pname = unquote(name)
pname = six.ensure_text(pname) # we don't support unicode names, but in case a url comes in with one
+ try:
+ pname.encode('ascii')
+ except UnicodeError:
+ raise exc.HTTPNotFound
provider = plugin.ProjectRegistrationProvider.get()
try:
provider.shortname_validator.to_python(pname, check_allowed=False, neighborhood=nbhd)
@@ -324,7 +328,7 @@ def nbhd_lookup_first_path(nbhd, name, current_user, remainder, api=False):
if project is None:
# look for neighborhood tools matching the URL
project = nbhd.neighborhood_project
- return project, (pname.encode('utf-8'),) + remainder # include pname in new remainder, it is actually the nbhd tool path
+ return project, (pname,) + remainder # include pname in new remainder, it is actually the nbhd tool path
if project and prefix == 'u/':
# make sure user-projects are associated with an enabled user
user = project.user_project_of
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 014c093..a9cecb0 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -31,6 +31,8 @@ Please read http://pythonpaste.org/webtest/ for more information.
from __future__ import unicode_literals
from __future__ import absolute_import
import os
+
+import six
from six.moves.urllib.parse import quote
from tg import tmpl_context as c
@@ -103,8 +105,9 @@ class TestRootController(TestController):
self.app.get('/', headers=dict(Accept=str(hdr)), validate_skip=True)
def test_encoded_urls(self):
- # not valid unicode
- self.app.get(b'/foo\xFF', status=400)
+ if six.PY2:
+ # not valid unicode
+ self.app.get(b'/foo\xFF', status=400)
self.app.get('/foo%FF', status=400)
# encoded
self.app.get('/foo%C3%A9', status=404)