Imagecache in particular fails when filenames include special chars like + or &.
#615418: image file with '+' sign or & in name not found by imagecache

I suggest the addition of a preg_replace to the file_create_filename function in file.inc that will replace these 'problem' characters with a dash or underscore.

Something like this:

$name = preg_replace('/[&\+\s]/i', '-', $name);

In this case any ampersand, plus sign, or whitespace char will be replaced with a dash. This is probably enough to prevent imagecache from breaking, and any other modules that may have issues. Though more special characters may need filtering out as well.
Files: 
CommentFileSizeAuthor
#3 drupal-791780b.patch576 byteswillvincent
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-791780b.patch.
[ View ]
#1 drupal-791780.patch297 byteswillvincent
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-791780.patch.
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new297 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-791780.patch.
[ View ]

This patch implements my proposed change outlined above

Status:Needs review» Needs work

The last submitted patch, drupal-791780.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new576 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-791780b.patch.
[ View ]

Rerolled patch from drupal base install dir.. simpletest *should* succeed this time. :)

Status:Needs review» Needs work

The last submitted patch, drupal-791780b.patch, failed testing.

in file.inc
function file_munge_filename($filename, $extensions, $alerts = TRUE) {
// drupal bug fix
+ $filename = str_replace('+', '-', $filename);
$original = $filename;

Do not forget the '#'.

Just stumbled on this issue and wondering if the transliteration module http://drupal.org/project/transliteration solves this. It seems to work quite well and I believe it is in D7.

Thank you izmeez, transliteration module does the work!

Title:Special chars should be removed from filenames on uploadSpecial chars should be removed/replaced from filenames on upload.
Version:6.16» 6.x-dev
Category:bug» feature
Issue tags:+transliteration

Well, this issue's title makes it sound a lot like a feature request and AFAICT it affects all D6 and not just 6.16. Now, for D8 we got #567832: Transliteration in core in (yippy!!) which combined with #576180: Make the machine-name generation pluggeable could make real magic happen. What we have to do next is put it into good use for other places as well: #1842718: Use new Transliteration functionality in core for machine names

For D6/D7 we have the Transliteration module (and friends). So, what I'm trying to say is that perhaps we should close this almost-3-years-old issue now? After all D8 is scheduled/estimated for around September 2013, so I guess it doesn't make sense anyways. Perhaps if it's not breaking any APIs you can suggest for #567832: Transliteration in core to be backported to D7.

So, what say you? Should we close it and point people to Transliteration?

1+ to close this.

I agree it can be closed, but it would probably be a very good idea to point people to Transliteration in a rather prominent way. While those of us who have been around for a while know about and regularly use transliteration, for newcomers it's not obvious that it should be used, and with the huge number of contrib modules it's not unlikely that people will not find their way to the transliteration module.