Item10671: rename not handling anchored links
Priority: Normal
Current State: Closed
Released In: 1.1.4
Target Release: patch
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
<verbatim>
protected $this->{test_web}.OldTopic
</verbatim>
<pre>
pre $this->{test_web}.OldTopic
</pre>
<noautolink>
protected $this->{test_web}.OldTopic
rename [[OldTopic]]
rename [[$this->{test_web}.OldTopic]]
</noautolink>
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
1..2
(?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