From d9d9843f656da8700ad24edc72aac4075f514864 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 28 May 2008 19:17:02 +0000 Subject: [PATCH] * (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. --- RELEASE-NOTES | 1 + includes/GlobalFunctions.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f520008d8e..fbb0b043ae 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 3294c8f9b0..8c05555656 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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]); } } -- 2.20.1