attachment: Support Windows paths when taking basename of client-supplied file name.
authorJoey Hess <joey@kitenet.net>
Wed, 16 Jun 2010 17:23:32 +0000 (13:23 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 16 Jun 2010 17:23:32 +0000 (13:23 -0400)
IkiWiki/Plugin/attachment.pm
debian/changelog
doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn

index 9c774557fdbb649b010da4f899d6089f943b5337..ce688ca40df0f8c13f9f09206e54a871438a2f10 100644 (file)
@@ -134,9 +134,12 @@ sub formbuilder (@) {
                        }
                }
 
+               $filename=IkiWiki::basename($filename);
+               $filename=~s/.*\\+(.+)/$1/; # hello, windows
+
                $filename=linkpage(IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
-                               IkiWiki::basename($filename)));
+                               $filename));
                if (IkiWiki::file_pruned($filename)) {
                        error(gettext("bad attachment filename"));
                }
index aeb9dc0ebe1db3b02c047c63bf28fc301b6bb863..1f350912e5d8e40f7b05d94ce5d0a8df827a7171 100644 (file)
@@ -20,6 +20,8 @@ ikiwiki (3.20100611) UNRELEASED; urgency=low
     (Workaround bug #586045)
   * Make --gettime be honored after initial setup.
   * git: Gix --gettime to properly support utf8 filenames.
+  * attachment: Support Windows paths when taking basename of client-supplied
+    file name.
 
  -- Joey Hess <joeyh@debian.org>  Fri, 11 Jun 2010 13:39:15 -0400
 
index de57a1441248c6beeeefecfd3450635e536d35d1..ad3aadbce9a87028407c8bda5fe9727c202cf831 100644 (file)
@@ -4,6 +4,13 @@ It seems as if windows clients (IE) submit filenames with backslash as directory
 But the attachment plugin translates these backslashes to underscore, making the
 whole path a filename.
 
+> As far as I can see, that just means that the file will be saved with
+> a filename something like `c:__92__My_Documents__92__somefile`.
+> I don't see any "does not work" here. Error message?
+> 
+> Still, I don't mind adding a special case, though obviously not in
+> `basename`. [[done]] --[[Joey]] 
+
 This little hack fixed the backslash problem, although I wonder if that
 really is the problem?
 (Everything works perfectly from linux clients of course. :-)