From 81e0b9d3c0c2bad288a3d73a38738070092db467 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 2 Sep 2004 08:01:13 +0000 Subject: [PATCH] One more unicode normalization fix: don't die horribly on arrays, and get the PATH_INFO title too. --- includes/WebRequest.php | 20 +++++++++++--------- index.php | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 04742bb0a8..1ebc2438d7 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -27,7 +27,10 @@ class WebRequest { $this->checkMagicQuotes(); global $wgUseLatin1; if( !$wgUseLatin1 ) { - $this->normalizeUnicode(); + require_once( 'normal/UtfNormal.php' ); + wfProfileIn( 'WebRequest:normalizeUnicode-fix' ); + $this->normalizeUnicode( $_REQUEST ); + wfProfileOut( 'WebRequest:normalizeUnicode-fix' ); } } @@ -53,15 +56,14 @@ class WebRequest { } } - function normalizeUnicode() { - wfProfileIn( 'WebRequest:normalizeUnicode-include' ); - require_once( 'normal/UtfNormal.php' ); - wfProfileOut( 'WebRequest:normalizeUnicode-include' ); - wfProfileIn( 'WebRequest:normalizeUnicode-fix' ); - foreach( $_REQUEST as $key => $val ) { - $_REQUEST[$key] = UtfNormal::toNFC( $val ); + function normalizeUnicode( &$arr ) { + foreach( $arr as $key => $val ) { + if( is_array( $val ) ) { + $this->normalizeUnicode( $arr[$key ] ); + } else { + $arr[$key] = UtfNormal::toNFC( $val ); + } } - wfProfileOut( 'WebRequest:normalizeUnicode-fix' ); } function getGPCVal( &$arr, $name, $default ) { diff --git a/index.php b/index.php index 045b0a114c..8f60e00da8 100644 --- a/index.php +++ b/index.php @@ -28,6 +28,10 @@ $action = $wgRequest->getVal( "action", "view" ); if( isset( $_SERVER['PATH_INFO'] ) && $wgUsePathInfo ) { $title = substr( $_SERVER['PATH_INFO'], 1 ); + if( !$wgUseLatin1 ) { + require_once( 'includes/normal/UtfNormal.php' ); + $title = UtfNormal::toNFC( $title ); + } } else { $title = $wgRequest->getVal( "title" ); } -- 2.20.1