r50902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50901‎ | r50902 | r50903 >
Date:17:40, 22 May 2009
Author:philip
Status:ok
Tags:
Comment:
Follow up on r49157. Fixed the header parsing code to conform to RFC 2616 section 14.4.
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -184,8 +184,17 @@
185185 // preference is loaded
186186 if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) {
187187 $acceptLanguage = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
188 - $languages = preg_split('/[,;]/', $acceptLanguage);
 188+
 189+ // take the part of the string up to the first semicolon
 190+ if($semiPos = strpos( $acceptLanguage, ';' ) !== false )
 191+ $acceptLanguage = substr( $acceptLanguage, 0, $semiPos );
 192+
 193+ // explode by comma
 194+ $languages = explode(',', $acceptLanguage);
 195+
189196 foreach( $languages as $language ) {
 197+ // strip whitespace
 198+ $language = trim( $language );
190199 if( in_array( $language, $this->mVariants ) ) {
191200 return $language;
192201 break;

Follow-up revisions

RevisionCommit summaryAuthorDate
r50938Follow up on r49157 and r50902. Fixed the header parsing code to conform to RFC.philip15:27, 23 May 2009
r511771. Follow up on r49157, r50902 and r50938. According RFC 2616 section 14.4, l...philip05:07, 30 May 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r491571. Rewrite code for parsing http request header to get supported language var...philip17:35, 3 April 2009

Status & tagging log