From 3faec0800eeb36499ead3e0f892201ff74ab8861 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 25 Jun 2015 10:45:48 -0400 Subject: Allow all RFC3986-specified characters in explicit path segments. Change-Id: I37635b153bde00e47904f94ed212e03f4dd708e9 --- pecan/routing.py | 4 +++- pecan/tests/test_base.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pecan/routing.py b/pecan/routing.py index 29a294c..aed8ad5 100644 --- a/pecan/routing.py +++ b/pecan/routing.py @@ -42,7 +42,9 @@ def route(*args): if not isinstance(route, six.string_types): raise TypeError('%s must be a string' % route) - if not re.match('^[0-9a-zA-Z-_$\(\),;:]+$', route): + if route in ('.', '..') or not re.match( + '^[0-9a-zA-Z-_$\(\)\.~!,;:*+@=]+$', route + ): raise ValueError( '%s must be a valid path segment. Keep in mind ' 'that path segments should not contain path separators ' diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index 785b522..5baab91 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -2231,6 +2231,13 @@ class TestExplicitRoute(PecanTestCase): 'path(with-parens)', 'path;with;semicolons', 'path:with:colons', + 'v2.0', + '~username', + 'somepath!', + 'four*four', + 'one+two', + '@twitterhandle', + 'package=pecan' ): handler = C() route(C, path, handler) -- cgit v1.2.1