Item625: Uploaded filename stripped if special character
Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: I18N
Branches:
When uploading a file with special characters, e.g
Ba-Benzélé.file
, the special character is stripped off to
Ba-Benzl.file
Example can be found @
http://trunk.foswiki.org/Sandbox/UploadFilenameTest
I've also tried chinese characters
示范.file
in
UploadFilenameTest but the following error got thrown back at me.
Either you did not specify a file name, or the file you are trying to upload blank :) has no content. You may not upload an empty file.
Please go back in your browser and check again.
Note: blank :)
is the content of the file.
On my box (4.1.2), I tried to scp the file to the appropriate
pub
directory, and it works, i.e. the attachment is displayed on the topic.
You don't say how your system is configured. Locale? Charset? Are you using utf8? There is a function Foswiki::Sandbox::sanitiseAttachmentName. What is it doing wrong?
--
CrawfordCurrie - 04 Jan 2009
trunk.foswiki.org has the following configuration,
$Foswiki::cfg{Site}{Locale} = 'en_US.ISO-8859-1';
$Foswiki::cfg{Site}{CharSet} = 'iso-8859-1';
My site running 4.1.2 has the following configuration,
$TWiki::cfg{Site}{Locale} = 'en_GB.UTF8';
$TWiki::cfg{UseLocale} = 1;
$TWiki::cfg{Site}{CharSet} = 'utf-8';
Note that FW 1.0 is more improved in handling special characters than in T 4.1.2, meaning, 4.1.2 doesn't allow me to upload at all, whilst 1.0 just strips off the characters.
--
KwangErnLiew - 04 Jan 2009
Confirmed. Foswiki::Sandbox::sanitizeAttachmentName uses
$fileName =~ s/$Foswiki::cfg{NameFilter}//goi
if
UseLocale is on. This is set in the configuration:
# **REGEX EXPERT**
# Filter-out regex for webnames, topic names, usernames, include paths
# and skin names. This is a filter <b>out</b>, so if any of the
# characters matched by this expression are seen in names, they will be
# removed.
$Foswiki::cfg{NameFilter} = qr/[\s\*?~^\$@%`"'&;|<>\[\]\x00-\x1f]/;
Thus the workaround is to extend that RE to work for your selected charset.
--
CrawfordCurrie - 06 Jan 2009
Already fixed in 1.2.
--
JozefMojzis - 24 Jun 2015