r35509 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35508‎ | r35509 | r35510 >
Date:19:17, 28 May 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 14273) Fix for HTTP Accept header parsing with spaces as from Konqueror

Also went ahead and had it normalize all values to floats rather than a mix of ints and strings.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1266,7 +1266,7 @@
12671267 function wfAcceptToPrefs( $accept, $def = '*/*' ) {
12681268 # No arg means accept anything (per HTTP spec)
12691269 if( !$accept ) {
1270 - return array( $def => 1 );
 1270+ return array( $def => 1.0 );
12711271 }
12721272
12731273 $prefs = array();
@@ -1275,12 +1275,12 @@
12761276
12771277 foreach( $parts as $part ) {
12781278 # FIXME: doesn't deal with params like 'text/html; level=1'
1279 - @list( $value, $qpart ) = explode( ';', $part );
 1279+ @list( $value, $qpart ) = explode( ';', trim( $part ) );
12801280 $match = array();
12811281 if( !isset( $qpart ) ) {
1282 - $prefs[$value] = 1;
 1282+ $prefs[$value] = 1.0;
12831283 } elseif( preg_match( '/q\s*=\s*(\d*\.\d+)/', $qpart, $match ) ) {
1284 - $prefs[$value] = $match[1];
 1284+ $prefs[$value] = floatval($match[1]);
12851285 }
12861286 }
12871287
Index: trunk/phase3/RELEASE-NOTES
@@ -306,6 +306,7 @@
307307 * (bug 6957) E-mail confirmation links now using English special page name
308308 for better compatibility and keeping the links shorter. Avoids problem
309309 with corrupt links in Gmail on IE 6.
 310+* (bug 14273) Fix for HTTP Accept header parsing with spaces as from Konqueror
310311
311312
312313 === API changes in 1.13 ===

Status & tagging log