Process paragraph
@return string
@param $str string
339344
protected function _p($str) {
		$str=trim($str);
		if (strlen($str)) {
			if (preg_match('/^(.+?\n)([>#].+)$/s',$str,$parts))
				return $this->_p($parts[1]).$this->build($parts[2]);
			$str=preg_replace_callback(
				'/([^<>\[]+)?(<[\?%].+?[\?%]>|<.+?>|\[.+?\]\s*\(.+?\))|'.
				'(.+)/s',
				function($expr) {
					$tmp='';
					if (isset($expr[4]))
						$tmp.=$this->esc($expr[4]);
					else {
						if (isset($expr[1]))
							$tmp.=$this->esc($expr[1]);
						$tmp.=$expr[2];
						if (isset($expr[3]))
							$tmp.=$this->esc($expr[3]);
					}
					return $tmp;
				},
				$str
			);
			$str=preg_replace('/\s{2}\r?\n/','<br />',$str);
			return '<p>'.$this->scan($str).'</p>'."\n\n";
		}
		return '';
	}
1213095
public static function strip($str)
    {
        $ascii = '';
        for($i=0; $i<strlen($str); $i++){
            if(ord($str{$i}) <128){
                $ascii .= $str{$i};
            }
        }
        return $ascii;
    }
526492
private function parseHeaders($str) {

		if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}
		
		$headers = [];
		$status  = [];

		foreach(explode("\n", $str) as $header) {
			
			if(preg_match('/(:)/is', $header)) {
				list($key, $value) = preg_split('/(:)/is', $header, 2);
			}
			else {
				$key = $header;
			}

			if(trim($key) !== '') {

				if(preg_match('/(https?\/[0-9]\.[0-9])/i', $key, $http)) {

					$status['code'] = null;

					if(preg_match('/([0-9]+)/', ltrim($key, $http[0]), $code)) {
						$status['code'] = $code[0];
					}

					$status['protocol'] = $http[0];
					$status['status'] 	= trim($key);
					$status['text'] 	= trim(ltrim(trim(ltrim($key, $status['protocol'])), $status['code']));
					
				}
				else {
					$headers[strtolower($key)] = trim($value);
				}
			}
		}

		return ['headers' => $headers, 'status' => $status];
	}
1279230
public static function makeHTMLString($str)
    {

        $str = trim($str);
        $str = htmlspecialchars($str, ENT_COMPAT, 'utf-8');

        return nl2br($str);
    }
1074652
protected function _code($str) {
		$self=$this;
		return preg_replace_callback(
			'/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/',
			function($expr) use($self) {
				return '<code>'.
					$self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>';
			},
			$str
		);
	}
915957
private function _do($str)
    {
        $str = (string) $str;
        $strInt = (int) $str;
        $strFloat = (float) $str;
        if (
            !$str
            ||
            (string) $strInt === $str
            ||
            (string) $strFloat === $str
        ) {

            // no xss found
            if ($this->_xss_found !== true) {
                $this->_xss_found = false;
            }

            return $str;
        }

        // remove the BOM from UTF-8 / UTF-16 / UTF-32 strings
        $str = UTF8::remove_bom($str);

        // replace the diamond question mark (�) and invalid-UTF8 chars
        $str = UTF8::replace_diamond_question_mark($str, '');

        // replace invisible characters with one single space
        $str = UTF8::remove_invisible_characters($str, true, ' ');

        // normalize the whitespace
        $str = UTF8::normalize_whitespace($str);

        // decode UTF-7 characters
        $str = $this->_repack_utf7($str);

        // decode the string
        $str = $this->_decode_string($str);

        // remove all >= 4-Byte chars if needed
        if ($this->_stripe_4byte_chars) {
            $str = (string) \preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $str);
        }

        // backup the string (for later comparision)
        $str_backup = $str;

        // remove strings that are never allowed
        $str = $this->_do_never_allowed($str);

        // corrects words before the browser will do it
        $str = $this->_compact_exploded_javascript($str);

        // remove disallowed javascript calls in links, images etc.
        $str = $this->_remove_disallowed_javascript($str);

        // remove evil attributes such as style, onclick and xmlns
        $str = $this->_remove_evil_attributes($str);

        // sanitize naughty JavaScript elements
        $str = $this->_sanitize_naughty_javascript($str);

        // sanitize naughty HTML elements
        $str = $this->_sanitize_naughty_html($str);

        // final clean up
        //
        // -> This adds a bit of extra precaution in case something got through the above filters.
        $str = $this->_do_never_allowed_afterwards($str);

        // check for xss
        if ($this->_xss_found !== true) {
            $this->_xss_found = !($str_backup === $str);
        }

        return $str;
    }
