Index: tests/formatting/WPTexturize.php
===================================================================
--- tests/formatting/WPTexturize.php	(revision 1337)
+++ tests/formatting/WPTexturize.php	(working copy)
@@ -194,4 +194,55 @@
 		$this->assertEquals( ' &#8212;&nbsp;', wptexturize( ' --&nbsp;' ) );
 		$this->assertEquals( '&nbsp;&#8212; ', wptexturize( '&nbsp;-- ') );
 	}
+
+	/**
+	 * @ticket 22692
+	 */
+	function test_spaces_around_quotes() {
+		$nbsp = "\xC2\xA0";
+		$pi   = "\xCE\xA0";
+
+		// This should never happen, even if the desired output changes some day.
+
+		$problem_input  = "$nbsp\"A";
+		$problem_output = "$nbsp&#8221;A";
+
+		$this->assertNotEquals( $problem_output, wptexturize( $problem_input ) );
+
+		// These are desirable outputs for the current design.
+
+		$input  = array();
+		$output = array();
+
+		$input[]  = "stop. $nbsp\"A quote after 2 spaces.\"";
+		$output[] = "stop. $nbsp&#8220;A quote after 2 spaces.&#8221;";
+
+		$input[]  = "stop.$nbsp$nbsp\"A quote after 2 spaces.\"";
+		$output[] = "stop.$nbsp$nbsp&#8220;A quote after 2 spaces.&#8221;";
+
+		$input[]  = "stop. $nbsp'A quote after 2 spaces.'";
+		$output[] = "stop. $nbsp&#8216;A quote after 2 spaces.&#8217;";
+
+		$input[]  = "stop.$nbsp$nbsp'A quote after 2 spaces.'";
+		$output[] = "stop.$nbsp$nbsp&#8216;A quote after 2 spaces.&#8217;";
+
+		$input[]  = "stop. &nbsp;\"A quote after 2 spaces.\"";
+		$output[] = "stop. &nbsp;&#8220;A quote after 2 spaces.&#8221;";
+
+		$input[]  = "stop.&nbsp;&nbsp;\"A quote after 2 spaces.\"";
+		$output[] = "stop.&nbsp;&nbsp;&#8220;A quote after 2 spaces.&#8221;";
+
+		$input[]  = "stop. &nbsp;'A quote after 2 spaces.'";
+		$output[] = "stop. &nbsp;&#8216;A quote after 2 spaces.&#8217;";
+
+		$input[]  = "stop.&nbsp;&nbsp;'A quote after 2 spaces.'";
+		$output[] = "stop.&nbsp;&nbsp;&#8216;A quote after 2 spaces.&#8217;";
+
+		$input[]  = "Contraction: $pi's";
+		$output[] = "Contraction: $pi&#8217;s";
+
+		foreach($input as $key => $in) {
+			$this->assertEquals( $output[$key], wptexturize( $in ) );
+		}
+	}
 }
