]> sipb.mit.edu Git - ikiwiki.git/commitdiff
attachment: Fix utf-8 display bug.
authorJoey Hess <joey@kitenet.net>
Sun, 15 Jan 2012 20:39:13 +0000 (16:39 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 15 Jan 2012 20:39:13 +0000 (16:39 -0400)
IkiWiki/Plugin/attachment.pm
debian/changelog
doc/bugs/UTF-8_in_attachment_filenames.mdwn

index fd4096edf7de153ef01145f310c459f255e3fffc..5a180cd5cf3c3eaac5282ef267982327e49eba8d 100644 (file)
@@ -272,6 +272,7 @@ sub attachments_save {
        my @attachments;
        my $dir=attachment_holding_location($form->field('page'));
        foreach my $filename (glob("$dir/*")) {
+               $filename=Encode::decode_utf8($filename);
                next unless -f $filename;
                my $destdir=$config{srcdir}."/".
                        linkpage(IkiWiki::possibly_foolish_untaint(
@@ -345,6 +346,7 @@ sub attachment_list ($) {
        my $dir=attachment_holding_location($page);
        my $heldmsg=gettext("this attachment is not yet saved");
        foreach my $file (glob("$dir/*")) {
+               $file=Encode::decode_utf8($file);
                next unless -f $file;
                my $base=IkiWiki::basename($file);
                my $f=$loc.$base;
index 9c4e83c2f0fa50423b65ce0b23546b048016348e..1eab184f53c922fcd979af38970bb4bbf1cc82cd 100644 (file)
@@ -1,7 +1,8 @@
 ikiwiki (3.20120115) unstable; urgency=low
 
   * Make backlink(.) work. Thanks, Giuseppe Bilotta.
-  * Workaround discount's eliding of <style> blocks.
+  * mdwn: Workaround discount's eliding of <style> blocks.
+  * attachment: Fix utf-8 display bug.
 
  -- Joey Hess <joeyh@debian.org>  Sun, 15 Jan 2012 16:19:25 -0400
 
index 6e79a4e064b8ef24ffd31511b434f78f217c42f5..07fff88d251c97df5684a58c7247924fa485d6ec 100644 (file)
@@ -1,4 +1,9 @@
-I have ikiwiki_3.20111229 installed on Debian Squeeze (Perl 5.10.1, UTF-8 locale). The attachment plugin mangles UTF8-encoded attachment filenames if the name contains multibyte characters, e.g. "lää.png" becomes "lää.png". Apparently glob returns byte strings which are subject to implicit upgrading when concatenated with Perl strings. The following patch fixes the problem for me:
+I have ikiwiki_3.20111229 installed on Debian Squeeze (Perl 5.10.1, UTF-8
+locale). The attachment plugin mangles UTF8-encoded attachment filenames if
+the name contains multibyte characters, e.g. "lää.png" becomes "lää.png".
+Apparently glob returns byte strings which are subject to implicit
+upgrading when concatenated with Perl strings. The following patch fixes
+the problem for me:
 
 ----
 
@@ -13,3 +18,8 @@ I have ikiwiki_3.20111229 installed on Debian Squeeze (Perl 5.10.1, UTF-8 locale
        foreach my $file (glob("$dir/*")) {
     +      $file = Encode::decode_utf8($file);
                next unless -f $file;
+
+> Seems it only mangled display of the just-uploaded attachment's filename,
+> the attachment was otherwise saved to disk with a valid UTF-8 name, and
+> doing other stuff with it also was ok. In any case, I applied your patch,
+> thanks. [[done]] --[[Joey]]