Index: src/wp-includes/compat.php
===================================================================
--- src/wp-includes/compat.php	(revision 38708)
+++ src/wp-includes/compat.php	(working copy)
@@ -41,6 +41,34 @@
 	return $utf8_pcre;
 }
 
+/**
+ * Returns whether PCRE Unicode character properties (UCP, eg \p{L}) are available for use.
+ *
+ * @ignore
+ * @since 4.7.0
+ * @access private
+ *
+ * @staticvar string $ucp_pcre
+ *
+ * @param bool $set - Used for testing only
+ *             null   : default - get PCRE UCP capability
+ *             false  : Used for testing - return false for future calls to this function
+ *             'reset': Used for testing - restore default behavior of this function
+ */
+function _wp_can_use_pcre_ucp( $set = null ) {
+	static $ucp_pcre = 'reset';
+
+	if ( null !== $set ) {
+		$ucp_pcre = $set;
+	}
+
+	if ( 'reset' === $ucp_pcre ) {
+		$ucp_pcre = false !== @preg_match( '/\p{L}/u', '' );
+	}
+
+	return $ucp_pcre;
+}
+
 if ( ! function_exists( 'mb_substr' ) ) :
 	/**
 	 * Compat function to mimic mb_substr().
Index: src/wp-includes/formatting.php
===================================================================
--- src/wp-includes/formatting.php	(revision 38708)
+++ src/wp-includes/formatting.php	(working copy)
@@ -1711,6 +1711,18 @@
 		}
 
 		$string = strtr($string, $chars);
+
+		// Removes "Mn" nonspacing combining marks that follow Latin characters.
+		if ( _wp_can_use_pcre_ucp() ) { // If UCP available.
+			$string = preg_replace( '/(?<=\p{Latin})\p{Mn}+/u', '', $string );
+		} else {
+			static $mn_regex_alts, $latin_regex_alts;
+			if ( ! isset( $mn_regex_alts ) ) {
+				require dirname( __FILE__ ) . '/unicode/regex_alts.php';
+			}
+			$string = preg_replace( '/(?<=' . $latin_regex_alts . ')(?:' . $mn_regex_alts . ')+/', '', $string );
+		}
+
 	} else {
 		$chars = array();
 		// Assume ISO-8859-1 if not UTF-8
Index: src/wp-includes/unicode/regex_alts.php
===================================================================
--- src/wp-includes/unicode/regex_alts.php	(nonexistent)
+++ src/wp-includes/unicode/regex_alts.php	(working copy)
@@ -0,0 +1,18 @@
+<?php
+/*
+ * Generated by "gen_cat_regex_alts.php" from "UnicodeData.txt". Don't edit!
+ * Mn general category code points.
+ *
+ * See http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt
+ */
+
+$mn_regex_alts = '\xcc[\x80-\xbf]|\xcd[\x80-\xaf]|\xd2[\x83-\x87]|\xd6[\x91-\xbd\xbf]|\xd7[\x81\x82\x84\x85\x87]|\xd8[\x90-\x9a]|\xd9[\x8b-\x9f\xb0]|\xdb[\x96-\x9c\x9f-\xa4\xa7\xa8\xaa-\xad]|\xdc[\x91\xb0-\xbf]|\xdd[\x80-\x8a]|\xde[\xa6-\xb0]|\xdf[\xab-\xb3]|\xe0(?:\xa0[\x96-\x99\x9b-\xa3\xa5-\xa7\xa9-\xad]|\xa1[\x99-\x9b]|\xa3[\x94-\xa1\xa3-\xbf]|\xa4[\x80-\x82\xba\xbc]|\xa5[\x81-\x88\x8d\x91-\x97\xa2\xa3]|\xa6[\x81\xbc]|\xa7[\x81-\x84\x8d\xa2\xa3]|\xa8[\x81\x82\xbc]|\xa9[\x81\x82\x87\x88\x8b-\x8d\x91\xb0\xb1\xb5]|\xaa[\x81\x82\xbc]|\xab[\x81-\x85\x87\x88\x8d\xa2\xa3]|\xac[\x81\xbc\xbf]|\xad[\x81-\x84\x8d\x96\xa2\xa3]|\xae\x82|\xaf[\x80\x8d]|\xb0[\x80\xbe\xbf]|\xb1[\x80\x86-\x88\x8a-\x8d\x95\x96\xa2\xa3]|\xb2[\x81\xbc\xbf]|\xb3[\x86\x8c\x8d\xa2\xa3]|\xb4\x81|\xb5[\x81-\x84\x8d\xa2\xa3]|\xb7[\x8a\x92-\x94\x96]|\xb8[\xb1\xb4-\xba]|\xb9[\x87-\x8e]|\xba[\xb1\xb4-\xb9\xbb\xbc]|\xbb[\x88-\x8d]|\xbc[\x98\x99\xb5\xb7\xb9]|\xbd[\xb1-\xbe]|\xbe[\x80-\x84\x86\x87\x8d-\x97\x99-\xbc]|\xbf\x86)|\xe1(?:\x80[\xad-\xb0\x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xa8[\x81-\x83\x85\x86\x8c-\x8f\xb8-\xba\xbf]|\xab[\xa5\xa6])|\x91(?:\x80[\x81\xb8-\xbf]|\x81[\x80-\x86\xbf]|\x82[\x80\x81\xb3-\xb6\xb9\xba]|\x84[\x80-\x82\xa7-\xab\xad-\xb4]|\x85\xb3|\x86[\x80\x81\xb6-\xbe]|\x87[\x8a-\x8c]|\x88[\xaf-\xb1\xb4\xb6\xb7\xbe]|\x8b[\x9f\xa3-\xaa]|\x8c[\x80\x81\xbc]|\x8d[\x80\xa6-\xac\xb0-\xb4]|\x90[\xb8-\xbf]|\x91[\x82-\x84\x86]|\x92[\xb3-\xb8\xba\xbf]|\x93[\x80\x82\x83]|\x96[\xb2-\xb5\xbc\xbd\xbf]|\x97[\x80\x9c\x9d]|\x98[\xb3-\xba\xbd\xbf]|\x99\x80|\x9a[\xab\xad\xb0-\xb5\xb7]|\x9c[\x9d-\x9f\xa2-\xa5\xa7-\xab]|\xb0[\xb0-\xb6\xb8-\xbd\xbf]|\xb2[\x92-\xa7\xaa-\xb0\xb2\xb3\xb5\xb6])|\x96(?:\xab[\xb0-\xb4]|\xac[\xb0-\xb6]|\xbe[\x8f-\x92])|\x9b\xb2[\x9d\x9e]|\x9d(?:\x85[\xa7-\xa9\xbb-\xbf]|\x86[\x80-\x82\x85-\x8b\xaa-\xad]|\x89[\x82-\x84]|\xa8[\x80-\xb6\xbb-\xbf]|\xa9[\x80-\xac\xb5]|\xaa[\x84\x9b-\x9f\xa1-\xaf])|\x9e(?:\x80[\x80-\x86\x88-\x98\x9b-\xa1\xa3\xa4\xa6-\xaa]|\xa3[\x90-\x96]|\xa5[\x84-\x8a]))|\xf3\xa0(?:[\x84-\x86][\x80-\xbf]|\x87[\x80-\xaf])'; // 1690 code points.
+
+/*
+ * Generated by "gen_script_regex_alts.php" from "Scripts.txt". Don't edit!
+ * Latin script code points.
+ *
+ * See http://www.unicode.org/Public/9.0.0/ucd/Scripts.txt
+ */
+
+$latin_regex_alts = '[\x41-\x5a\x61-\x7a]|\xc2[\xaa\xba]|\xc3[\x80-\x96\x98-\xb6\xb8-\xbf]|[\xc4-\xc9][\x80-\xbf]|\xca[\x80-\xb8]|\xcb[\xa0-\xa4]|\xe1(?:\xb4[\x80-\xa5\xac-\xbf]|\xb5[\x80-\x9c\xa2-\xa5\xab-\xb7\xb9-\xbf]|\xb6[\x80-\xbe]|[\xb8-\xbb][\x80-\xbf])|\xe2(?:\x81[\xb1\xbf]|\x82[\x90-\x9c]|\x84[\xaa\xab\xb2]|\x85[\x8e\xa0-\xbf]|\x86[\x80-\x88]|\xb1[\xa0-\xbf])|\xea(?:\x9c[\xa2-\xbf]|\x9d[\x80-\xbf]|\x9e[\x80-\x87\x8b-\xae\xb0-\xb7]|\x9f[\xb7-\xbf]|\xac[\xb0-\xbf]|\xad[\x80-\x9a\x9c-\xa4])|\xef(?:\xac[\x80-\x86]|\xbc[\xa1-\xba]|\xbd[\x81-\x9a])'; // 1350 code points.
Index: tests/phpunit/tests/formatting/RemoveAccents.php
===================================================================
--- tests/phpunit/tests/formatting/RemoveAccents.php	(revision 38708)
+++ tests/phpunit/tests/formatting/RemoveAccents.php	(working copy)
@@ -143,4 +143,215 @@
 		
 		$this->assertEquals( 'Dd', remove_accents( 'Đđ' ) );
 	}
