howto : Drupal CJK filename dropped.
reason : Drupal is using basename() function on filename extracting. But basename function with php5 is not safe locale. If you use utf-8 encoding on cjk like charset, basename will not work exatly.
solution : First. don't use php5, and use php4.
Second. make locale indepent basename function (ex: drupal_basename() )
1 2 3 4 5 6 7 8 | function drupal_basename($path,$prefix = '') { $path = preg_replace('|^.+[\\/]|', '', $path); if ($prefix) { $path = preg_replace('|'. preg_quote($prefix) .'$|', '', $path); } return $path; } |
I changed pattern '|^.+[\\/]|' to '/([^\/]+)\//'.
1 2 3 4 5 6 7 8 | function drupal_basename($path,$suffix = '') { $path = preg_replace('/([^\/]+)\//', '', $path); if ($suffix) { $path = preg_replace('/'.preg_quote($suffix).'$/', '', $path); } return $path; } |
And replace three files to use drupal_basename function.
* file.inc
* common.inc
* locale.inc
Reference : http://drupal.org/node/278425
Trackback URL for this post:
http://barami.org/trackback/67
