Index: src/wp-includes/functions.php
===================================================================
--- src/wp-includes/functions.php	(revision 49533)
+++ src/wp-includes/functions.php	(working copy)
@@ -1149,6 +1149,7 @@
 	$ret = preg_replace( '#=(&|$)#', '$1', $ret );
 	$ret = $protocol . $base . $ret . $frag;
 	$ret = rtrim( $ret, '?' );
+	$ret = str_replace( '?#', '#', $ret );
 	return $ret;
 }
 
