You are here: Foswiki>Tasks Web>Item13320 (05 Jul 2015, GeorgeClark)Edit Attach

Item13320: Backlinks fails when is an number in the topic name

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component:
Branches: master
Reported By: JozefMojzis
Waiting For:
Last Change By: GeorgeClark

Backlinks fails with error message

Backlinks to Test2Topic in Sandbox Web (Search all webs)

Could not perform search. Error was: Unmatched ) in regex; marked by <-- HERE in m/Test2Topic([^A-Za-z0-9]|$)|Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?) <-- HERE Topic([^A-Za-z0-9]|$)|Sandbox.Test2Topic([^A-Za-z0-9]|$)/

How to reproduce - what I did.

dir=fwtest
mkdir -p $dir
cd $dir
git clone https://github.com/foswiki/distro foswiki
cd "foswiki/core"
perl -T ./pseudo-install.pl developer
(cd tools && perl -I ../lib rewriteshebang.pl)
tools/lighttpd.pl

After

  • Configure, Save go to wiki
  • go to Sandbox
  • create a topic with a name "Test2Topic"
  • simply save it
  • click the Backlinks link

tango:core $ perl -v

This is perl 5, version 20, subversion 1 (v5.20.1) built for darwin-thread-multi-2level

tango:core $ uname -a
Darwin tango.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64

-- JozefMojzis - 23 Mar 2015

This has something to do with the way the backlinks.tmpl is building the search.

Could you please put these two lines into your Test2Topic on your system and see how they expand?

   * search="%TOPIC%([^A-Za-z0-9]|$)|%SPACEOUT{"%TOPIC%" separator="([^A-Za-z0-9]*?)"}%([^A-Za-z0-9]|$)|%WEB%.%TOPIC%([^A-Za-z0-9]|$)"
   * search="%WEB%.%TOPIC%([^A-Za-z0-9]|$)|%WEB%.%SPACEOUT{"%TOPIC%" separator="([^A-Za-z0-9]*?)"}%([^A-Za-z0-9]|$)"

Here is what I get on my system where the regexes work:

   * search="Test2Topic([^A-Za-z0-9]|$)|Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?)Topic([^A-Za-z0-9]|$)|Litterbox.Test2Topic([^A-Za-z0-9]|$)"
   * search="Litterbox.Test2Topic([^A-Za-z0-9]|$)|Litterbox.Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?)Topic([^A-Za-z0-9]|$)"

On my system got the same

   * search="Test2Topic([^A-Za-z0-9]|$)|Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?)Topic([^A-Za-z0-9]|$)|Sandbox.Test2Topic([^A-Za-z0-9]|$)"
   * search="Sandbox.Test2Topic([^A-Za-z0-9]|$)|Sandbox.Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?)Topic([^A-Za-z0-9]|$)"

Test([^A-Za-z0-9]*?)2([^A-Za-z0-9]*?)Topic

-- GeorgeClark - 23 Mar 2015

  • Test([^A-Za-z0-9]*?)2([^A-Za-z0-9]*?)Topic([^A-Za-z0-9]|$)
  • Test([^A-Za-z0-9]*?)2([^A-Za-z([^A-Za-z0-9]*?)0-9]*?)Topic([^A-Za-z0-9]

-- GeorgeClark - 23 Mar 2015

diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm
index 0cc66a5..e820f94 100644
--- a/core/lib/Foswiki.pm
+++ b/core/lib/Foswiki.pm
@@ -3100,12 +3100,14 @@ sub spaceOutWikiWord {
     # Both could have the value 0 so we cannot use simple = || ''
     $word = defined($word) ? $word : '';
     $sep  = defined($sep)  ? $sep  : ' ';
-    $word =~ s/([$regex{upperAlpha}])([$regex{numeric}])/$1$sep$2/g;
-    $word =~ s/([$regex{numeric}])([$regex{upperAlpha}])/$1$sep$2/g;
+    my $mark = "\001";
+    $word =~ s/([$regex{upperAlpha}])([$regex{numeric}])/$1$mark$2/g;
+    $word =~ s/([$regex{numeric}])([$regex{upperAlpha}])/$1$mark$2/g;
     $word =~
-      s/([$regex{lowerAlpha}])([$regex{upperAlpha}$regex{numeric}]+)/$1$sep$2/g;
+s/([$regex{lowerAlpha}])([$regex{upperAlpha}$regex{numeric}]+)/$1$mark$2/g;
     $word =~
-s/([$regex{upperAlpha}])([$regex{upperAlpha}])(?=[$regex{lowerAlpha}])/$1$sep$2/g;
+s/([$regex{upperAlpha}])([$regex{upperAlpha}])(?=[$regex{lowerAlpha}])/$1$mark$2/g;
+    $word =~ s/$mark/$sep/g;
     return $word;
 }

Fix!

-- GeorgeClark - 23 Mar 2015

 

ItemTemplate edit

Summary Backlinks fails when is an number in the topic name
ReportedBy JozefMojzis
Codebase
SVN Range
AppliesTo Engine
Component
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:cedd32a166da
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:cedd32a166da
ItemBranchCheckins
Release01x01Checkins
Topic revision: r5 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy