diff --git a/core/lib/Drupal/Core/File/FileSystem.php b/core/lib/Drupal/Core/File/FileSystem.php index 076bc06..b159391 100644 --- a/core/lib/Drupal/Core/File/FileSystem.php +++ b/core/lib/Drupal/Core/File/FileSystem.php @@ -181,8 +181,10 @@ public function mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) { // If recursive, create each missing component of the parent directory // individually and set the mode explicitly to override the umask. if ($recursive) { - // Ensure the path is using DIRECTORY_SEPARATOR. - $uri = str_replace('/', DIRECTORY_SEPARATOR, $uri); + // Ensure the path is using DIRECTORY_SEPARATOR, and trim off any trailing + // slashes because they can throw off the loop when creating the parent + // directories. + $uri = str_replace('/', DIRECTORY_SEPARATOR, rtrim($uri, '\/')); // Determine the components of the path. $components = explode(DIRECTORY_SEPARATOR, $uri); // If the filepath is absolute the first component will be empty as there