X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/75a096d056270d5b20f19a55416436d731654105..b44ca17f939596d0ec76aca9a295516f12803d69:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 64ef6585f..4e4da11c5 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -121,7 +121,7 @@ sub getsetup () { #{{{ type => "internal", default => [qw{mdwn link inline htmlscrubber passwordauth openid signinedit lockedit conditional - recentchanges parentlinks}], + recentchanges parentlinks editpage}], description => "plugins to enable by default", safe => 0, rebuild => 1, @@ -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, @@ -389,6 +395,13 @@ sub getsetup () { #{{{ safe => 0, rebuild => 0, }, + allow_symlinks_before_srcdir => { + type => "string", + default => 0, + description => "allow symlinks in the path leading to the srcdir (potentially insecure)", + safe => 0, + rebuild => 0, + }, } #}}} sub defaultconfig () { #{{{ @@ -413,6 +426,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}}) { @@ -503,7 +520,11 @@ sub loadplugin ($) { #{{{ foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef, "$installdir/lib/ikiwiki") { if (defined $dir && -x "$dir/plugins/$plugin") { - require IkiWiki::Plugin::external; + eval { require IkiWiki::Plugin::external }; + if ($@) { + my $reason=$@; + error(sprintf(gettext("failed to load external plugin needed for %s plugin: %s"), $plugin, $reason)); + } import IkiWiki::Plugin::external "$dir/plugins/$plugin"; $loaded_plugins{$plugin}=1; return 1; @@ -770,7 +791,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 +829,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; } #}}}