扫描并返回检测到的敏感词。

@param string $text 要扫描的文本。
@param null $replaceList 如果传入此变量，函数会将需要替换的字符组扔进这个变量里，此变量可以在 WordBan::escape 方法中使用。
@return array 返回敏感词组成的数组。
435756
public function scan($text, &$replaceList = null)
    {
        $scan_result = array();
        $text = $this->_matchCase ? $text : strtolower($text);
        $text_length = mb_strlen($text);
        for ($i = 0; $i < $text_length; $i++) {
            $word_length = $this->_check($text, $i, $text_length);
            if ($word_length > 0) {
                $word = mb_substr($text, $i, $word_length);
                $scan_result[] = $word;
                $replaceList !== null && $replaceList[] = str_repeat($this->_escapeChar, mb_strlen($word));
                $i += $word_length - 1;
            }
        }
        return $scan_result;
    }
1029809
public function parser($text, $replacements = []): string
	{
		global $context;

		if (empty($text) || empty($replacements) || !is_array($replacements))
			return '';

		// Split the replacements up into two arrays, for use with str_replace.
		$find = [];
		$replace = [];

		foreach ($replacements as $f => $r)
		{
			$find[] = '{' . $f . '}';
			$replace[] = $r . ((strpos($f,'href') !== false) ? (';'. $context['session_var'] .'='. $context['session_id']) : '');
		}

		// Do the variable replacements.
		return str_replace($find, $replace, $text);
	}
112367
public static function ampReplace($text)
    {
        $text = str_replace('&&', '*--*', $text);
        $text = str_replace('&#', '*-*', $text);
        $text = str_replace('&amp;', '&', $text);
        $text = preg_replace('|&(?![\w]+;)|', '&amp;', $text);
        $text = str_replace('*-*', '&#', $text);
        $text = str_replace('*--*', '&&', $text);

        return $text;
    }
582474
protected static function removeUnusedPlaceholders($text)
    {
        $text = preg_replace(self::PLACEHOLDER_REGEX, '', $text);
        return preg_replace(self::COMMAND_REGEX, '', $text);
    }
957508
private function _convertTagsToEscapeSequences ( $text ) {
        list($patterns, $replacements) = $this->_getConvertingDictionary();
        $convertedText = preg_replace($patterns, $replacements, $text);
        return $convertedText;
    }
1139849
public function replaceExact(array $words, $replace, $text)
    {
        return Replace\Normal::replace($words, $replace, $text);
    }
488456
public static function cleanMsChar($text, $quotesOnly=false)
	{
		$y = array(
			"\x7f"=>'',
			"\x80"=>'&#8364;',
			"\x81"=>'',
			"\x83"=>'&#402;',
			"\x85"=>'&#8230;',
			"\x86"=>'&#8224;',
			"\x87"=>'&#8225;',
			"\x88"=>'&#710;',
			"\x89"=>'&#8240;',
			"\x8a"=>'&#352;',
			"\x8b"=>'&#8249;',
			"\x8c"=>'&#338;',
			"\x8d"=>'',
			"\x8e"=>'&#381;',
			"\x8f"=>'',
			"\x90"=>'',
			"\x95"=>'&#8226;',
			"\x96"=>'&#8211;',
			"\x97"=>'&#8212;',
			"\x98"=>'&#732;',
			"\x99"=>'&#8482;',
			"\x9a"=>'&#353;',
			"\x9b"=>'&#8250;',
			"\x9c"=>'&#339;',
			"\x9d"=>'',
			"\x9e"=>'&#382;',
			"\x9f"=>'&#376;',
		);
		$x = array(
			"\x82"=>'\'',
			"\x84"=>'"',
			"\x91"=>'\'',
			"\x92"=>'\'',
			"\x93"=>'"',
			"\x94"=>'"'
		);
		if (!$quotesOnly)
		{
			$x = $y + $x;
		}

		$text = strtr($text, $x);

		return $text;
	}
1273398
protected function replaceText($string)
    {
        if (empty($string)) {
            $this->node->parentNode->removeChild($this->node);

            return null;
        }

        $newElement = $this->node->ownerDocument->createTextNode($string);

        $newNode = $this->node->ownerDocument->importNode($newElement, true);

        $this->node->parentNode->replaceChild($newNode, $this->node);
        $this->node = $newNode;

        return $this;
    }
