? drupal_6_basename.patch Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.756.2.57 diff -u -p -r1.756.2.57 common.inc --- includes/common.inc 1 Jul 2009 20:51:55 -0000 1.756.2.57 +++ includes/common.inc 27 Aug 2009 08:58:59 -0000 @@ -1823,13 +1823,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; @@ -3690,3 +3690,12 @@ function _drupal_flush_css_js() { } variable_set('css_js_query_string', $new_character . substr($string_history, 0, 19)); } + +function drupal_basename($path, $suffix = '') { + $path = preg_replace('|^.+[\\/]|', '', $path); + if ($suffix) { + $path = preg_replace('|'. preg_quote($suffix) .'$|', '', $path); + } + return $path; +} + Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.121.2.7 diff -u -p -r1.121.2.7 file.inc --- includes/file.inc 9 Jun 2009 10:37:38 -0000 1.121.2.7 +++ includes/file.inc 27 Aug 2009 08:58:59 -0000 @@ -155,7 +155,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; @@ -185,7 +185,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) { @@ -243,7 +243,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 @@ -296,7 +296,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; @@ -525,7 +525,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 = file_get_mimetype($file->filename); @@ -895,7 +895,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; Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.174.2.9 diff -u -p -r1.174.2.9 locale.inc --- includes/locale.inc 18 Jun 2009 12:50:33 -0000 1.174.2.9 +++ includes/locale.inc 27 Aug 2009 08:58:59 -0000 @@ -2606,7 +2606,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/Attic/blogapi.module,v retrieving revision 1.115.2.5 diff -u -p -r1.115.2.5 blogapi.module --- modules/blogapi/blogapi.module 8 Oct 2008 20:12:17 -0000 1.115.2.5 +++ modules/blogapi/blogapi.module 27 Aug 2009 08:58:59 -0000 @@ -436,7 +436,7 @@ function blogapi_metaweblog_new_media_ob $whitelist = array_unique(explode(' ', trim($extensions))); - $name = basename($file['name']); + $name = drupal_basename($file['name']); if ($extension_position = strrpos($name, '.')) { $filename = drupal_substr($name, 0, $extension_position); Index: modules/color/color.module =================================================================== RCS file: /cvs/drupal/drupal/modules/color/color.module,v retrieving revision 1.39.2.2 diff -u -p -r1.39.2.2 color.module --- modules/color/color.module 16 May 2009 16:09:21 -0000 1.39.2.2 +++ modules/color/color.module 27 Aug 2009 08:58:59 -0000 @@ -86,7 +86,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; @@ -310,7 +310,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; @@ -352,7 +352,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); } @@ -484,7 +484,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.