Tags:
create new tag
view all tags

Question

Paul E. Johnson, Dept. of Political Science, University of Kansas pauljohn@kuPLEASENOSPAM.edu

I'm running TWiki this edition, which I recently signed up for/downloaded: TWiki20011201.tar.gz on a DEC/Compac Alpha system. I'm running under cgiwrap, but most everything is normal. I have some unusual things on this system, such as the fact that cgiwrap ignores .htaccess, but I think I have found good workarounds:

http://www.ku.edu/cgiwrap/pauljohn/twiki/view

My Twiki mostly works. HOWEVER, the "More" command however causes a crash, and the error output (in the cgiwrap diagnostic) is this:

invalid \{ \} repetition

Followed by the web page it intends to deliver. But the page does not display because of the error.

I've dug through the source code and isolated the cause of the trouble. It is the line

$tempVal = `$cmd`;

in TWiki/Search.pm. The error is an egrep error message, because it is trying to use unescaped curly brackets in the command line. I've intercepted the value of $cmd and tried it on the command line, it says

> $ /bin/egrep -i -l '%META:TOPICPARENT{.*name=\"(Main\.)?WebHome\".*}%'
> *.txt
> invalid \{ \} repetition

If I escape the {} I don't get that error and my TWiki works.

Here is the patch which fixes the problem I see due to that one line in Search.pm

*** /homea/pauljohn/src/Twiki/lib/TWiki/Search.pm       Fri Nov 30 13:36:02 2001
--- ./Search.pm Thu Dec  5 17:37:01 2002
***************
*** 204,209 ****
--- 204,215 ----
          $cmd = "%GREP% %SWITCHES% -l $TWiki::cmdQuote$theSearchVal$TWiki::cmdQuote *.txt";
      }
+     #here is my fix, pj 2002-12-05
+ 
+       $cmd =~ s/(\{)/\\\{/ ;
+       $cmd =~ s/(\})/\\\}/ ;
+ 
+ 
      if( $caseSensitive ) {
          $tempVal = "";
      } else {

So long, thanks for all the cool fun I've had looking at TWiki

-- TWikiGuest - 06 Dec 2002

Answer

I moved this question from the bug entry in the Codev web to the Support web. Thanks for investigating, it must have taken a while to debug it!

Guessing here: Not sure why it did not work out of the box. It could be caused by an old Perl version (check RequiredEnvironmentForTWiki) or a TWiki installation issue. egrep does not get '%META:TOPICPARENT{...}%', it should get the expanded value of the meta variable, so the curley brackets should never get to egrep.

-- PeterThoeny - 06 Dec 2002

Question Again

I have Perl 5.6.0, so I don't think that would explain it. But I do understand your point that the META variable is not being expanded. I will try to find why that one particular META variable does not get digested. Can you tell me how the {} are eliminated from the expression? I mean, which of the TWiki.pm elements hacks them out? And what should that egrep cmd line look like if it is properly substitued?


It might help if you download the latest testenv and attach its output - see SupportGuidelines for a link. This would provide a lot more info about your setup, but it still sounds a bit weird. As for the code, have a look at TWikiDebugging to put in some writeDebug calls into handleMetaSearch, which implements the METASEARCH embedded in oopsmore.tmpl that finds child topics. Then maybe get into the Search::searchWeb routine and do the same there until you find out where it's getting confused. This might be a quoting issue, either in Perl or the shell - worth checking the SHELL variable as seen from your web server.

5.6.0 is a somewhat old Perl version so it's possible there are bugs that affect TWiki, perhaps on Alphas only, though unlikely. Most people are using 5.6.1 or 5.005_03.

As a workaround, you could update the template to remove this meta search, allowing you to use the rest of the More page.

-- RichardDonkin - 07 Dec 2002


Followup: Are you both mistaken?

With the maximum amount of respect and courtesy, I hate to say I think both of you are wrong smile It is all a problem of egrep implementation on this system I'm looking at.

I think you are both not reading the TWiki source code correctly. I believe that TWiki.pm's "handleMetaSearch" method really does intend to insert the %META:TOPICPARENT stuff into the egrep command. Here is the relevant code from handleMetaSearch:

    
    if( $attrType eq "topicmoved" ) {
       $searchVal = "%<nop>META:<nop>TOPICMOVED\{.*from=\\\"$attrWeb\.$attrTopic\\\".*\}%";
       } elsif ( $attrType eq "parent" ) {
       $searchWeb = $attrWeb;
       $searchVal = "%<nop>META:<nop>TOPICPARENT\{.*name=\\\"($attrWeb\\.)?$attrTopic\\\".*\}%";
   }

It inserts that stuff into the searchVal because the egrep in TWiki::Search.pm searches through the text files. In those text files there are lines that start with %META:TOPICPARENT, as in, from one of the text files:

So, above, when I note that TWiki is trying to run an egrep line like this:

/bin/egrep -i -l '%META:TOPICPARENT{.*name=\"(Main\.)?WebHome\".*}%'

I think that is correct. I think Peter is mistaken to think that the META characters in this command are suppose to have been replaced at this stage. TWiki is really intending to do exactly this, and on a Linux system it does not cause an error.

However, on the DEC Alpha under the Compaq TRU64 OS, egrep crashes unless the braces are escaped.

I may try to find the GNU version of egrep and install it on that system to see if the problem goes away.

From the look of things, however, it appears to me that the back slashes in the egrep command don't do any harm on a Linux system and it makes sense to me that they should be there.

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2002-12-07 - TWikiGuest
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.