From: Brion Vibber Date: Wed, 4 Jan 2006 00:27:48 +0000 (+0000) Subject: * (bug 4453) fix for __TOC__ dollar-number breakage X-Git-Tag: 1.6.0~777 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=41701080d2c9b0b37990f5d79e8eee1c9b3b4093;p=lhc%2Fweb%2Fwiklou.git * (bug 4453) fix for __TOC__ dollar-number breakage --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 24d344de1d..ef43bfcd9b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c804bb7558..23d177701f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; +} + ?> diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 7d38b0ee75..603ab8c049 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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; }