summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2015-01-17 14:23:22 -0800
committerBen Bangert <ben@groovie.org>2015-01-17 14:23:22 -0800
commit6329370142f5c4986db6f935626a046a7d1b71ca (patch)
tree5294bb68eeda0f5ae08d73015ebd640e5fa21a21
parent4baf95808cbbab4db6ee2e6e9a54109b9b23a3f3 (diff)
downloadroutes-6329370142f5c4986db6f935626a046a7d1b71ca.tar.gz
* Fix 3 other route matching groups in route.py to use anonymous groups for
optional sections to avoid exceeding regex limits. Fixes #15.
-rw-r--r--CHANGELOG.rst2
-rw-r--r--routes/route.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index dc2aa4a..9fc398b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -3,6 +3,8 @@ Routes Changelog
Release 2.1 (**dev**)
=====================
+* Fix 3 other route matching groups in route.py to use anonymous groups for
+ optional sections to avoid exceeding regex limits. Fixes #15.
* Printing a mapper now includes the Controller/action parameters from the
route. Fixes #11.
* Fix regression that didn't allow passing in params 'host', 'protocol', or
diff --git a/routes/route.py b/routes/route.py
index ea14b1f..901b4f6 100644
--- a/routes/route.py
+++ b/routes/route.py
@@ -424,7 +424,7 @@ class Route(object):
# our regexp first. It's still possible we could be completely
# blank as we have a default
if var in self.reqs and var in self.defaults:
- reg = '(' + partreg + rest + ')?'
+ reg = '(?:' + partreg + rest + ')?'
# Or we have a regexp match with no default, so now being
# completely blank form here on out isn't possible
@@ -454,7 +454,7 @@ class Route(object):
# something else in the chain does have req's though, we have
# to make the partreg here required to continue matching
if allblank and var in self.defaults:
- reg = '(' + partreg + rest + ')?'
+ reg = '(?:' + partreg + rest + ')?'
# Same as before, but they can't all be blank, so we have to
# require it all to ensure our matches line up right
@@ -490,7 +490,7 @@ class Route(object):
noreqs = False
elif part and part[-1] in self.done_chars:
if allblank:
- reg = re.escape(part[:-1]) + '(' + re.escape(part[-1]) + rest
+ reg = re.escape(part[:-1]) + '(?:' + re.escape(part[-1]) + rest
reg += ')?'
else:
allblank = False