One more unicode normalization fix: don't die horribly on arrays, and get the PATH_IN...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 2 Sep 2004 08:01:13 +0000 (08:01 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 2 Sep 2004 08:01:13 +0000 (08:01 +0000)
includes/WebRequest.php
index.php

index 04742bb..1ebc243 100644 (file)
@@ -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 ) {
index 045b0a1..8f60e00 100644 (file)
--- 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" );
 }