diff --git modules/update/update.manager.inc modules/update/update.manager.inc index 4f55b1b..a6dafe7 100644 --- modules/update/update.manager.inc +++ modules/update/update.manager.inc @@ -644,8 +644,13 @@ function update_manager_install_form_submit($form, &$form_state) { form_set_error($field, t('Provided archive contains no files.')); return; } - // Unfortunately, we can only use the directory name for this. :( - $project = drupal_substr($files[0], 0, -1); + + // Unfortunately, we can only use the directory name to determine the project + // name. Some archivers list the first file as the directory (i.e., MODULE/) + // and others list an actual file (i.e., MODULE/README.TXT). + $path = str_replace('\\', '/', $files[0]); // Windows path sanitization. + $project = explode('/', $path, 2); + $project = $project[0]; $archive_errors = update_manager_archive_verify($project, $local_cache, $directory); if (!empty($archive_errors)) { @@ -771,8 +776,14 @@ function update_manager_archive_extract($file, $directory) { // old files mixed with the new files (e.g. in cases where files were removed // from a later release). $files = $archiver->listContents(); - // Unfortunately, we can only use the directory name for this. :( - $project = drupal_substr($files[0], 0, -1); + + // Unfortunately, we can only use the directory name to determine the project + // name. Some archivers list the first file as the directory (i.e., MODULE/) + // and others list an actual file (i.e., MODULE/README.TXT). + $path = str_replace('\\', '/', $files[0]); // Windows path sanitization. + $project = explode('/', $path, 2); + $project = $project[0]; + $extract_location = $directory . '/' . $project; if (file_exists($extract_location)) { file_unmanaged_delete_recursive($extract_location);