summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-03 20:12:27 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-03 20:12:27 +0000
commitfa9517e5bb07fad29fddb219e6c8e8f1b0a08d7e (patch)
treed04771c376accfbf57a699f728da095a30f23702
parent117e71ec9b4fe6a37fd9fa07b8fa2117306bb9a6 (diff)
* Support pages with utf8 filenames. Patch by Faidon Liambotis.
-rw-r--r--IkiWiki.pm5
-rw-r--r--IkiWiki/CGI.pm8
-rw-r--r--IkiWiki/Render.pm5
-rw-r--r--debian/changelog3
4 files changed, 14 insertions, 7 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index e86581415..4be5612f1 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -3,6 +3,7 @@
package IkiWiki;
use warnings;
use strict;
+use encoding "utf8";
use vars qw{%config %links %oldlinks %oldpagemtime %pagectime
%renderedfiles %pagesources %depends %hooks};
@@ -340,7 +341,7 @@ sub unlockwiki () { #{{{
} #}}}
sub loadindex () { #{{{
- open (IN, "$config{wikistatedir}/index") || return;
+ open (IN, "<:utf8", "$config{wikistatedir}/index") || return;
while (<IN>) {
$_=possibly_foolish_untaint($_);
chomp;
@@ -372,7 +373,7 @@ sub saveindex () { #{{{
if (! -d $config{wikistatedir}) {
mkdir($config{wikistatedir});
}
- open (OUT, ">$config{wikistatedir}/index") ||
+ open (OUT, ">:utf8", "$config{wikistatedir}/index") ||
error("cannot write to $config{wikistatedir}/index: $!");
foreach my $page (keys %oldpagemtime) {
next unless $oldpagemtime{$page};
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index d069de8dc..b2d126977 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -308,7 +308,8 @@ sub cgi_editpage ($$) { #{{{
# This untaint is safe because titlepage removes any problimatic
# characters.
- my ($page)=titlepage(possibly_foolish_untaint(lc($form->param('page'))));
+ my ($page)=Encode::decode_utf8($form->param('page'));
+ $page=titlepage(possibly_foolish_untaint(lc($page)));
if (! defined $page || ! length $page ||
$page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
error("bad page name");
@@ -353,10 +354,11 @@ sub cgi_editpage ($$) { #{{{
# utf-8, so decode from it.
require Encode;
my $content = Encode::decode_utf8($form->field('editcontent'));
+ my $comments = Encode::decode_utf8($form->field('comments'));
$form->field(name => "editcontent",
value => $content, force => 1);
$form->field(name => "comments",
- value => Encode::decode_utf8($form->field('comments')), force => 1);
+ value => $comments, force => 1);
$form->tmpl_param("page_preview",
htmlize($config{default_pageext},
linkify($page, $page, $content)));
@@ -457,7 +459,7 @@ sub cgi_editpage ($$) { #{{{
}
if (defined $form->field('comments') &&
length $form->field('comments')) {
- $message.=Encode::decode_utf8(": ".$form->field('comments'));
+ $message.=": ".Encode::decode_utf8($form->field('comments'));
}
if ($config{rcs}) {
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 3be8e1c53..e778ff20c 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -324,9 +324,11 @@ sub refresh () { #{{{
my %exists;
my @files;
eval q{use File::Find};
+ require Encode;
find({
no_chdir => 1,
wanted => sub {
+ $_ = Encode::decode_utf8($_);
if (/$config{wiki_file_prune_regexp}/) {
$File::Find::prune=1;
}
@@ -346,6 +348,7 @@ sub refresh () { #{{{
find({
no_chdir => 1,
wanted => sub {
+ $_ = Encode::decode_utf8($_);
if (/$config{wiki_file_prune_regexp}/) {
$File::Find::prune=1;
}
@@ -405,7 +408,7 @@ sub refresh () { #{{{
if (! exists $oldpagemtime{$page} ||
mtime(srcfile($file)) > $oldpagemtime{$page}) {
- debug("rendering changed file $file");
+ debug("rendering $file");
render($file);
$rendered{$file}=1;
}
diff --git a/debian/changelog b/debian/changelog
index 5b7b66e16..a7e5f676f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,8 +22,9 @@ ikiwiki (1.8) UNRELEASED; urgency=low
getting in the way of the preview.
* Centralised all calls to HTML::Template and force all the templates
to be read as utf8.
+ * Support pages with utf8 filenames. Patch by Faidon Liambotis.
- -- Joey Hess <joeyh@debian.org> Sun, 2 Jul 2006 14:55:40 -0400
+ -- Joey Hess <joeyh@debian.org> Mon, 3 Jul 2006 16:09:16 -0400
ikiwiki (1.7) unstable; urgency=low