(bug 8247) Minor tweaks to includes/CoreParserFunctions.php and parser test for ANCHO...
authorRob Church <robchurch@users.mediawiki.org>
Fri, 22 Dec 2006 02:36:06 +0000 (02:36 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Fri, 22 Dec 2006 02:36:06 +0000 (02:36 +0000)
includes/CoreParserFunctions.php
maintenance/parserTests.txt

index 74a187b..80280cf 100644 (file)
@@ -65,7 +65,6 @@ class CoreParserFunctions {
        static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); }
 
        static function urlFunction( $func, $s = '', $arg = null ) {
-               $found = false;
                $title = Title::newFromText( $s );
                # Due to order of execution of a lot of bits, the values might be encoded
                # before arriving here; if that's true, then the title can't be created
@@ -79,9 +78,6 @@ class CoreParserFunctions {
                        } else {
                                $text = $title->$func();
                        }
-                       $found = true;
-               }
-               if ( $found ) {
                        return $text;
                } else {
                        return array( 'found' => false );
@@ -172,7 +168,7 @@ class CoreParserFunctions {
        }
        
        static function anchorencode( $parser, $text ) {
-               return str_replace( '%', '.', str_replace('+', '_', urlencode( $text ) ) );
+               return strtr( urlencode( $text ) , array( '%' => '.' , '+' => '_' ) );
        }
 
        static function special( $parser, $text ) {
index 923f466..b009807 100644 (file)
@@ -6135,6 +6135,16 @@ Pages in namespace (Magic word disabled currently)
 !! end
 
 
+!! test
+anchorencode
+!! input
+{{anchorencode:foo barĀ©#%n}}
+!! result
+<p>foo_bar.C2.A9.23.25n
+</p>
+!! end
+
+
 !! test
 Bug 8293: Use of center tag ruins paragraph formatting
 !! input