summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-04 14:13:10 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-04 14:13:10 -0400
commitd2679de965a0300474341139871855bbccc61612 (patch)
tree286ffeea6d5d8608fc115ef16647982d10b439e1 /IkiWiki.pm
parent57153dcb9bc9de0214f58dc2a3ea9ff055ab6d07 (diff)
For fine control over what characters are allowed, unescaped in source filenames, the wiki_file_chars setting is added. For example, set to "-[:alnum:]+/._" to disable colons from being used in source files (which can cause trouble om Windows).
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 64ef6585f..7553ae3db 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -312,9 +312,15 @@ sub getsetup () { #{{{
safe => 0,
rebuild => 1,
},
+ wiki_file_chars => {
+ type => "string",
+ description => "specifies the characters that are allowed in source filenames",
+ default => "-[:alnum:]+/.:_",
+ safe => 0,
+ rebuild => 1,
+ },
wiki_file_regexp => {
type => "internal",
- default => qr/(^[-[:alnum:]_.:\/+]+$)/,
description => "regexp of legal source files",
safe => 0,
rebuild => 1,
@@ -413,6 +419,10 @@ sub checkconfig () { #{{{
$gettext_obj=undef;
}
}
+
+ if (! defined $config{wiki_file_regexp}) {
+ $config{wiki_file_regexp}=qr/(^[$config{wiki_file_chars}]+$)/;
+ }
if (ref $config{ENV} eq 'HASH') {
foreach my $val (keys %{$config{ENV}}) {
@@ -770,7 +780,7 @@ sub bestlink ($$) { #{{{
elsif (exists $pagecase{lc $l}) {
return $pagecase{lc $l};
}
- } while $cwd=~s!/?[^/]+$!!;
+ } while $cwd=~s{/?[^/]+$}{};
if (length $config{userdir}) {
my $l = "$config{userdir}/".lc($link);
@@ -808,13 +818,16 @@ sub pagetitle ($;$) { #{{{
sub titlepage ($) { #{{{
my $title=shift;
- $title=~s/([^-[:alnum:]:+\/.])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
+ # support use w/o %config set
+ my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
+ $title=~s/([^$chars]|_)/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
return $title;
} #}}}
sub linkpage ($) { #{{{
my $link=shift;
- $link=~s/([^-[:alnum:]:+\/._])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
+ my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
+ $link=~s/([^$chars])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
return $link;
} #}}}