152420
public static function parse_attrib_string($str)
    {
        $attrib = array();
        $html   = '<html>'
            . '<head><meta http-equiv="Content-Type" content="text/html; charset=' . RCUBE_CHARSET . '" /></head>'
            . '<body><div ' . rtrim($str, '/ ') . ' /></body>'
            . '</html>';

        $document = new DOMDocument('1.0', RCUBE_CHARSET);
        @$document->loadHTML($html);

        if ($node = $document->getElementsByTagName('div')->item(0)) {
            foreach ($node->attributes as $name => $attr) {
                $attrib[strtolower($name)] = $attr->nodeValue;
            }
        }

        return $attrib;
    }
934819
public static function camelize($str)
    {
        $str = strtolower($str);
        $str = strtr($str, '_', ' ');
        $str = preg_replace('/\s+/', '', ucwords($str));

        return lcfirst($str);
    }
900474
protected static function normalize($str)
    {
        $str = static::normalizeNewLines($str);
        // remove control characters; leave \t + \n
        $str = preg_replace('#[\x00-\x08\x0B-\x1F\x7F-\x9F]+#u', '', $str);
        // right trim
        $str = preg_replace('#[\t ]+$#m', '', $str);
        // leading and trailing blank lines
        $str = trim($str, "\n");

        return $str;
    }
100499
function ParseStr($str) {
		$this->Clear();

		$this->modifyContent($str);

		$pos = strpos($str, '@');
		while ($pos !== false) {
			$start = $pos;
			$pos++;
			$media = '';
			$count = -1;

			while(true) {
				if ($str[$pos] == '{') {
					if ($count == -1) {
						$media = substr($str, $start, ($pos-$start));
						$count = 0;
					}
					$count++;
				}
				if ($str[$pos] == '}') $count--;

				if ($count == 0) {
					$end = $pos;

					$fullmedia = substr($str, $start, ($end-$start)+1);

					$subparse = substr($fullmedia, strpos($fullmedia, '{')+1);

					$subparse = substr($subparse, 0, -1);

					$cssparser = new Css($this->prefix);
					$cssparser->SetUrl($this->thisUrl);
					$cssparser->ParseStr($subparse);
					$codestr = $cssparser->GetCSS();

					$str = str_replace($fullmedia, '', $str);
					$this->Add($media, $codestr);
					$pos = 0;
					break;
				}
				$pos++;
				if ($pos == strlen($str)) break;
			}
			$pos = strpos($str, '@', $pos);
		}

		if (preg_match_all('#([^}]*){([^}]*)}#Sis', $str, $parts)) {
			foreach($parts[1] as $key => $keystr) {
				$codestr = trim($parts[2][$key]);
				$keys = explode(',', trim($keystr));
				if(count($keys)) {
					foreach($keys as $value) {
						$value = trim($value);
						if(strlen($value)) {
							$this->Add($value, $codestr);
						}
					}
				}
			}
		}
		return (count($this->css) > 0);
	}
467593
public static function replaceRoman(string $str) : string
    {
        $str = self::strToArray($str);
        return implode('', self::replaceRomanArray($str));
    }
966657
public static function strToHex($str)
	{
		$r = "";
		$l = strlen($str);
		for($i = 0; $i < $l; $i++)
			$r .= str_pad(strtoupper(dechex(ord($str[$i]))), 2, " ",
				STR_PAD_LEFT) . " ";
		return $r;
	}
305099
public function chunk($str = null)
    {
        parent::chunk();

        if (null !== $str) {
            printf("%x\r\n", strlen($str));
            echo "$str\r\n";
            flush();
        }

        return $this;
    }
199318
public static function encode(String $str) : String
    {
        return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str);
    }
110946
public function parse($str)
	{
		if ($this->isQuoteHtml() === true)
		{
			$str = htmlspecialchars($str, ENT_QUOTES);
		}

		foreach ($this->getBbCodes() as $key => $val)
		{
			$str = preg_replace($key, $val, $str);
		}

		return $str;
	}
994910
public function parseString($str) {
        $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7);
        $this->ast = $parser->parse($str);
        return $this;
    }
1064022
public static function core($str)
    {
        $str = _String::normalizePunctuationSpaces($str);
        $str = mb_strtolower(trim($str));
        $str = _String::normalizeSpaces($str);
        return $str;
    }