Bug Report #3460

Upload::save() UTF-8 problem

Added by Korney Czukowski about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:12/06/2010
Priority:NormalDue date:
Assignee:Woody Gilk% Done:


Target version:v3.0.10
Resolution:fixed Points:


I've run into a weird issue when trying to upload a couple of files with international names. Most were uploaded just fine, however the return value of Upload::save() for one of the files was corrupted somehow, even though I can't tell what exactly caused it and how was corrupting character different from other, it wasn't any special symbol, etc. As result, among other, inserting the file path to database would truncate the it at the corrupted character.

I've tracked it down to around line 69 in system/classes/kohana/upload.php:

if (Upload::$remove_spaces === TRUE)
// Remove spaces from the filename
$filename = preg_replace('/\s+/', '_', $filename);

After adding Unicode switch to the regex, the problem was gone:

$filename = preg_replace('/\s+/u', '_', $filename);

My PHP installation fully supports UTF8, according to install.php.

Associated revisions

Revision bfdfc8e5
Added by Woody Gilk about 4 years ago

Make the removal of spaces in Upload::save() UTF-8 safe, fixes #3460


#1 Updated by Woody Gilk about 4 years ago

  • Target version changed from v3.0.9 to v3.0.10

#2 Updated by Woody Gilk about 4 years ago

  • Category set to Core
  • Status changed from New to Closed
  • Assignee set to Woody Gilk
  • % Done changed from 0 to 100
  • Resolution set to fixed

Also available in: Atom PDF