Index: includes/api/ApiFormatBase.php
===================================================================
--- includes/api/ApiFormatBase.php	(.../REL1_9_3/phase3)	(revision 25750)
+++ includes/api/ApiFormatBase.php	(.../REL1_9_4/phase3)	(revision 25750)
@@ -143,8 +143,11 @@
 	* This method also replaces any '<' with &lt;
 	*/
 	protected function formatHTML($text) {
-		// encode all tags as safe blue strings
-		$text = ereg_replace('\<([^>]+)\>', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
+		// Escape everything first for full coverage
+		$text = htmlspecialchars($text);
+		
+		// encode all comments or tags as safe blue strings
+		$text = preg_replace('/\&lt;(!--.*?--|.*?)\&gt;/', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
 		// identify URLs
 		$protos = "http|https|ftp|gopher";
 		$text = ereg_replace("($protos)://[^ '\"()<\n]+", '<a href="\\0">\\0</a>', $text);
Index: includes/WebRequest.php
===================================================================
--- includes/WebRequest.php	(.../REL1_9_3/phase3)	(revision 25750)
+++ includes/WebRequest.php	(.../REL1_9_4/phase3)	(revision 25750)
@@ -328,6 +328,14 @@
 				"REQUEST_URI or SCRIPT_NAME. Report details of your " .
 				"web server configuration to http://bugzilla.wikimedia.org/" );
 		}
+		// User-agents should not send a fragment with the URI, but
+		// if they do, and the web server passes it on to us, we
+		// need to strip it or we get false-positive redirect loops
+		// or weird output URLs
+		$hash = strpos( $base, '#' );
+		if( $hash !== false ) {
+			$base = substr( $base, 0, $hash );
+		}
 		if( $base{0} == '/' ) {
 			return $base;
 		} else {
Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php	(.../REL1_9_3/phase3)	(revision 25750)
+++ includes/DefaultSettings.php	(.../REL1_9_4/phase3)	(revision 25750)
@@ -32,7 +32,7 @@
 $wgConf = new SiteConfiguration;
 
 /** MediaWiki version number */
-$wgVersion			= '1.9.3';
+$wgVersion			= '1.9.4';
 
 /** Name of the site. It must be changed in LocalSettings.php */
 $wgSitename         = 'MediaWiki';
Index: languages/messages/MessagesHe.php
===================================================================
--- languages/messages/MessagesHe.php	(.../REL1_9_3/phase3)	(revision 25750)
+++ languages/messages/MessagesHe.php	(.../REL1_9_4/phase3)	(revision 25750)
@@ -1514,7 +1514,7 @@
 
 שימו לב: הדף '''לא''' יועבר אם כבר יש דף תחת השם החדש, אלא אם הדף הזה ריק, או שהוא הפניה, ואין לו היסטוריה של שינויים. משמעות הדבר, שאפשר לשנות חזרה את שמו של דף לשם המקורי, אם נעשתה טעות, ולא יימחק דף קיים במערכת.
 
-'''אזהרה:''' שינוי זה עשוי להיות שינוי דרסטי ובלתי צפוי לדף פופלארי; אנא ודאו שאתם מבינים את השלכות המעשה לפני שאתם ממשיכים.",
+'''אזהרה:''' שינוי זה עשוי להיות שינוי דרסטי ובלתי צפוי לדף פופולרי; אנא ודאו שאתם מבינים את השלכות המעשה לפני שאתם ממשיכים.",
 'movepagetalktext'        => 'דף השיחה של דף זה יועבר אוטומטית, אלא אם:
 * קיים דף שיחה שאינו ריק תחת השם החדש אליו מועבר הדף.
 * הורדתם את הסימון בתיבה שלהלן.
@@ -2196,10 +2196,10 @@
 'autosumm-new'     => 'דף חדש: $1',
 
 # Size units
-'size-bytes'     => '$1 בייטים',
-'size-kilobytes' => '$1 קילו־בייטים',
-'size-megabytes' => '$1 מגה־בייטים',
-'size-gigabytes' => "$1 ג'יגה־בייטים",
+'size-bytes'     => '$1 בייט',
+'size-kilobytes' => '$1 קילו־בייט',
+'size-megabytes' => '$1 מגה־בייט',
+'size-gigabytes' => "$1 ג'יגה־בייט",
 
 );
 
Index: RELEASE-NOTES
===================================================================
--- RELEASE-NOTES	(.../REL1_9_3/phase3)	(revision 25750)
+++ RELEASE-NOTES	(.../REL1_9_4/phase3)	(revision 25750)
@@ -3,6 +3,41 @@
 Security reminder: MediaWiki does not require PHP's register_globals
 setting since version 1.2.0. If you have it on, turn it *off* if you can.
 
+== MediaWiki 1.9.4 ==
+
+September 10, 2007
+
+This is a security and bug fix update to the Winter 2007 quarterly release.
+Minor compatibility fixes for IIS 5 are included.
+
+* (bug 8847) Strip spurious #fragments from request URI to fix redirect
+  loops on some server configurations
+* A possible HTML/XSS injection vector in the API pretty-printing mode
+  has been found and fixed.
+
+The vulnerability may be worked around in an unfixed version by simply
+disabling the API interface if it is not in use, by adding this to
+LocalSettings.php:
+
+  $wgEnableAPI = false;
+
+Not vulnerable versions:
+* 1.11 >= 1.11.0
+* 1.10 >= 1.10.2
+* 1.9 >= 1.9.4
+* 1.8 >= 1.8.5
+
+Vulnerable versions:
+* 1.11 <= 1.11.0rc1
+* 1.10 <= 1.10.1
+* 1.9 <= 1.9.3
+* 1.8 <= 1.8.4 (if $wgEnableAPI has been switched on)
+
+MediaWiki 1.7 and below are not affected as they do not include
+the faulty function, however the BotQuery extension is similarly
+vulnerable unless updated to the latest SVN version.
+
+
 == MediaWiki 1.9.3 ==
 
 February 20, 2007
