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).

master
Joey Hess 2008-09-04 14:13:10 -04:00
parent 57153dcb9b
commit d2679de965
4 changed files with 48 additions and 26 deletions

View File

@ -312,9 +312,15 @@ sub getsetup () { #{{{
safe => 0, safe => 0,
rebuild => 1, 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 => { wiki_file_regexp => {
type => "internal", type => "internal",
default => qr/(^[-[:alnum:]_.:\/+]+$)/,
description => "regexp of legal source files", description => "regexp of legal source files",
safe => 0, safe => 0,
rebuild => 1, rebuild => 1,
@ -414,6 +420,10 @@ sub checkconfig () { #{{{
} }
} }
if (! defined $config{wiki_file_regexp}) {
$config{wiki_file_regexp}=qr/(^[$config{wiki_file_chars}]+$)/;
}
if (ref $config{ENV} eq 'HASH') { if (ref $config{ENV} eq 'HASH') {
foreach my $val (keys %{$config{ENV}}) { foreach my $val (keys %{$config{ENV}}) {
$ENV{$val}=$config{ENV}{$val}; $ENV{$val}=$config{ENV}{$val};
@ -770,7 +780,7 @@ sub bestlink ($$) { #{{{
elsif (exists $pagecase{lc $l}) { elsif (exists $pagecase{lc $l}) {
return $pagecase{lc $l}; return $pagecase{lc $l};
} }
} while $cwd=~s!/?[^/]+$!!; } while $cwd=~s{/?[^/]+$}{};
if (length $config{userdir}) { if (length $config{userdir}) {
my $l = "$config{userdir}/".lc($link); my $l = "$config{userdir}/".lc($link);
@ -808,13 +818,16 @@ sub pagetitle ($;$) { #{{{
sub titlepage ($) { #{{{ sub titlepage ($) { #{{{
my $title=shift; 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; return $title;
} #}}} } #}}}
sub linkpage ($) { #{{{ sub linkpage ($) { #{{{
my $link=shift; 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; return $link;
} #}}} } #}}}

4
debian/changelog vendored
View File

@ -11,6 +11,10 @@ ikiwiki (2.63) UNRELEASED; urgency=low
if no mime type is detected. if no mime type is detected.
* table: Support header=column to make the table header be the first * table: Support header=column to make the table header be the first
column of the data. (AlexandreDupas) column of the data. (AlexandreDupas)
* 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).
-- Joey Hess <joeyh@debian.org> Thu, 28 Aug 2008 16:08:18 -0400 -- Joey Hess <joeyh@debian.org> Thu, 28 Aug 2008 16:08:18 -0400

View File

@ -60,6 +60,11 @@ Windows does not support filenames containing any of these characters: `/ \ * :
>>> source on windows systems is desired, you'd have to remember to turn >>> source on windows systems is desired, you'd have to remember to turn
>>> that on when setting up a wiki, even if the wiki was hosted on unix. >>> that on when setting up a wiki, even if the wiki was hosted on unix.
>>> >>>
>>> Ok, `wiki_file_chars` config option added, set to
>>> `"-[:alnum:]+/._"` to exclude colons from filenames read or written by
>>> ikiwiki. [[done]]
>>>
>>> BTW, I suspect there are lots of other problems with actually running >>> BTW, I suspect there are lots of other problems with actually running
>>> ikiwiki on windows, including its assumption that the directory >>> ikiwiki on windows, including its assumption that the directory
>>> separator is "/". --[[Joey]] >>> separator is "/". Windows will be supported when someone sends me a
>>> comprehansive and not ugly or performance impacting patch. :-) --[[Joey]]

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-28 13:05-0400\n" "POT-Creation-Date: 2008-09-04 14:10-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,62 +16,62 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: ../IkiWiki/CGI.pm:139 #: ../IkiWiki/CGI.pm:140
msgid "You need to log in first." msgid "You need to log in first."
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:171 #: ../IkiWiki/CGI.pm:172
msgid "login failed, perhaps you need to turn on cookies?" msgid "login failed, perhaps you need to turn on cookies?"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:189 ../IkiWiki/CGI.pm:538 #: ../IkiWiki/CGI.pm:190 ../IkiWiki/CGI.pm:539
msgid "Your login session has expired." msgid "Your login session has expired."
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:210 #: ../IkiWiki/CGI.pm:211
msgid "Login" msgid "Login"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:211 #: ../IkiWiki/CGI.pm:212
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:212 #: ../IkiWiki/CGI.pm:213
msgid "Admin" msgid "Admin"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:279 #: ../IkiWiki/CGI.pm:280
msgid "Preferences saved." msgid "Preferences saved."
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:338 #: ../IkiWiki/CGI.pm:339
#, perl-format #, perl-format
msgid "%s is not an editable page" msgid "%s is not an editable page"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:449 ../IkiWiki/Plugin/brokenlinks.pm:33 #: ../IkiWiki/CGI.pm:450 ../IkiWiki/Plugin/brokenlinks.pm:33
#: ../IkiWiki/Plugin/inline.pm:310 ../IkiWiki/Plugin/opendiscussion.pm:26 #: ../IkiWiki/Plugin/inline.pm:310 ../IkiWiki/Plugin/opendiscussion.pm:26
#: ../IkiWiki/Plugin/orphans.pm:37 ../IkiWiki/Render.pm:78 #: ../IkiWiki/Plugin/orphans.pm:37 ../IkiWiki/Render.pm:78
#: ../IkiWiki/Render.pm:148 #: ../IkiWiki/Render.pm:148
msgid "discussion" msgid "discussion"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:505 #: ../IkiWiki/CGI.pm:506
#, perl-format #, perl-format
msgid "creating %s" msgid "creating %s"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:523 ../IkiWiki/CGI.pm:551 ../IkiWiki/CGI.pm:561 #: ../IkiWiki/CGI.pm:524 ../IkiWiki/CGI.pm:552 ../IkiWiki/CGI.pm:562
#: ../IkiWiki/CGI.pm:596 ../IkiWiki/CGI.pm:641 #: ../IkiWiki/CGI.pm:597 ../IkiWiki/CGI.pm:642
#, perl-format #, perl-format
msgid "editing %s" msgid "editing %s"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:666 #: ../IkiWiki/CGI.pm:667
msgid "You are banned." msgid "You are banned."
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:783 ../IkiWiki/CGI.pm:784 ../IkiWiki.pm:1117 #: ../IkiWiki/CGI.pm:784 ../IkiWiki/CGI.pm:785 ../IkiWiki.pm:1132
msgid "Error" msgid "Error"
msgstr "" msgstr ""
@ -673,11 +673,11 @@ msgstr ""
msgid "empty data" msgid "empty data"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/table.pm:101 #: ../IkiWiki/Plugin/table.pm:100
msgid "Direct data download" msgid "Direct data download"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/table.pm:135 #: ../IkiWiki/Plugin/table.pm:134
#, perl-format #, perl-format
msgid "parse fail at line %d: %s" msgid "parse fail at line %d: %s"
msgstr "" msgstr ""
@ -865,20 +865,20 @@ msgstr ""
msgid "refreshing wiki.." msgid "refreshing wiki.."
msgstr "" msgstr ""
#: ../IkiWiki.pm:434 #: ../IkiWiki.pm:444
msgid "Must specify url to wiki with --url when using --cgi" msgid "Must specify url to wiki with --url when using --cgi"
msgstr "" msgstr ""
#: ../IkiWiki.pm:478 #: ../IkiWiki.pm:490
msgid "cannot use multiple rcs plugins" msgid "cannot use multiple rcs plugins"
msgstr "" msgstr ""
#: ../IkiWiki.pm:1100 #: ../IkiWiki.pm:1115
#, perl-format #, perl-format
msgid "preprocessing loop detected on %s at depth %i" msgid "preprocessing loop detected on %s at depth %i"
msgstr "" msgstr ""
#: ../IkiWiki.pm:1588 #: ../IkiWiki.pm:1603
msgid "yes" msgid "yes"
msgstr "" msgstr ""