This question about Configuration: Answered

Disable Rename of Attachments

When files are attached that have a space in their filename, the space character is replaced with an underscore character. Likewise, when text files whose names do not have a .txt extension (i.e., connect.def ) are downloaded, a .txt extension is added to the filename (granted I don't know that it's not the browser doing this one).

I can see in configure the filter-in and filter-out options, but I don't know how to alter them to stop these substitutions. I have not been able to find any documentation of how this works.

Anybody have an idea? Here is the filter-in regex we have:
^(\.htaccess|.*\.(?i)(?:php[0-9s]?(\..*)?|[sp]htm[l]?(\..*)?|pl|py|cgi))$

Thank you
The renaming of attachments is a thorny subject. It tracks all the way back to the days when the precursor of Foswiki worked by calling exernal programs using a command line. In this context. you couldn't use filenames with spaces (or any other "funny" characters). Since that time the technology has moved on, but the constraints have not, and some of the code will almost certainly break if you try to use spaces in filenames.

Sorry about that. If it's a big issue, raise a FeatureRequest to get the code fully audited to remove this restriction.

-- CrawfordCurrie - 06 Feb 2009

Thanks, Crawford. If you're saying that the actual attachment would break the code, wouldn't that really only matter if you were attaching scripts, css, or other files that Foswiki were going to be interpreting? Or are you saying that to change the behavior would be the challenge?

The files we're attaching are PDFs, photos, and text files that store preferences for various graphic arts applications. So far, renaming has not been a huge problem. We simply put a table on the topic that says, "When you download this file, rename it like this." But we're reaching a point where it's going to quickly become really cumbersome to handle like this. We are often provided files by clients, like Acrobat Distiller Settings files, that we are required to use for their projects. We create a topic in the wiki to hold this information for each client. The client-provided process documentation refers to their settings files by name, but the names of the attachments don't match the documentation, because things like parenthesis and spaces have been removed or replaced.

Thanks for your help and information.

-- DavidWolfe - 06 Feb 2009

"Filenames" are used by Foswiki in a number of places. As well as attachments, topic names map to filenames, and so do web names. So when we talk about "spaces in filenames" we really mean "spaces in attachment, topic and web names". This is nothing to so with the content of these files, just their names. For example, there might be places in the code where a space is used as a list separator, and that would certainly fail. I'm not saying it doesn't work; I'm saying it's never been tried, but I suspect that there will be more than one code bug revealed that way.

Attachments is a limited case of the general spaces-in-filenames problem, and if you were to ask me on a good day I'd say it ought to be fixed, and it probably wouldn't take much effort. Trouble is, there are so many other things to fix first....

-- CrawfordCurrie - 06 Feb 2009

Has anything changed about the praxis of using attachments with special characters like space since this question was created? When i upload a file with space i get a nice warning about the fact that it was renamed with underscroes and that i should contact the Wiki admin to change the restriction. Well, i guess i am the wiki-admin jet have no idea how to disable the auto-rename smile At least for some Webs it would be quite important for us to disable this.

Kind regards,

-- EnrikGuenter - 24 Nov 2010

QuestionForm edit

Subject Configuration
Extension
Version Foswiki 1.1.2
Status Answered
Topic revision: r6 - 24 Nov 2010, EnrikGuenter
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy