From 96c7e31c34b10e343afb3f17eb1ca7c34aaa4123 Mon Sep 17 00:00:00 2001 From: jhagg Date: Wed, 16 Jun 2010 13:40:29 +0000 Subject: --- ...ment_upload_does_not_work_for_windows_clients.mdwn | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn (limited to 'doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn') diff --git a/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn new file mode 100644 index 000000000..de57a1441 --- /dev/null +++ b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn @@ -0,0 +1,19 @@ +It seems as if windows clients (IE) submit filenames with backslash as directory separator. +(no surprise :-). + +But the attachment plugin translates these backslashes to underscore, making the +whole path a filename. + +This little hack fixed the backslash problem, although I wonder if that +really is the problem? +(Everything works perfectly from linux clients of course. :-) + + sub basename ($) { + my $file=shift; + + $file=~s!.*/+!!; + $file=~s!.*\\+!!; + return $file; + } + +Should probably be `$file=~s!.*[/\\]+!!` :-) -- cgit v1.2.3 From 69c22fa1ea143e3eb36692e087b167ae2171581e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 16 Jun 2010 13:23:32 -0400 Subject: attachment: Support Windows paths when taking basename of client-supplied file name. --- IkiWiki/Plugin/attachment.pm | 5 ++++- debian/changelog | 2 ++ doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn') diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 9c774557f..ce688ca40 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -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")); } diff --git a/debian/changelog b/debian/changelog index aeb9dc0eb..1f350912e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Fri, 11 Jun 2010 13:39:15 -0400 diff --git a/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn index de57a1441..ad3aadbce 100644 --- a/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn +++ b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn @@ -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. :-) -- cgit v1.2.3 From 79ffede4a7224a26e1725296db2db1918d52667c Mon Sep 17 00:00:00 2001 From: jhagg Date: Thu, 17 Jun 2010 08:30:38 +0000 Subject: --- doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn') diff --git a/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn index ad3aadbce..4e8c7bdcf 100644 --- a/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn +++ b/doc/bugs/attachment_upload_does_not_work_for_windows_clients.mdwn @@ -11,6 +11,14 @@ whole path a filename. > Still, I don't mind adding a special case, though obviously not in > `basename`. [[done]] --[[Joey]] +>> Well, it's probably something else also, I get **bad attachment filename**. +>> Now, that could really be a bad filename, problem is that it wasn't. I even +>> tried applying the **wiki_file_prune_regexps** one by one to see what was +>> causing it. No problem there. The strange thing is that the error shows up +>> when using firefox on windows too. But the backslash hack fixes at least the +>> incorrect filename from IE (firefox on windows gave me the correct filename. +>> I'll do some more digging... :-) /jh + This little hack fixed the backslash problem, although I wonder if that really is the problem? (Everything works perfectly from linux clients of course. :-) -- cgit v1.2.3