Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.776 diff -u -p -r1.776 common.inc --- includes/common.inc 2 Jul 2008 19:36:52 -0000 1.776 +++ includes/common.inc 4 Jul 2008 07:32:59 -0000 @@ -1717,13 +1717,13 @@ function drupal_get_css($css = NULL) { // Setup theme overrides for module styles. $theme_styles = array(); foreach (array_keys($css[$media]['theme']) as $theme_style) { - $theme_styles[] = basename($theme_style); + $theme_styles[] = drupal_basename($theme_style); } } foreach ($types[$type] as $file => $preprocess) { // If the theme supplies its own style using the name of the module style, skip its inclusion. // This includes any RTL styles associated with its main LTR counterpart. - if ($type == 'module' && in_array(str_replace('-rtl.css', '.css', basename($file)), $theme_styles)) { + if ($type == 'module' && in_array(str_replace('-rtl.css', '.css', drupal_basename($file)), $theme_styles)) { // Unset the file to prevent its inclusion when CSS aggregation is enabled. unset($types[$type][$file]); continue; Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.126 diff -u -p -r1.126 file.inc --- includes/file.inc 18 Jun 2008 03:36:23 -0000 1.126 +++ includes/file.inc 4 Jul 2008 07:32:59 -0000 @@ -193,7 +193,7 @@ function file_check_path(&$path) { } // Check if path is a possible dir/file. - $filename = basename($path); + $filename = drupal_basename($path); $path = dirname($path); if (file_check_directory($path)) { return $filename; @@ -223,7 +223,7 @@ function file_check_location($source, $d } else { // This file does not yet exist - $source = realpath(dirname($source)) . '/' . basename($source); + $source = realpath(dirname($source)) . '/' . drupal_basename($source); } $directory = realpath($directory); if ($directory && strpos($source, $directory) !== 0) { @@ -281,7 +281,7 @@ function file_copy(&$source, $dest = 0, } // If the destination file is not specified then use the filename of the source file. - $basename = $basename ? $basename : basename($source); + $basename = $basename ? $basename : drupal_basename($source); $dest = $directory . '/' . $basename; // Make sure source and destination filenames are not the same, makes no sense @@ -334,7 +334,7 @@ function file_destination($destination, if (file_exists($destination)) { switch ($replace) { case FILE_EXISTS_RENAME: - $basename = basename($destination); + $basename = drupal_basename($destination); $directory = dirname($destination); $destination = file_create_filename($basename, $directory); break; @@ -563,7 +563,7 @@ function file_save_upload($source, $vali // Begin building file object. $file = new stdClass(); - $file->filename = file_munge_filename(trim(basename($_FILES['files']['name'][$source]), '.'), $extensions); + $file->filename = file_munge_filename(trim(drupal_basename($_FILES['files']['name'][$source]), '.'), $extensions); $file->filepath = $_FILES['files']['tmp_name'][$source]; $file->filemime = $_FILES['files']['type'][$source]; @@ -931,7 +931,7 @@ function file_scan_directory($dir, $mask elseif ($depth >= $min_depth && ereg($mask, $file)) { // Always use this match over anything already set in $files with the same $$key. $filename = "$dir/$file"; - $basename = basename($file); + $basename = drupal_basename($file); $name = substr($basename, 0, strrpos($basename, '.')); $files[$$key] = new stdClass(); $files[$$key]->filename = $filename; @@ -1018,5 +1018,16 @@ function file_upload_max_size() { } /** + * This is a locale independent, UTF-8 safe version of basename. + */ +function drupal_basename($path, $suffix = '') { + $path = preg_replace('|^.+[\\/]|', '', $path); + if ($suffix) { + $path = preg_replace('|'. preg_quote($suffix) .'$|', '', $path); + } + return $path; +} + +/** * @} End of "defgroup file". */ Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.176 diff -u -p -r1.176 locale.inc --- includes/locale.inc 26 May 2008 17:12:54 -0000 1.176 +++ includes/locale.inc 4 Jul 2008 07:33:00 -0000 @@ -2542,7 +2542,7 @@ function _locale_batch_import($filepath, // The filename is either {langcode}.po or {prefix}.{langcode}.po, so // we can extract the language code to use for the import from the end. if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) { - $file = (object) array('filename' => basename($filepath), 'filepath' => $filepath); + $file = (object) array('filename' => drupal_basename($filepath), 'filepath' => $filepath); _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]); $context['results'][] = $filepath; } Index: modules/blogapi/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v retrieving revision 1.119 diff -u -p -r1.119 blogapi.module --- modules/blogapi/blogapi.module 13 May 2008 18:13:43 -0000 1.119 +++ modules/blogapi/blogapi.module 4 Jul 2008 07:33:00 -0000 @@ -372,7 +372,7 @@ function blogapi_metaweblog_new_media_ob return blogapi_error($user); } - $name = basename($file['name']); + $name = drupal_basename($file['name']); $data = $file['bits']; if (!$data) { Index: modules/color/color.module =================================================================== RCS file: /cvs/drupal/drupal/modules/color/color.module,v retrieving revision 1.41 diff -u -p -r1.41 color.module --- modules/color/color.module 19 May 2008 19:36:41 -0000 1.41 +++ modules/color/color.module 4 Jul 2008 07:33:01 -0000 @@ -87,7 +87,7 @@ function _color_page_alter(&$vars) { foreach ($color_paths as $color_path) { // Color module currently requires unique file names to be used, // which allows us to compare different file paths. - if (basename($old_path) == basename($color_path)) { + if (drupal_basename($old_path) == drupal_basename($color_path)) { // Pull out the non-colored and add rewritten stylesheet. unset($new_theme_css[$old_path]); $new_theme_css[$color_path] = $old_preprocess; @@ -306,7 +306,7 @@ function color_scheme_form_submit($form, // Copy over neutral images. foreach ($info['copy'] as $file) { - $base = basename($file); + $base = drupal_basename($file); $source = $paths['source'] . $file; file_copy($source, $paths['target'] . $base); $paths['map'][$file] = $base; @@ -348,7 +348,7 @@ function color_scheme_form_submit($form, // Rewrite stylesheet with new colors. $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style); - $base_file = basename($file); + $base_file = drupal_basename($file); $css[] = $paths['target'] . $base_file; _color_save_stylesheet($paths['target'] . $base_file, $style, $paths); } @@ -477,7 +477,7 @@ function _color_render_images($theme, &$ // Cut out slices. foreach ($info['slices'] as $file => $coord) { list($x, $y, $width, $height) = $coord; - $base = basename($file); + $base = drupal_basename($file); $image = $paths['target'] . $base; // Cut out slice. Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.5 diff -u -p -r1.5 simpletest.module --- modules/simpletest/simpletest.module 26 Jun 2008 21:07:59 -0000 1.5 +++ modules/simpletest/simpletest.module 4 Jul 2008 07:33:01 -0000 @@ -110,7 +110,7 @@ function simpletest_test_form() { 'data' => array( $result->message, $result->message_group, - basename($result->file), + drupal_basename($result->file), $result->line, $result->caller, $map[$status], Index: modules/upload/upload.test =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.test,v retrieving revision 1.3 diff -u -p -r1.3 upload.test --- modules/upload/upload.test 6 Jun 2008 10:36:44 -0000 1.3 +++ modules/upload/upload.test 4 Jul 2008 07:33:01 -0000 @@ -47,11 +47,11 @@ class UploadTestCase extends DrupalWebTe $this->uploadFile($node, $files[1]); // Check to see that uploaded file is listed and actually accessible. - $this->assertText(basename($files[0]), basename($files[0]) . ' found on node.'); - $this->assertText(basename($files[1]), basename($files[1]) . ' found on node.'); + $this->assertText(drupal_basename($files[0]), drupal_basename($files[0]) . ' found on node.'); + $this->assertText(drupal_basename($files[1]), drupal_basename($files[1]) . ' found on node.'); - $this->checkUploadedFile(basename($files[0])); - $this->checkUploadedFile(basename($files[1])); + $this->checkUploadedFile(drupal_basename($files[0])); + $this->checkUploadedFile(drupal_basename($files[1])); // Fetch db record and use fid to rename and delete file. $upload = db_fetch_object(db_query('SELECT fid, description FROM {upload} WHERE nid = %d', array($node->nid))); @@ -106,7 +106,7 @@ class UploadTestCase extends DrupalWebTe // Attempt to upload .txt file when .test is only extension allowed. $this->uploadFile($node, $files[0], FALSE); - $this->assertRaw(t('The selected file %name could not be uploaded. Only files with the following extensions are allowed: %files-allowed.', array('%name' => basename($files[0]), '%files-allowed' => $settings['upload_extensions'])), 'File '. $files[0] . ' was not allowed to be uploaded'); + $this->assertRaw(t('The selected file %name could not be uploaded. Only files with the following extensions are allowed: %files-allowed.', array('%name' => drupal_basename($files[0]), '%files-allowed' => $settings['upload_extensions'])), 'File '. $files[0] . ' was not allowed to be uploaded'); // Attempt to upload .test file when .test is only extension allowed. $this->uploadFile($node, $files[1]); @@ -140,7 +140,7 @@ class UploadTestCase extends DrupalWebTe $this->uploadFile($node, $file, FALSE); $info = stat($file); - $filename = basename($file); + $filename = drupal_basename($file); $filesize = format_size($info['size']); $maxsize = format_size(parse_size(($settings['upload_uploadsize'] * 1024) . 'KB')); // Won't parse decimals. $this->assertRaw(t('The selected file %name could not be uploaded. The file is %filesize exceeding the maximum file size of %maxsize.', array('%name' => $filename, '%filesize' => $filesize, '%maxsize' => $maxsize)), t('File upload was blocked since it was larger than maxsize.')); Index: scripts/drupal.sh =================================================================== RCS file: /cvs/drupal/drupal/scripts/drupal.sh,v retrieving revision 1.5 diff -u -p -r1.5 drupal.sh --- scripts/drupal.sh 17 Feb 2008 20:09:52 -0000 1.5 +++ scripts/drupal.sh 4 Jul 2008 07:33:01 -0000 @@ -12,7 +12,7 @@ * @param path Drupal's absolute root directory in local file system (optional). * @param URI A URI to execute, including HTTP protocol prefix. */ -$script = basename(array_shift($_SERVER['argv'])); +$script = drupal_basename(array_shift($_SERVER['argv'])); if (in_array('--help', $_SERVER['argv']) || empty($_SERVER['argv'])) { echo <<status] . ']', $result->message, $result->message_group, - basename($result->file), + drupal_basename($result->file), $result->line, $result->caller, );