804245
public static function replaceStringPlaceholders($text, $deletePlaceholders = false)
    {
        if (is_string($text)) {
            // Fast pre-check, to optimize performance
            if (strpos($text, "_") !== false) {
                $replaceStringPlaceholders = function ($matches) use ($deletePlaceholders) {
                    $result = "";
                    if (isset(self::$replacements[$matches[1]])) {
                        $result = self::$replacements[$matches[1]];
                        $result = str_replace(
                            ['_STRING_CSSLINEBREAK_', '_STRING_ESCAPEDDOUBLEQUOTE_', '_STRING_ESCAPEDSINGLEQUOTE_'],
                            ["\\\n", '\\"', "\\'"],
                            $result
                        );
                        if ($deletePlaceholders === true) {
                            unset(self::$replacements[$matches[1]]);
                        }
                    }
                    return $result;
                };
                $text = preg_replace_callback('/(?:_STRING_([a-f0-9]{32})_)/', $replaceStringPlaceholders, $text);
            }
            return $text;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($text). "' for argument 'text' given."
            );
        }
    }
905704
function get_words($text = null)
    {
        if ($text) {
            $matches = $this->check($text);
        }
        else {
            $matches = $this->matches;
            $text    = $this->content;
        }

        $result = array();

        foreach ($matches as $m) {
            $result[] = mb_substr($text, $m[1], $m[2], RCUBE_CHARSET);
        }

        return $result;
    }
705602
protected function escapeLatex($string)
	{
		if ($this->_escaper === null) {
			$this->_escaper = new TextToLatex();
		}
		return $this->_escaper->convert($string);
	}
54371
public function inject($text)
    {
        if (!is_string($text)) {
            return $text; // nothing to do here
        }

        foreach ($this->parameters as $key => $parameter) {
            if (strpos($text, $key) === false) {
                continue;
            }

            if (is_callable($parameter)) {
                $parameter = call_user_func($parameter);
            }

            $text = str_replace($key, $parameter, $text);
        }

        return $text;
    }
749707
public function prependEmpty($text=NULL) {
		
		$t = Translator::getInstance();
		
		$option			= new \stdClass();
		$option->value	= '';
		$option->text	= is_null($text) ? $t->get('SELECT_NULL_VALUE') : $text;

		$this->list = array_merge(array($option), $this->list);
		
		return $this;
		
	}
1052897
public static function sanitizeText($text)
    {
        if (!$text) {
            return null;
        }

        $allowedTagNames = [ "b", "strong", "i", "em", "br" ];

        $marker = "\&8slkc7\\";

        // Create a one-to-one conversion array for easy replacing
        $allowedTagConversion = [];
        foreach($allowedTagNames as $allowedTagName) {
            $allowedTagConversion["<{$allowedTagName}>"] = "{$marker}{$allowedTagName}{$marker}";
            $allowedTagConversion["<{$allowedTagName}/>"] = "{$marker}{$allowedTagName}/{$marker}";
            $allowedTagConversion["<{$allowedTagName} />"] = "{$marker}{$allowedTagName} /{$marker}";
            $allowedTagConversion["</{$allowedTagName}>"] = "{$marker}/{$allowedTagName}{$marker}";
        }

        // Convert to BB-like tags before sanitizing and then revert
        $text = str_ireplace(array_keys($allowedTagConversion), array_values($allowedTagConversion), $text);

        $text = self::sanitizeString($text);

        if (!$text) {
            return null;
        }

        return str_ireplace(array_values($allowedTagConversion), array_keys($allowedTagConversion), $text);
    }
866013
private function replace(string $text = null, array $data = null)
    {
        if ($text && is_array($data) && sizeof($data) > 0 && $text && is_numeric(array_keys($data)[0])) {
            return vsprintf($text, $data);
        } elseif ($text && !is_null($data) && sizeof($data) > 0) {
            return strtr($text, $data);
        } else {
            return $text ?? null;
        }
    }
730823
protected function replaceTextTokens($text)
    {
        foreach ($this->tokens as $key => $val) {
            $text = str_replace('<' . $key . '>', $val, $text);
        }

        return $text;
    }
1037191
public function transform( $text, $options = null )
    {
        if ( null !== $options )
        {
            $this->setOptions( $options );
        }

        $parser = $this->extraEnabled
                ? new MarkdownExtraParser
                : new MarkdownParser;
        $parsed = $parser->transformMarkdown( $text );

        if ( ! empty( $this->linkTarget ) )
        {
            $parsed = preg_replace(
                '#<(a|form)((\s[^>]*)?)>(.*?)</\\1>#',
                '<$1 target="' . htmlspecialchars( $this->linkTarget ) . '"$2>$4</$1>',
                $parsed
            );
        }

        if ( $this->stripScripts )
        {
            $parsed = preg_replace(
                '#<script(\s[^>]*)?>.*?</script>#',
                '',
                $parsed
            );
        }

        return $parsed;
    }