/** * Clean up signature text * * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig * 2) Substitute all transclusions * * @param string $text * @param bool $parsing Whether we're cleaning (preferences save) or parsing * @return string Signature text */ public function cleanSig($text, $parsing = false) { if (!$parsing) { global $wgTitle; $this->startParse($wgTitle, new ParserOptions(), self::OT_PREPROCESS, true); } # Option to disable this feature if (!$this->mOptions->getCleanSignatures()) { return $text; } # @todo FIXME: Regex doesn't respect extension tags or nowiki # => Move this logic to braceSubstitution() $substWord = MagicWord::get('subst'); $substRegex = '/\\{\\{(?!(?:' . $substWord->getBaseRegex() . '))/x' . $substWord->getRegexCase(); $substText = '{{' . $substWord->getSynonym(0); $text = preg_replace($substRegex, $substText, $text); $text = self::cleanSigInSig($text); $dom = $this->preprocessToDom($text); $frame = $this->getPreprocessor()->newFrame(); $text = $frame->expand($dom); if (!$parsing) { $text = $this->mStripState->unstripBoth($text); } return $text; }