r44817 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44816‎ | r44817 | r44818 >
Date:00:01, 20 December 2008
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Delay $wgContLang unstubbing
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -220,13 +220,10 @@
221221 */
222222 function getGPCVal( $arr, $name, $default ) {
223223 if( isset( $arr[$name] ) ) {
224 - global $wgContLang;
225224 $data = $arr[$name];
226225 if( isset( $_GET[$name] ) && !is_array( $data ) ) {
227226 # Check for alternate/legacy character encoding.
228 - if( isset( $wgContLang ) ) {
229 - $data = $wgContLang->checkTitleEncoding( $data );
230 - }
 227+ $data = $this->checkTitleEncoding( $data );
231228 }
232229 $data = $this->normalizeUnicode( $data );
233230 return $data;
@@ -234,7 +231,21 @@
235232 return $default;
236233 }
237234 }
 235+
 236+ protected function checkTitleEncoding( $s ) {
 237+ global $wgContLang;
 238+ if( !isset($wgContLang) ) return $s;
 239+ # Check for non-UTF-8 URLs
 240+ $ishigh = preg_match( '/[\x80-\xff]/', $s);
 241+ if( !$ishigh ) return $s;
238242
 243+ $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
 244+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
 245+ if( $isutf8 ) return $s;
 246+ # Do the heavy lifting by unstubbing $wgContLang
 247+ return $wgContLang->iconv( $wgContLang->fallback8bitEncoding(), "utf-8", $s );
 248+ }
 249+
239250 /**
240251 * Fetch a scalar from the input or return $default if it's not set.
241252 * Returns a string. Arrays are discarded. Useful for

Follow-up revisions

RevisionCommit summaryAuthorDate
r44965Revert r44817 "Delay $wgContLang unstubbing"...brion19:56, 23 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   19:56, 23 December 2008

Maintainability alert -- creates duplicate code which could become out of sync!

Reverted in r44965

Status & tagging log