From 01a9a12bbfbc21b45c59e4bbc52fbf488776d386 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Sep 2009 13:46:32 -0400 Subject: [PATCH] auto.setup, auto-blog.setup: Fix sanitization of entered wikiname. Closes: #547378 --- IkiWiki/Setup/Automator.pm | 17 +++++++++++------ auto-blog.setup | 15 ++++++++------- auto.setup | 15 ++++++++------- debian/changelog | 2 ++ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 742d67666..d1594d7ea 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -24,16 +24,21 @@ sub prettydir ($) { return $dir; } +sub sanitize_wikiname ($) { + my $wikiname=shift; + + # Sanitize this to avoid problimatic directory names. + $wikiname=~s/[^-A-Za-z0-9_]//g; + if (! length $wikiname) { + error gettext("you must enter a wikiname (that contains alphanumerics)"); + } + return $wikiname; +} + sub import (@) { my $this=shift; IkiWiki::Setup::merge({@_}); - # Sanitize this to avoid problimatic directory names. - $config{wikiname}=~s/[^-A-Za-z0-9_]//g; - if (! length $config{wikiname}) { - error gettext("you must enter a wikiname (that contains alphanumerics)"); - } - # Avoid overwriting any existing files. foreach my $key (qw{srcdir destdir repository dumpsetup}) { next unless exists $config{$key}; diff --git a/auto-blog.setup b/auto-blog.setup index 3ef734b39..cf77b3bf7 100644 --- a/auto-blog.setup +++ b/auto-blog.setup @@ -15,6 +15,7 @@ require IkiWiki::Setup::Automator; our $wikiname=IkiWiki::Setup::Automator::ask( gettext("What will the blog be named?"), gettext("blog")); +our $wikiname_short=IkiWiki::Setup::Automator::sanitize_wikiname($wikiname); our $rcs=IkiWiki::Setup::Automator::ask( gettext("What revision control system to use?"), "git"); our $admin=IkiWiki::Setup::Automator::ask( @@ -27,13 +28,13 @@ IkiWiki::Setup::Automator->import( wikiname => $wikiname, adminuser => [$admin], rcs => $rcs, - srcdir => "$ENV{HOME}/$wikiname", - destdir => "$ENV{HOME}/public_html/$wikiname", - repository => "$ENV{HOME}/$wikiname.".($rcs eq "monotone" ? "mtn" : $rcs), - dumpsetup => "$ENV{HOME}/$wikiname.setup", - url => "http://$domain/~$ENV{USER}/$wikiname", - cgiurl => "http://$domain/~$ENV{USER}/$wikiname/ikiwiki.cgi", - cgi_wrapper => "$ENV{HOME}/public_html/$wikiname/ikiwiki.cgi", + srcdir => "$ENV{HOME}/$wikiname_short", + destdir => "$ENV{HOME}/public_html/$wikiname_short", + repository => "$ENV{HOME}/$wikiname_short.".($rcs eq "monotone" ? "mtn" : $rcs), + dumpsetup => "$ENV{HOME}/$wikiname_short.setup", + url => "http://$domain/~$ENV{USER}/$wikiname_short", + cgiurl => "http://$domain/~$ENV{USER}/$wikiname_short/ikiwiki.cgi", + cgi_wrapper => "$ENV{HOME}/public_html/$wikiname_short/ikiwiki.cgi", adminemail => "$ENV{USER}\@$domain", add_plugins => [qw{goodstuff websetup comments blogspam}], disable_plugins => [qw{}], diff --git a/auto.setup b/auto.setup index b3d2513d9..dc2b19992 100644 --- a/auto.setup +++ b/auto.setup @@ -14,6 +14,7 @@ require IkiWiki::Setup::Automator; our $wikiname=IkiWiki::Setup::Automator::ask( gettext("What will the wiki be named?"), gettext("wiki")); +our $wikiname_short=IkiWiki::Setup::Automator::sanitize_wikiname($wikiname); our $rcs=IkiWiki::Setup::Automator::ask( gettext("What revision control system to use?"), "git"); our $admin=IkiWiki::Setup::Automator::ask( @@ -26,13 +27,13 @@ IkiWiki::Setup::Automator->import( wikiname => $wikiname, adminuser => [$admin], rcs => $rcs, - srcdir => "$ENV{HOME}/$wikiname", - destdir => "$ENV{HOME}/public_html/$wikiname", - repository => "$ENV{HOME}/$wikiname.".($rcs eq "monotone" ? "mtn" : $rcs), - dumpsetup => "$ENV{HOME}/$wikiname.setup", - url => "http://$domain/~$ENV{USER}/$wikiname", - cgiurl => "http://$domain/~$ENV{USER}/$wikiname/ikiwiki.cgi", - cgi_wrapper => "$ENV{HOME}/public_html/$wikiname/ikiwiki.cgi", + srcdir => "$ENV{HOME}/$wikiname_short", + destdir => "$ENV{HOME}/public_html/$wikiname_short", + repository => "$ENV{HOME}/$wikiname_short.".($rcs eq "monotone" ? "mtn" : $rcs), + dumpsetup => "$ENV{HOME}/$wikiname_short.setup", + url => "http://$domain/~$ENV{USER}/$wikiname_short", + cgiurl => "http://$domain/~$ENV{USER}/$wikiname_short/ikiwiki.cgi", + cgi_wrapper => "$ENV{HOME}/public_html/$wikiname_short/ikiwiki.cgi", adminemail => "$ENV{USER}\@$domain", add_plugins => [qw{goodstuff websetup}], disable_plugins => [qw{}], diff --git a/debian/changelog b/debian/changelog index be7c97119..bcdbd865c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low * Updated Czech translation from Miroslav Kure. Closes: #546223 * rsync: New plugin that allows pushing the destdir to a remote host via rsync or similar. Thanks, Amitai Schlair. + * auto.setup, auto-blog.setup: Fix sanitization of entered wikiname. + Closes: #547378 -- Joey Hess Wed, 02 Sep 2009 15:01:27 -0400