Bug: GNU egrep Breaks with Escaped Curly Brace
GNU egrep (as of version 2.4.2) breaks on \{\} which is used in METASEARCH. My version gives the log entry
"egrep: Invalid content of \{\}"
in Apache's error log.
The GNU grep manpage says the following about this:
Traditional egrep did not support the { metacharacter, and some egrep implementations support \{ instead, so portable scripts
should avoid { in egrep patterns and should use [{] to match a literal {.
The following should fix that bug:
--- TWiki.pm.old Sat Feb 1 18:55:21 2003
+++ TWiki.pm Thu May 1 22:45:51 2003
@@ -1435,10 +1435,10 @@
my $searchWeb = "all";
if( $attrType eq "topicmoved" ) {
- $searchVal = "%META:TOPICMOVED\{.*from=\\\"$attrWeb\.$attrTopic\\\".*\}%";
+ $searchVal = "%META:TOPICMOVED[{].*from=\\\"$attrWeb\.$attrTopic\\\".*[}]%";
} elsif ( $attrType eq "parent" ) {
$searchWeb = $attrWeb;
- $searchVal = "%META:TOPICPARENT\{.*name=\\\"($attrWeb\\.)?$attrTopic\\\".*\}%";
+ $searchVal = "%META:TOPICPARENT[{].*name=\\\"($attrWeb\\.)?$attrTopic\\\".*[}]%";
}
my $text = &TWiki::Search::searchWeb( "1", $searchWeb, $searchVal, "",
And works on my Debian Linux 3.0r1 stable (Woody).
Test case
Attempt to perform a METASEARCH, such as the following:
%METASEARCH{type="parent" web="Codev" topic="GNUEgrepBreaksWithEscapedCurlyBrace" title="Related: "}%
Environment
TWiki version: |
01 Feb 2003 |
TWiki plugins: |
SlideShowPlugin, BugzillaLinkPlugin |
Server OS: |
Debian Linux 3.0r1 stable (Woody) |
Web server: |
Apache 1.3.26 |
Perl version: |
5.6.1 |
Client OS: |
Debian Linux unstable (Sid) |
Web Browser: |
Konqueror (as of KDE 3.1.1) |
--
AlanShields - 02 May 2003
Follow up
Fix record
Now fixed in
TWikiAlphaRelease - thanks for the patch!
--
RichardDonkin - 02 May 2003
Category:
TWikiPatches
I get a crash when I run TWiki on a DEC Unix system which does not have GNU egrep, but
rather a DEC implementation. The error is similar to the one that your patch is intended
to fix. But I fixed it by adding more back slash around squiggly brackets in the grep command line.
Here is my patch to Search.pm
290c290,296
< $tempVal = `$acmd`;
>
> #PJ Fix 2003-06-18
> $acmd =~ s/(\{)/\\\{/ ;
> $acmd =~ s/(\})/\\}/ ;
>
>
> $tempVal = `$acmd`;
That works, but I found it by trial and error. Their man page calls for back slashes to protect squiggly braces.
I will try your fix above to see if it works too. But I was curious to ask if you know if these two things are related issues.
--
PaulJohnson