Index: src/wp-includes/taxonomy.php
===================================================================
--- src/wp-includes/taxonomy.php	(revision 28243)
+++ src/wp-includes/taxonomy.php	(working copy)
@@ -2391,7 +2391,13 @@
 
 	$slug_provided = ! empty( $slug );
 	if ( ! $slug_provided ) {
-		$slug = sanitize_title($name);
+		$_name = trim( $name );
+		$existing_term = get_term_by( 'name', $_name, $taxonomy );
+		if ( $existing_term ) {
+			$slug = $existing_term->slug;
+		} else {
+			$slug = sanitize_title( $name );
+		}
 	}
 
 	$term_group = 0;
@@ -3931,4 +3937,4 @@
 		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
 
 	return $parent;
-}
\ No newline at end of file
+}
Index: tests/phpunit/tests/taxonomy.php
===================================================================
--- tests/phpunit/tests/taxonomy.php	(revision 28243)
+++ tests/phpunit/tests/taxonomy.php	(working copy)
@@ -168,4 +168,49 @@
 		wp_set_object_terms( $post->ID, $term['term_id'], 'category' );
 		$this->assertTrue( in_category( $term['term_id'], $post ) );
 	}
+
+	/**
+	 * @ticket 17689
+	 */
+	function test_duplicate_name() {
+		$term = $this->factory->tag->create_and_get( array( 'name' => 'Bozo' ) );
+		$this->assertFalse( is_wp_error( $term ) );
+		$this->assertTrue( empty( $term->errors ) );
+
+		// Test existing term name with unique slug
+		$term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );
+		$this->assertFalse( is_wp_error( $term1 ) );
+		$this->assertTrue( empty($term1->errors ) );
+
+		// Test an existing term name
+		$term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) );
+		$this->assertTrue( is_wp_error( $term2 ) );
+		$this->assertNotEmpty( $term2->errors );
+
+		// Test named terms ending in special characters
+		$term3 = $this->factory->tag->create( array( 'name' => 'T$' ) );
+		$term4 = $this->factory->tag->create( array( 'name' => 'T$$' ) );
+		$term5 = $this->factory->tag->create( array( 'name' => 'T$$$' ) );
+		$term6 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) );
+		$term7 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) );
+		$this->assertTrue( is_wp_error( $term7 ) );
+		$this->assertNotEmpty( $term7->errors );
+		$this->assertEquals( $term6, $term7->error_data['term_exists'] );
+
+		$terms = array_map( 'get_tag', array( $term3, $term4, $term5, $term6 ) );
+		$this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );
+
+		// Test named terms with only special characters
+		$term8 = $this->factory->tag->create( array( 'name' => '$' ) );
+		$term9 = $this->factory->tag->create( array( 'name' => '$$' ) );
+		$term10 = $this->factory->tag->create( array( 'name' => '$$$' ) );
+		$term11 = $this->factory->tag->create( array( 'name' => '$$$$' ) );
+		$term12 = $this->factory->tag->create( array( 'name' => '$$$$' ) );
+		$this->assertTrue( is_wp_error( $term12 ) );
+		$this->assertNotEmpty( $term12->errors );
+		$this->assertEquals( $term11, $term12->error_data['term_exists'] );
+
+		$terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) );
+		$this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );
+	}
 }