+
+	/**
+	 * @ticket 24661
+	 */
+	public function test_remove_accents_mn_combining_marks() {
+		// Creates a string with all Mn nonspacing combining marks (generated from Unicode 5.0.0 "UnicodeData.txt", 880 code points).
+		// (Using Unicode 5.0.0 to be compatible with PHP 5.2.4 (PCRE 7.2).)
+		$code_points = array_merge(
+			  range( 0x300, 0x36f )
+			, range( 0x483, 0x486 )
+			, range( 0x591, 0x5bd )
+			, array( 0x5bf )
+			, range( 0x5c1, 0x5c2 )
+			, range( 0x5c4, 0x5c5 )
+			, array( 0x5c7 )
+			, range( 0x610, 0x615 )
+			, range( 0x64b, 0x65e )
+			, array( 0x670 )
+			, range( 0x6d6, 0x6dc )
+			, range( 0x6df, 0x6e4 )
+			, range( 0x6e7, 0x6e8 )
+			, range( 0x6ea, 0x6ed )
+			, array( 0x711 )
+			, range( 0x730, 0x74a )
+			, range( 0x7a6, 0x7b0 )
+			, range( 0x7eb, 0x7f3 )
+			, range( 0x901, 0x902 )
+			, array( 0x93c )
+			, range( 0x941, 0x948 )
+			, array( 0x94d )
+			, range( 0x951, 0x954 )
+			, range( 0x962, 0x963 )
+			, array( 0x981 )
+			, array( 0x9bc )
+			, range( 0x9c1, 0x9c4 )
+			, array( 0x9cd )
+			, range( 0x9e2, 0x9e3 )
+			, range( 0xa01, 0xa02 )
+			, array( 0xa3c )
+			, range( 0xa41, 0xa42 )
+			, range( 0xa47, 0xa48 )
+			, range( 0xa4b, 0xa4d )
+			, range( 0xa70, 0xa71 )
+			, range( 0xa81, 0xa82 )
+			, array( 0xabc )
+			, range( 0xac1, 0xac5 )
+			, range( 0xac7, 0xac8 )
+			, array( 0xacd )
+			, range( 0xae2, 0xae3 )
+			, array( 0xb01 )
+			, array( 0xb3c )
+			, array( 0xb3f )
+			, range( 0xb41, 0xb43 )
+			, array( 0xb4d )
+			, array( 0xb56 )
+			, array( 0xb82 )
+			, array( 0xbc0 )
+			, array( 0xbcd )
+			, range( 0xc3e, 0xc40 )
+			, range( 0xc46, 0xc48 )
+			, range( 0xc4a, 0xc4d )
+			, range( 0xc55, 0xc56 )
+			, array( 0xcbc )
+			, array( 0xcbf )
+			, array( 0xcc6 )
+			, range( 0xccc, 0xccd )
+			, range( 0xce2, 0xce3 )
+			, range( 0xd41, 0xd43 )
+			, array( 0xd4d )
+			, array( 0xdca )
+			, range( 0xdd2, 0xdd4 )
+			, array( 0xdd6 )
+			, array( 0xe31 )
+			, range( 0xe34, 0xe3a )
+			, range( 0xe47, 0xe4e )
+			, array( 0xeb1 )
+			, range( 0xeb4, 0xeb9 )
+			, range( 0xebb, 0xebc )
+			, range( 0xec8, 0xecd )
+			, range( 0xf18, 0xf19 )
+			, array( 0xf35 )
+			, array( 0xf37 )
+			, array( 0xf39 )
+			, range( 0xf71, 0xf7e )
+			, range( 0xf80, 0xf84 )
+			, range( 0xf86, 0xf87 )
+			, range( 0xf90, 0xf97 )
+			, range( 0xf99, 0xfbc )
+			, array( 0xfc6 )
+			, range( 0x102d, 0x1030 )
+			, array( 0x1032 )
+			, range( 0x1036, 0x1037 )
+			, array( 0x1039 )
+			, range( 0x1058, 0x1059 )
+			, array( 0x135f )
+			, range( 0x1712, 0x1714 )
+			, range( 0x1732, 0x1734 )
+			, range( 0x1752, 0x1753 )
+			, range( 0x1772, 0x1773 )
+			, range( 0x17b7, 0x17bd )
+			, array( 0x17c6 )
+			, range( 0x17c9, 0x17d3 )
+			, array( 0x17dd )
+			, range( 0x180b, 0x180d )
+			, array( 0x18a9 )
+			, range( 0x1920, 0x1922 )
+			, range( 0x1927, 0x1928 )
+			, array( 0x1932 )
+			, range( 0x1939, 0x193b )
+			, range( 0x1a17, 0x1a18 )
+			, range( 0x1b00, 0x1b03 )
+			, array( 0x1b34 )
+			, range( 0x1b36, 0x1b3a )
+			, array( 0x1b3c )
+			, array( 0x1b42 )
+			, range( 0x1b6b, 0x1b73 )
+			, range( 0x1dc0, 0x1dca )
+			, range( 0x1dfe, 0x1dff )
+			, range( 0x20d0, 0x20dc )
+			, array( 0x20e1 )
+			, range( 0x20e5, 0x20ef )
+			, range( 0x302a, 0x302d ) // NOTE: U+302E & U+302F recategorized as Mc in Unicode 6.1.0
+			, range( 0x3099, 0x309a )
+			, array( 0xa806 )
+			, array( 0xa80b )
+			, range( 0xa825, 0xa826 )
+			, array( 0xfb1e )
+			, range( 0xfe00, 0xfe0f )
+			, range( 0xfe20, 0xfe23 )
+			, range( 0x10a01, 0x10a03 )
+			, range( 0x10a05, 0x10a06 )
+			, range( 0x10a0c, 0x10a0f )
+			, range( 0x10a38, 0x10a3a )
+			, array( 0x10a3f )
+			, range( 0x1d167, 0x1d169 )
+			, range( 0x1d17b, 0x1d182 )
+			, range( 0x1d185, 0x1d18b )
+			, range( 0x1d1aa, 0x1d1ad )
+			, range( 0x1d242, 0x1d244 )
+			, range( 0xe0100, 0xe01ef )
+		);
+		$combining_marks = 'a'; // Only if follow Latin character.
+		foreach ( $code_points as $c ) {
+			if ( $c < 0x800 ) {
+				$combining_marks .= chr( 0xc0 | $c >> 6 ) . chr( 0x80 | $c & 0x3f );
+			} elseif ( $c < 0x10000 ) {
+				$combining_marks .= chr( 0xe0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3f ) . chr( 0x80 | $c & 0x3f );
+			} else {
+				$combining_marks .= chr( 0xf0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3f ) . chr( 0x80 | $c >> 6 & 0x3f ) . chr( 0x80 | $c & 0x3f );
+			}
+		}
+		// Performs the test: all the characters should be removed.
+		$this->assertSame( 'a', remove_accents( $combining_marks ) );
+		if ( _wp_can_use_pcre_ucp() ) { // If UCP available.
+			// Test single-byte replace also.
+			_wp_can_use_pcre_ucp( false );
+			$this->assertSame( 'a', remove_accents( $combining_marks ) );
+			_wp_can_use_pcre_ucp( 'reset' );
+		}
+	}
+
+	/**
+	 * @ticket 24661
+	 * @dataProvider data_remove_accents_combining
+	 */
+	function test_remove_accents_combining( $input, $output ) {
+		$this->assertSame( $output, remove_accents( $input ) );
+	}
+
+	function data_remove_accents_combining() {
+		return array(
+			// Test a collection of filenames that could have problems.
+			array(
+				"Capture d’e\xcc\x81cran 2013-02-20 a\xcc\x80 23.36.06.png", // NOTE: apostrophe is U+2019
+				//"Capture d'ecran 2013-02-20 a 23.36.06.png", // NOTE: apostrophe should go to U+0029
+				"Capture d’ecran 2013-02-20 a 23.36.06.png",
+			),
+			array(
+				"Buttermo\xcc\x88deli.jpg",
+				"Buttermodeli.jpg",
+			),
+			array(
+				"Mu\xcc\x88nsterl.Mai13a.jpg",
+				"Munsterl.Mai13a.jpg",
+			),
+
+			array(
+				'Cáo nâu lanh lẹ nhảy qua người lười biếng. Do bạch kim rất quý, sẽ để lắp vô xương',
+				"Cao nau lanh le nhay qua nguoi luoi bieng. Do bach kim rat quy, se de lap vo xuong",
+			),
+			array(
+				'Příliš žluťoučký kůň úpěl ďábelské kódy. Pójdźże, kiń tę chmurność w głąb flaszy! Päťtýždňové vĺčatá nervózne štekajú na môjho ďatľa v tŕní.',
+				"Prilis zlutoucky kun upel dabelske kody. Pojdzze, kin te chmurnosc w glab flaszy! Pattyzdnove vlcata nervozne stekaju na mojho datla v trni.",
+			),
+			array(
+				"Les naïfs ægithales hâtifs pondant à noël où il gèle sont sûrs d'être déçus en voyant leurs drôles d'œufs abîmés.",
+				"Les naifs aegithales hatifs pondant a noel ou il gele sont surs d'etre decus en voyant leurs droles d'oeufs abimes.",
+			),
+			array(
+				'a᷄ (a + combining macron-acute). +⃟ (plus with enclosing diamond). a︠e︡ (ae with a combining ligature)',
+				"a (a + combining macron-acute). +⃟ (plus with enclosing diamond). ae (ae with a combining ligature)", // NOTE: Not doing "Me" enclosing combining marks.
+			),
+
+			// From UTF-8 Sampler http://www.columbia.edu/~fdc/utf8/
+			array(
+				// NOTE: U+200C ZERO WIDTH NON-JOINER not dealt with.
+				"Im finſteren Jagdſchloß am offenen Felsquellwaſſer patzte der affig-flatterhafte kauzig-höf\xe2\x80\x8cliche Bäcker über ſeinem verſifften kniffligen C-Xylophon.",
+				"Im finsteren Jagdschlos am offenen Felsquellwasser patzte der affig-flatterhafte kauzig-hof\xe2\x80\x8cliche Backer uber seinem versifften kniffligen C-Xylophon.",
+			),
+		);
+	}
 }
