Bug:
%SEARCH{"http://koala.ilog.fr/twikiirc/bin/irclogger_logs/twiki", scope=topic, format="| $pattern(\r\n(.*).*) | $pattern(\r\n.*\(.*\).*) |"}%
--
MartinCleaver - 12 Feb 2004
Test case
%SEARCH{"http://koala.ilog.fr/twikiirc/bin/irclogger_logs/twiki", scope=topic, format="| $pattern(\r\n(.*).*) | $pattern(\r\n.*\(.*\).*) |"}%
Environment
TWiki version: |
? |
TWiki plugins: |
? |
Server OS: |
? |
Web server: |
? |
Perl version: |
? |
Client OS: |
N/A |
Web Browser: |
N/A |
--
WillNorris - 18 Feb 2004
Follow up
Martin, your search gives me an error
/\r\n(.*/: unmatched () in regexp at /home/groups/t/tw/twiki/cgi-bin/TWiki/Search.pm line 1041.
which I presume indicates a bug with Search.pm. I'll leave it up to you to file a bug report in the hopes that you have a better idea than I of what's going on.
--
MattWilkie - 12 Feb 2004
moved here from
TWikiIRC --
WillNorris - 18 Feb 2004
The issue is that when TWiki looks for
$pattern()
syntax in a
FormattedSearch, it looks for "$pattern(", the pattern, ".*)". If there is a ".*)" actually present in the pattern string the pattern will be considered to end prematurely at that point. When TWiki then procedes to attempt to use that pattern the lack of at least one ')' (the one stripped off as the end paren of the $pattern() syntax) causes this error. As a workaround you can use change ".*)" to ".* *)", which has the same behavior regex-wise but doesn't exhibit this problem.
--
WalterMundt - 20 Feb 2004
Presumably this is something that Perl's
quotemeta()
or
/\Q$patt$E/
on the pattern would fix? See
perldoc -f quotemeta
for the details.
--
RichardDonkin - 20 Feb 2004
Yes, that would fix it, but it would also disable all regex power like
[0-9]+
and introduce incompatibilities. The correct way is to scan for exact pairs of parenthesis. I will fix that.
Although above syntax has problems (search for URL on topic name; pattern
$pattern(\r\n.*\(.*\).*)
with missing capturing parens due to escaping), TWiki should never produce an internal error.
--
PeterThoeny - 21 Feb 2004
Proper parentheses matching would do it, but might introduce performance implications (I don't know). Another approach is the one I mention in the
FormattedSearch page: add something at the start and end that won't show usually show up in a regex. E.g. introduce a new syntax
$pattern([[<the pattern>]])
and deprecate the old. Regex matching works neatly and the extra punctuation isn't that much of a hurdle to people who are already writing regular expressions anyway.
We could do both, of course.
--
WalterMundt - 21 Feb 2004
I prefer not to introduce a new syntax just to get around a problem with user supplied syntax. However, a new
FormattedSearchWithSubstitution would be a logical extension.
--
PeterThoeny - 24 Feb 2004
Fix record
This is now fixed in
TWikiAlphaRelease and TWiki.org. The regex match is now in an eval block and fails gracefully if there is a problem with the pattern.
--
PeterThoeny - 24 Feb 2004