X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/96da041907bcd4e74be6b2beef06d265708644ee..4e82acb052935ad2bc3c83e8578a9d5117a5d3bb:/IkiWiki.pm
diff --git a/IkiWiki.pm b/IkiWiki.pm
index d9b3dcdb4..c1d9119e8 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1,6 +1,7 @@
#!/usr/bin/perl
package IkiWiki;
+
use warnings;
use strict;
use Encode;
@@ -532,13 +533,18 @@ sub displaytime ($;$) { #{{{
return decode_utf8(POSIX::strftime($format, localtime($time)));
} #}}}
-sub beautify_url ($) { #{{{
+sub beautify_urlpath ($) { #{{{
my $url=shift;
if ($config{usedirs}) {
$url =~ s!/index.$config{htmlext}$!/!;
}
- $url =~ s!^$!./!; # Browsers don't like empty links...
+
+ # Ensure url is not an empty link, and
+ # if it's relative, make that explicit to avoid colon confusion.
+ if ($url !~ /\//) {
+ $url="./$url";
+ }
return $url;
} #}}}
@@ -548,7 +554,7 @@ sub urlto ($$) { #{{{
my $from=shift;
if (! length $to) {
- return beautify_url(baseurl($from)."index.$config{htmlext}");
+ return beautify_urlpath(baseurl($from)."index.$config{htmlext}");
}
if (! $destsources{$to}) {
@@ -557,7 +563,7 @@ sub urlto ($$) { #{{{
my $link = abs2rel($to, dirname(htmlpage($from)));
- return beautify_url($link);
+ return beautify_urlpath($link);
} #}}}
sub htmllink ($$$;@) { #{{{
@@ -596,7 +602,7 @@ sub htmllink ($$$;@) { #{{{
return " "create",
- page => pagetitle(lc($link), 1),
+ page => lc($link),
from => $lpage
).
"\" rel=\"nofollow\">?$linktext"
@@ -604,7 +610,7 @@ sub htmllink ($$$;@) { #{{{
}
$bestlink=abs2rel($bestlink, dirname(htmlpage($page)));
- $bestlink=beautify_url($bestlink);
+ $bestlink=beautify_urlpath($bestlink);
if (! $opts{noimageinline} && isinlinableimage($bestlink)) {
return "";
@@ -1290,6 +1296,13 @@ sub pagespec_valid ($) { #{{{
my $sub=pagespec_translate($spec);
return ! $@;
} #}}}
+
+sub glob2re ($) { #{{{
+ my $re=quotemeta(shift);
+ $re=~s/\\\*/.*/g;
+ $re=~s/\\\?/./g;
+ return $re;
+} #}}}
package IkiWiki::FailReason;
@@ -1337,12 +1350,8 @@ sub match_glob ($$;@) { #{{{
$glob="$from/$glob" if length $from;
}
- # turn glob into safe regexp
- $glob=quotemeta($glob);
- $glob=~s/\\\*/.*/g;
- $glob=~s/\\\?/./g;
-
- if ($page=~/^$glob$/i) {
+ my $regexp=IkiWiki::glob2re($glob);
+ if ($page=~/^$regexp$/i) {
if (! IkiWiki::isinternal($page) || $params{internal}) {
return IkiWiki::SuccessReason->new("$glob matches $page");
}