Trouble handling regular expressions
|Reported by:||creanium||Owned by:||ixokai|
In testing out the installation, I wanted to try out global Wiki subscriptions as we have a Trac instance to which we post meeting announcements and Minutes and would like messages to always go out.
I went into my preferences and entered a single Wiki subscription: * and clicked save.
The page reloaded and I noticed what I entered as simply "*" was now ".*?". Cool, I thought, it just converted it to regular expression, no biggy.
When I saved the page again, however, what was previously ".*?" was now "..*??". Uh oh, a replace error.
So I went in and fixed it again, to just "*".
Then I tried creating a new Wiki page to see if I would get notified.
I checked the Trac log, and the following was in it:
2008-04-03 18:45:05,364 Trac[api] ERROR: AnnouncementSystem failed. Traceback (most recent call last): File "build/bdist.linux-i686/egg/announcerplugin/api.py", line 355, in _real_send File "build/bdist.linux-i686/egg/announcerplugin/api.py", line 355, in <genexpr> File "/usr/local/lib/python2.5/site-packages/AnnouncerPlugin-0.2-py2.5.egg/announcerplugin/subscribers/wiki.py", line 24, in get_subscriptions_for_event for name, authenticated in self._get_membership(page.name): File "/usr/local/lib/python2.5/site-packages/AnnouncerPlugin-0.2-py2.5.egg/announcerplugin/subscribers/wiki.py", line 47, in _get_membership if re.match(pat, name): File "/usr/local/lib/python2.5/re.py", line 137, in match return _compile(pattern, flags).match(string) File "/usr/local/lib/python2.5/re.py", line 241, in _compile raise error, v # invalid expression error: nothing to repeat
Okay, I added a line of debug output to see what it was trying to RegEx match.
Trac[wiki] DEBUG: Checking re.match(*, WikiStart)
Oh no wonder, so I stepped through wiki.py and found where the replacements were supposed to be happening and realized the escape character handler was parsing in the wrong order.
So, attached is the patch I did that on wiki.py that now allows a * subscription to work.