section anchor cleanup, unurlencode :
authorGabriel Wicke <gwicke@users.mediawiki.org>
Sat, 5 Jun 2004 10:34:32 +0000 (10:34 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Sat, 5 Jun 2004 10:34:32 +0000 (10:34 +0000)
includes/EditPage.php
includes/Parser.php

index a4fbb5b..06910ec 100644 (file)
@@ -211,8 +211,12 @@ class EditPage {
                                                # strip out HTML 
                                                $headline = preg_replace( "/<.*?" . ">/","",$headline );
                                                $headline = trim( $headline );
-                                               $sectionanchor = '#'.preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', urlencode( $headline ) );
-                                               $sectionanchor = str_replace('%','.',$sectionanchor);
+                                               $sectionanchor = '#'.urlencode( str_replace(' ', '_', $headline ) );
+                                               $replacearray = array(
+                                                       '%3A' => ':',
+                                                       '%' => '.'
+                                               );
+                                               $sectionanchor = str_replace(array_keys($replacearray),array_values($replacearray),$sectionanchor);
                                        }
                                }
        
index 16ec4c6..a15690b 100644 (file)
@@ -1745,8 +1745,12 @@ class Parser
                        # strip out HTML
                        $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline );
                        $tocline = trim( $canonized_headline );
-                       $canonized_headline = preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', urlencode( do_html_entity_decode( $tocline, ENT_COMPAT, $wgInputEncoding ) ) );
-                       $canonized_headline = str_replace('%','.',$canonized_headline);
+                       $canonized_headline = urlencode( do_html_entity_decode( str_replace(' ', '_', $tocline), ENT_COMPAT, $wgInputEncoding ) );
+                       $replacearray = array(
+                               '%3A' => ':',
+                               '%' => '.'
+                       );
+                       $canonized_headline = str_replace(array_keys($replacearray),array_values($replacearray),$canonized_headline);
                        $refer[$headlineCount] = $canonized_headline;
 
                        # count how many in assoc. array so we can track dupes in anchors