Fix the link() pagespec to match links that are internally recorded as absolute.
This fixes a problem exposed by the recent change to tags
(a2839de936
). That recorded tag links as
absolute by including a leading slash in the link. The same could also be
done with an absolute wikilink.
In either case, link() would not match such links, unless the leading slash
was included in the link to match. But that's not right, because pagespecs
match absolute by default. So strip the leading slash.
Note that to keep any existing `link(/foo)` pagespecs working after this
change, the leading slash is removed from there, too.
master
parent
d552b28430
commit
7f80e52543
|
@ -1901,6 +1901,10 @@ sub match_link ($$;@) { #{{{
|
||||||
else {
|
else {
|
||||||
return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
|
return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
|
||||||
if match_glob($p, $link, %params);
|
if match_glob($p, $link, %params);
|
||||||
|
$p=~s/^\///;
|
||||||
|
$link=~s/^\///;
|
||||||
|
return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
|
||||||
|
if match_glob($p, $link, %params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return IkiWiki::FailReason->new("$page does not link to $link");
|
return IkiWiki::FailReason->new("$page does not link to $link");
|
||||||
|
|
|
@ -7,6 +7,8 @@ ikiwiki (2.69) UNRELEASED; urgency=low
|
||||||
* meta: Plugin is now enabled by default since the basewiki uses it.
|
* meta: Plugin is now enabled by default since the basewiki uses it.
|
||||||
* txt: Do not encode quotes when filtering the txt, as that broke
|
* txt: Do not encode quotes when filtering the txt, as that broke
|
||||||
later parsing of any directives on the page.
|
later parsing of any directives on the page.
|
||||||
|
* Fix the link() pagespec to match links that are internally recorded as
|
||||||
|
absolute.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 06 Nov 2008 16:01:00 -0500
|
-- Joey Hess <joeyh@debian.org> Thu, 06 Nov 2008 16:01:00 -0500
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Test::More tests => 56;
|
use Test::More tests => 58;
|
||||||
|
|
||||||
BEGIN { use_ok("IkiWiki"); }
|
BEGIN { use_ok("IkiWiki"); }
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ $links{"bugs/bar"}=[qw{done}];
|
||||||
$links{"done"}=[];
|
$links{"done"}=[];
|
||||||
$links{"examples/softwaresite/bugs/fails_to_frobnicate"}=[qw{done}];
|
$links{"examples/softwaresite/bugs/fails_to_frobnicate"}=[qw{done}];
|
||||||
$links{"examples/softwaresite/bugs/done"}=[];
|
$links{"examples/softwaresite/bugs/done"}=[];
|
||||||
|
$links{"ook"}=[qw{/blog/tags/foo}];
|
||||||
|
|
||||||
ok(pagespec_match("foo", "link(bar)"), "link");
|
ok(pagespec_match("foo", "link(bar)"), "link");
|
||||||
ok(pagespec_match("foo", "link(ba?)"), "glob link");
|
ok(pagespec_match("foo", "link(ba?)"), "glob link");
|
||||||
|
@ -55,6 +56,8 @@ ok(pagespec_match("bar", "backlink(foo)"), "backlink");
|
||||||
ok(! pagespec_match("quux", "backlink(foo)"), "failed backlink");
|
ok(! pagespec_match("quux", "backlink(foo)"), "failed backlink");
|
||||||
ok(! pagespec_match("bar", ""), "empty pagespec should match nothing");
|
ok(! pagespec_match("bar", ""), "empty pagespec should match nothing");
|
||||||
ok(! pagespec_match("bar", " "), "blank pagespec should match nothing");
|
ok(! pagespec_match("bar", " "), "blank pagespec should match nothing");
|
||||||
|
ok(pagespec_match("ook", "link(blog/tags/foo)"), "link internal absolute success");
|
||||||
|
ok(pagespec_match("ook", "link(/blog/tags/foo)"), "link explicit absolute success");
|
||||||
|
|
||||||
$IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006
|
$IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006
|
||||||
$IkiWiki::pagectime{bar}=1154532695; # after
|
$IkiWiki::pagectime{bar}=1154532695; # after
|
||||||
|
|
Loading…
Reference in New Issue