From a9465a75de3d233df1a5e03b35835590369b1a30 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 1 Sep 2008 23:03:03 +0000 Subject: [PATCH] Fixed a case of incorrect parsing of quanitifers in reg-exp patterns. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8825 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/regex_helper.py | 1 + tests/regressiontests/urlpatterns_reverse/tests.py | 1 + tests/regressiontests/urlpatterns_reverse/urls.py | 1 + 3 files changed, 3 insertions(+) diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py index 545bf8899c..996e391707 100644 --- a/django/utils/regex_helper.py +++ b/django/utils/regex_helper.py @@ -248,6 +248,7 @@ def get_quantifier(ch, input_iter): while ch != '}': ch, escaped = input_iter.next() quant.append(ch) + quant = quant[:-1] values = ''.join(quant).split(',') # Consume the trailing '?', if necessary. diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py index ff94196a92..f743af36dd 100644 --- a/tests/regressiontests/urlpatterns_reverse/tests.py +++ b/tests/regressiontests/urlpatterns_reverse/tests.py @@ -50,6 +50,7 @@ test_data = ( ('mixed', '/john/0/', [], {'name': 'john'}), ('repeats', '/repeats/a/', [], {}), ('repeats2', '/repeats/aa/', [], {}), + ('repeats3', '/repeats/aa/', [], {}), ('insensitive', '/CaseInsensitive/fred', ['fred'], {}), ('test', '/test/1', [], {}), ('test2', '/test/2', [], {}), diff --git a/tests/regressiontests/urlpatterns_reverse/urls.py b/tests/regressiontests/urlpatterns_reverse/urls.py index 1adefbe0a3..0f66346337 100644 --- a/tests/regressiontests/urlpatterns_reverse/urls.py +++ b/tests/regressiontests/urlpatterns_reverse/urls.py @@ -35,6 +35,7 @@ urlpatterns = patterns('', url(r'^(?P.+)/\d+/$', empty_view, name="mixed"), url(r'^repeats/a{1,2}/$', empty_view, name="repeats"), url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"), + url(r'^repeats/a{2}/$', empty_view, name="repeats3"), url(r'^(?i)CaseInsensitive/(\w+)', empty_view, name="insensitive"), url(r'^test/1/?', empty_view, name="test"), url(r'^(?i)test/2/?$', empty_view, name="test2"),