* (bug 14273) Fix for HTTP Accept header parsing with spaces as from Konqueror
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 28 May 2008 19:17:02 +0000 (19:17 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 28 May 2008 19:17:02 +0000 (19:17 +0000)
Also went ahead and had it normalize all values to floats rather than a mix of ints and strings.

RELEASE-NOTES
includes/GlobalFunctions.php

index f520008..fbb0b04 100644 (file)
@@ -306,6 +306,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 6957) E-mail confirmation links now using English special page name
   for better compatibility and keeping the links shorter. Avoids problem
   with corrupt links in Gmail on IE 6.
+* (bug 14273) Fix for HTTP Accept header parsing with spaces as from Konqueror
 
 
 === API changes in 1.13 ===
index 3294c8f..8c05555 100644 (file)
@@ -1266,7 +1266,7 @@ function wfClearOutputBuffers() {
 function wfAcceptToPrefs( $accept, $def = '*/*' ) {
        # No arg means accept anything (per HTTP spec)
        if( !$accept ) {
-               return array( $def => 1 );
+               return array( $def => 1.0 );
        }
 
        $prefs = array();
@@ -1275,12 +1275,12 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) {
 
        foreach( $parts as $part ) {
                # FIXME: doesn't deal with params like 'text/html; level=1'
-               @list( $value, $qpart ) = explode( ';', $part );
+               @list( $value, $qpart ) = explode( ';', trim( $part ) );
                $match = array();
                if( !isset( $qpart ) ) {
-                       $prefs[$value] = 1;
+                       $prefs[$value] = 1.0;
                } elseif( preg_match( '/q\s*=\s*(\d*\.\d+)/', $qpart, $match ) ) {
-                       $prefs[$value] = $match[1];
+                       $prefs[$value] = floatval($match[1]);
                }
        }