- Didn't use the magic word class to match subst: in the sign*A*ture, as a
result {{Subst:x}} would be turned into {{subst:Subst:x}} (no /i) and
{{this_is_valid_subst_in_some_locale:x}} would be turned into
{{subst:this...}}
* @return string Text
*/
function cleanSig( $text ) {
* @return string Text
*/
function cleanSig( $text ) {
- $text = str_replace( '{{', '{{subst:', $text );
- $text = str_replace( '{{subst:subst:', '{{subst:', $text );
- $text = str_replace( '~~~', '', $text );
- $text = str_replace( '~~~~', '', $text );
- $text = str_replace( '~~~~~', '', $text );
- return( $text );
+ $mw = MagicWord::get( MAG_SUBST );
+ $substre = $mw->getBaseRegex();
+ $subst = $mw->getSynonym( 0 );
+ $i = $mw->getRegexCase();
+
+ $text = preg_replace(
+ "/
+ \{\{
+ (?!
+ (?:
+ $substre
+ )
+ )
+ /x$i",
+ '{{' . $subst,
+ $text
+ );
+
+ $text = preg_replace( '/~{3,5}/', '', $text );
+
+ return $text;