New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
You are here: Foswiki>Tasks Web>Item10671 (17 Dec 2011, GeorgeClark)Edit Attach

Item10671: rename not handling anchored links

Priority: Normal
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Engine
Component: FoswikiRender, FoswikiUIRename
Reported By: DrakeDiedrich
Waiting For:
Last Change By: GeorgeClark
It looks to me as if the rename script has never been able to update links with anchors in other topics.

For example, LinksToAnchor referred to PageWithAnchor#bug. PageWithAnchor was renamed to MovedPageWithAnchor. Sandbox/LinksToAnchor still refers to PageWithAnchor#bug, even though PageWithAnchor was listed as a topic that would be updated and remained checked.

I'll attach a test script that demonstrates where I think this originates: Foswiki::Render::getReferenceRE not matching anchored text, though it sounds like there might be reasons it doesn't.

-- DrakeDiedrich - 22 Apr 2011

Confirmed. The rename search doesn't deal with anchors. RenameTests uses the following as the "standard topic" containing all topic references We need to add all the supported style of anchor links and adjust the regex, as well as any cases where the link should not be renamed. Thanks for providing the test script.

    # Topic text that contains all the different kinds of topic reference
    my $originaltext = <<THIS;
1 $this->{test_web}.OldTopic
$this->{test_web}.OldTopic 2
3 $this->{test_web}.OldTopic more
OldTopic 4
5 OldTopic
6 !OldTopic
6A <nop>OldTopic
6B <nop> OldTopic
6C ! OldTopic
7 (OldTopic)
8 [[$this->{test_web}.OldTopic]]
9 [[OldTopic]]
10 [[$this->{test_web}.OldTopic][the text]]
11 [[OldTopic][the text]]
12 $this->{test_web}.NewTopic
13 $this->{new_web}.OldTopic
14 OtherTopic
15 $this->{test_web}.OtherTopic
16 $this->{new_web}.OtherTopic
17 MeMeOldTopicpick$this->{test_web}.OldTopicme
18 http://site/$this->{test_web}/OldTopic
19 [[http://blah/OldTopic/blah][ref]]
20 random Random ranDom
21 $this->{test_web}.random $this->{test_web}.Random $this->{test_web}.ranDom
protected $this->{test_web}.OldTopic
pre $this->{test_web}.OldTopic
protected $this->{test_web}.OldTopic
rename [[OldTopic]]
rename [[$this->{test_web}.OldTopic]]
22 %INCLUDE{"OldTopic"}%
23 %INCLUDE{"$this->{test_web}.OldTopic"}%
24 "OldTopic, OtherTopic"
25 =OldTopic Fixed link to OldTopic=
26 *OldTopic Bold link to OldTopic*
27 _OldTopic Italic link to OldTopic_

Adding possibly?

28 OldTopic#anchor
29 $this->{test_web}.OldTopic#anchor
30 [[$this->{test_web}.OldTopic#anchor]]
31 [[OldTopic#anchor]]
32 http://site/$this->{test_web}/OldTopic#anchor
33 https://site/$this->{test_web}/OldTopic#anchor

I'm committing a possible fix against trunk - if you have a chance to check it out, please let me know. The revised unit tests pass. See the patch at distro:ead16fb4cedf

-- GeorgeClark - 23 Apr 2011

And your test script runs as well:
perl ./getreferencere.t
(?m-xis:^|(?<=[\s"\*=_\(]))(Main\.)?TestPage(?m-xis:$|(?=[\s"\*#=_,.;:!?)]))|(?<=\[\[)(Main\.)?[Tt]est *[Pp]age(?=(?:#.*?)?\][][])ok 1 - Main.TestPage
ok 2 -  Main.TestPage 
ok 3 - TestPage
ok 4 - TestPage\#anchor
ok 5 -  Main.TestPage\#anchor 
ok 6 - [[TestPage\#anchor]]
# Looks like you planned 2 tests but ran 6.

-- GeorgeClark - 23 Apr 2011

  • getreferencere.t: perl TAP test script demonstrating what getReferenceRE matches and doesn't match

ItemTemplate edit

Summary rename not handling anchored links
ReportedBy DrakeDiedrich
Codebase 1.1.3, 1.0.9, trunk
SVN Range
AppliesTo Engine
Component FoswikiRender, FoswikiUIRename
Priority Normal
CurrentState Closed
Checkins distro:ead16fb4cedf distro:18ab939005aa distro:139cf2834909 distro:3b815b2d34d2
TargetRelease patch
ReleasedIn 1.1.4
Topic attachments
I Attachment Action Size Date Who Comment getreferencere.t manage 714 bytes 23 Apr 2011 - 00:08 DrakeDiedrich perl TAP test script demonstrating what getReferenceRE matches and doesn't match
Topic revision: r8 - 17 Dec 2011, GeorgeClark - This page was cached on 20 Mar 2018 - 17:21.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License