1. Kenneth Gonsalves
  2. fossconf
  3. Issues
Issue #34 new

Regexp matching bug

Thejaswi Puthraya
created an issue

The regexp used for addreqtalk in web/urls.py doesn't match correctly and causes TemplateSyntaxErrors due to no proper reverse found.

Here is an explanation for it...

{{{

!python

r=re.compile('/((?P<id>\d+)/)?') a='/102/' b='/102' c='/' r.match(a).groupdict() {'id': '102'} r.match(b).groupdict() {'id': None} r.match(c).groupdict() {'id': None}

r=re.compile('/(?P<id>\d+)?/?') r.match(a).groupdict() {'id': '102'} r.match(b).groupdict() {'id': '102'} r.match(c).groupdict() {'id': None}

}}}

The diff for it is given below (and also uploaded)...

{{{

!diff

diff -r 408003d2e35b web/urls.py --- a/web/urls.py Thu Oct 22 00:14:20 2009 +0530 +++ b/web/urls.py Thu Oct 22 10:10:15 2009 +0530 @@ -39,9 +39,9 @@ url(r'^message/(?P<msg>[\w\s]+)/$', 'message', name='message'), #request talk url(r'^requesttalk/$', 'requesttalk', name='request_talk'), - url(r'^addreqtalk/((?P<id>\d+)/)?$', 'addreqtalk', name='add_request_talk'), + url(r'^addreqtalk/(?P<id>\d+)?/?$', 'addreqtalk', name='add_request_talk'), #bulkmail - url(r'^bulkmail/((?P<sstr>\w+)/)?$', 'bulkmail', name='bulk_mail'), + url(r'^bulkmail/(?P<sstr>\w+)?/?$', 'bulkmail', name='bulk_mail'), url(r'^mailsent/$', 'mailsent', name='mail_sent'), #tags support url(r'^talks/tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,

}}}

Comments (1)

  1. Log in to comment