* (bug 4453) fix for __TOC__ dollar-number breakage
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 4 Jan 2006 00:27:48 +0000 (00:27 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 4 Jan 2006 00:27:48 +0000 (00:27 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php
includes/MagicWord.php

index 24d344d..ef43bfc 100644 (file)
@@ -403,6 +403,7 @@ fully support the editing toolbar, but was found to be too confusing.
   which uses ipboptions
 * (bug 4446) $wgExportAllowHistory option to explicitly disable history in
   Special:Export form, 'exportnohistory' message to translate live hack.
+* (bug 4453) fix for __TOC__ dollar-number breakage
 
 
 === Caveats ===
index c804bb7..23d1777 100644 (file)
@@ -1737,4 +1737,17 @@ function wfUseMW( $req_ver ) {
                wfDebugDieBacktrace( "MediaWiki $req_ver required--this is only $wgVersion" );
 }
 
+/**
+ * Escape a string to make it suitable for inclusion in a preg_replace()
+ * replacement parameter.
+ *
+ * @param string $string
+ * @return string
+ */
+function wfRegexReplacement( $string ) {
+       $string = str_replace( '\\', '\\\\', $string );
+       $string = str_replace( '$', '\\$', $string );
+       return $string;
+}
+
 ?>
index 7d38b0e..603ab8c 100644 (file)
@@ -272,7 +272,7 @@ class MagicWord {
         * Replaces the word with something else
         */
        function replace( $replacement, $subject ) {
-               $res = preg_replace( $this->getRegex(), $replacement, $subject );
+               $res = preg_replace( $this->getRegex(), wfRegexReplacement( $replacement ), $subject );
                $this->mModified = !($res === $subject);
                return $res;
        }