Opened 17 years ago
Closed 16 years ago
#2855 closed defect (fixed)
Trouble handling regular expressions
Reported by: | John Crean | Owned by: | Stephen Hansen |
---|---|---|---|
Priority: | normal | Component: | AnnouncerPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
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.
No email.
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.
Attachments (2)
Change History (5)
Changed 17 years ago by
Attachment: | asterisk.patch added |
---|
comment:1 Changed 16 years ago by
I still think this is a weak solution, as if you save multiple times, the '*' keeps getting expanded.
- = .* .* = .. .. = ...*
big trouble.
The substitution should happen right before the evaluation of the wiki page name, and kept in glob format in the DB. My patch is still weak, but a little better. I'm willing to bet there is a python library to match globs. Or you could just use regexes instead.
Changed 16 years ago by
Attachment: | astrisk.patch added |
---|
move glob to regex code to query instead of save to avoid duplicate replacements
Patch to wiki.py that now allows it to properly handle asterisks in the subscriptions