• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5509: IF & query String matching may be incorrectly greedy.

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Urgent Closed   patch 4.2.1, 5.0.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

it appears to me that

IF{"'SomeTextToTestFor' ~ 'Test'" ... is incorrectly returning true

  • DEMO: false

similarly (and probably more fatally) IF{"'SomeTextToTestFor' ~ '*Test'" ... is incorrectly returning true

  • DEMO: false

it seems that there are wildcards added to any ~ test, making it ?impossible? to test for the begining and end of a string.

as ~ '*Test*' is already able to match any occurance of Test within the test string, this is an issue that requces the functionality of query and IF.

-- TWiki:Main/SvenDowideit - 09 Apr 2008

You are right.

Index: UnitTestContrib/test/unit/QueryTests.pm
===================================================================
--- UnitTestContrib/test/unit/QueryTests.pm   (revision 16418)
+++ UnitTestContrib/test/unit/QueryTests.pm   (working copy)
@@ -155,7 +155,13 @@
     $this->check("string~'String '", 0);
     $this->check("string='Str'", 0);
     $this->check("string~'?trin?'", 1);
+    $this->check("string~'*'", 1);
     $this->check("string~'*String'", 1);
+    $this->check("string~'*trin*'", 1);
+    $this->check("string~'*in?'", 1);
+    $this->check("string~'??????'", 1);
+    $this->check("string~'???????'", 0);
+    $this->check("string~'?????'", 0);
     $this->check("string~' String'", 0);
     $this->check("string!='Str'", 1);
     $this->check("string!='String '", 1);
Index: core/lib/TWiki/Query/Node.pm
===================================================================
--- core/lib/TWiki/Query/Node.pm   (revision 16587)
+++ core/lib/TWiki/Query/Node.pm   (working copy)
@@ -307,7 +307,7 @@
             $expr =~ s/\\\?/./g;
             $expr =~ s/\\\*/.*/g;
             defined($_[0]) && defined($_[1]) &&
-              $_[0] =~ m/$expr/ ? 1 : 0;
+              $_[0] =~ m/^$expr$/ ? 1 : 0;
         } );
 }

-- CrawfordCurrie - 10 Apr 2008

Does this get checked in or???

-- TWiki:Main.KennethLavrsen - 10 Apr 2008

Yes I will be working on these bugs soon, I wanted to confirm with Crawford (done) and give others the oportunity to comment in case changing this has some important sideeffect.

-- SvenDowideit - 10 Apr 2008

ItemTemplate
Summary IF & query String matching may be incorrectly greedy.
ReportedBy TWiki:Main.SvenDowideit
Codebase 4.2.0, ~twiki4
SVN Range TWiki-5.0.0, Thu, 03 Apr 2008, build 16612
AppliesTo Engine
Component

Priority Urgent
CurrentState Closed
WaitingFor

Checkins TWikirev:16644 TWikirev:16645
TargetRelease patch
ReleasedIn 4.2.1, 5.0.0
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r9 - 2008-08-04 - KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback