Index: src/wp-includes/ms-blogs.php
===================================================================
--- src/wp-includes/ms-blogs.php	(revision 30705)
+++ src/wp-includes/ms-blogs.php	(working copy)
@@ -296,8 +296,14 @@
 
 	$update_details = array();
 	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
-	foreach ( array_intersect( array_keys( $details ), $fields ) as $field )
-		$update_details[$field] = $details[$field];
+	foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) {
+		if ( 'path' === $field ) {
+			$details[ $field ] = array_filter( explode( '/', $details[ $field ] ) );
+			$details[ $field ] = trailingslashit( '/' . implode( '/', $details[ $field ] ) );
+		}
+
+		$update_details[ $field ] = $details[ $field ];
+	}
 
 	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
 
Index: tests/phpunit/tests/multisite/site.php
===================================================================
--- tests/phpunit/tests/multisite/site.php	(revision 30705)
+++ tests/phpunit/tests/multisite/site.php	(working copy)
@@ -329,21 +329,21 @@
 
 		$blog = get_blog_details( $blog_id );
 		$this->assertEquals( 'example.com', $blog->domain );
-		$this->assertEquals( 'my_path/', $blog->path );
+		$this->assertEquals( '/my_path/', $blog->path );
 		$this->assertEquals( '0', $blog->spam );
 
 		$result = update_blog_details( $blog_id, array('domain' => 'example2.com','spam' => 1) );
 		$this->assertTrue( $result );
 		$blog = get_blog_details( $blog_id );
 		$this->assertEquals( 'example2.com', $blog->domain );
-		$this->assertEquals( 'my_path/', $blog->path );
+		$this->assertEquals( '/my_path/', $blog->path );
 		$this->assertEquals( '1', $blog->spam );
 
 		$result = update_blog_details( $blog_id );
 		$this->assertFalse( $result );
 		$blog = get_blog_details( $blog_id );
 		$this->assertEquals( 'example2.com', $blog->domain );
-		$this->assertEquals( 'my_path/', $blog->path );
+		$this->assertEquals( '/my_path/', $blog->path );
 		$this->assertEquals( '1', $blog->spam );
 
 		$test_action_counter = 0;
@@ -475,6 +475,79 @@
 	}
 
 	/**
+	 * When the path for a site is updated with update_blog_details(), the final
+	 * path should have a leading and trailing slash. When multiple directories
+	 * are part of the path, only one slash should separate each directory.
+	 * 
+	 * @ticket 18117 
+	 */ 
+	function test_update_blog_details_single_path_no_slashes() {
+		update_blog_details( 1, array( 'path' => 'my_path' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_single_path_double_trailing_slashes() {
+		update_blog_details( 1, array( 'path' => 'my_path//' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_single_path_double_leading_slashes() {
+		update_blog_details( 1, array( 'path' => '//my_path' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_single_path_single_trailing_slash() {
+		update_blog_details( 1, array( 'path' => 'my_path/' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_single_path_single_leading_slashes() {
+		update_blog_details( 1, array( 'path' => '/my_path' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_single_path_both_slashes() {
+		update_blog_details( 1, array( 'path' => '/my_path/' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/my_path/', $blog->path );
+	}
+
+	function test_update_blog_details_multiple_paths_no_slashes() {
+		update_blog_details( 1, array( 'path' => 'multiple/dirs' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/multiple/dirs/', $blog->path );
+	}
+
+	function test_update_blog_details_multiple_paths_middle_slashes() {
+		update_blog_details( 1, array( 'path' => 'multiple///dirs' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/multiple/dirs/', $blog->path );
+	}
+
+	function test_update_blog_details_multiple_paths_leading_slash() {
+		update_blog_details( 1, array( 'path' => '/multiple/dirs' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/multiple/dirs/', $blog->path );
+	}
+
+	function test_update_blog_details_multiple_paths_trailing_slash() {
+		update_blog_details( 1, array( 'path' => 'multiple/dirs/' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/multiple/dirs/', $blog->path );
+	}
+
+	function test_update_blog_details_multiple_paths_both_slashes() {
+		update_blog_details( 1, array( 'path' => '/multiple/dirs/' ) );
+		$blog = get_blog_details( 1 );
+		$this->assertEquals( '/multiple/dirs/', $blog->path );
+	}
+
+	/**
 	 * Test cached data for a site that does not exist and then again after it exists.
 	 *
 	 * @ticket 23405
