Remove htmlspecialchars() calls on variables that are known to be safe

Must be called when the cursor is at the first argument of the call

@return bool Whether the call was removed
425703
protected function removeHtmlspecialcharsSafeVar()
	{
		if (!$this->isHtmlspecialcharSafeVar())
		{
			 return false;
		}

		// Remove the htmlspecialchars() call, except for its first argument
		unset($this->tokens[$this->i - 2]);
		unset($this->tokens[$this->i - 1]);
		unset($this->tokens[$this->i + 3]);
		unset($this->tokens[$this->i + 4]);
		unset($this->tokens[$this->i + 5]);

		// Move the cursor past the call
		$this->i += 6;

		return true;
	}
966193
public function remainingChars() {
        if ($this->char < $this->EOF) {
            $data = substr($this->data, $this->char);
            $this->char = $this->EOF;
            return $data;
        } else {
            return false;
        }
    }
661547
public function htmlSpecialChars($string, $preserveEntities = false)
    {
        return htmlspecialchars((string)$string, null, null, !$preserveEntities);
    }
548063
public void removeCharCommand()
    {
        if (!isCharCommand())
            return;
        if (getValue() == null)
            return;
        if (getValue().length() < 2)
            return;
        if (getValue().length() == 2)
        {
            setValue(null);
            setUsed(true);
            return;
        }
        setValue("-" + getValue().substring(2));
    }
1006210
private static function supportsCsvEscapeChar()
    {
        if (self::$csvEscapeChar === null) {
            self::$csvEscapeChar = version_compare(PHP_VERSION, '5.5.4') >= 0;
        }

        return self::$csvEscapeChar;
    }
1219173
private function removeUnprocessableTags()
    {
        foreach ($this->unprocessableHtmlTags as $tagName) {
            // Deleting nodes from a 'live' NodeList invalidates iteration on it, so a copy must be made to iterate.
            $nodes = [];
            foreach ($this->domDocument->getElementsByTagName($tagName) as $node) {
                $nodes[] = $node;
            }
            /** @var \DOMNode $node */
            foreach ($nodes as $node) {
                $hasContent = $node->hasChildNodes() || $node->hasChildNodes();
                if (!$hasContent) {
                    $node->parentNode->removeChild($node);
                }
            }
        }
    }
366365
private function trim()
	{
		if (utf8_strlen($this->message) <= ($this->length + $this->length_tolerance))
		{
			return false;
		}

		if (!$this->bbcode_uid)
		{
			$this->trimmed_message = utf8_substr($this->message, 0, $this->length) . $this->append_str;
			return true;
		}

		$this->trim_action();
		return $this->bbcodes->is_trimmed();
	}
766538
function _remove_invisible_characters($str)
	{
		static $non_displayables;

		if ( ! isset($non_displayables))
		{
			// every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
			$non_displayables = array(
										'/%0[0-8bcef]/',			// url encoded 00-08, 11, 12, 14, 15
										'/%1[0-9a-f]/',				// url encoded 16-31
										'/[\x00-\x08]/',			// 00-08
										'/\x0b/', '/\x0c/',			// 11, 12
										'/[\x0e-\x1f]/'				// 14-31
									);
		}

		do
		{
			$cleaned = $str;
			$str = preg_replace($non_displayables, '', $str);
		}
		while ($cleaned != $str);

		return $str;
	}
202090
public function checkChars($value)
    {
        if (strlen($value) != 8) {
            if (strpos($value, 'X') !== false) {
                return false;
            }
        }

        return parent::checkChars($value);
    }
923681
protected function removeChar($string, $charStart = null, $charEnd = null)
    {
        if (!is_null($charStart) && (is_string($charStart) || is_array($charStart))) {
            if (is_string($charStart)) {
                $charStart = [$charStart];
            }

            foreach ($charStart as $char) {
                if (substr($string, 0, 1) === $char) {
                    $string = substr($string, 1);
                }
            }
        }

        if (!is_null($charEnd) && (is_string($charEnd) || is_array($charEnd))) {
            if (is_string($charEnd)) {
                $charEnd = [$charEnd];
            }

            foreach ($charEnd as $char) {
                if (substr($string, -1) === $char) {
                    $string = substr($string, 0, -1);
                }
            }
        }

        return $string;
    }
559210
public function isStringType()
    {
        $stringTypeList = [
            'char',
            'varchar',
            'tinyblob',
            'blob',
            'mediumblob',
            'longblob',
            'tinytext',
            'text',
            'mediumtext',
            'longtext'
        ];
        $isString = false;
        $type = trim(strtolower($this->getType()));
        foreach ($stringTypeList as $stringType) {
            // Column type has string type prefix (e.g. VARCHAR(100), TEXT)
            if (substr($type, 0, strlen($stringType)) === $stringType) {
                $isString = true;
            }
        }
        return $isString;
    }
860732
@Deprecated
	public static String removeChars(String S, char[] chars) {
		int pos;
		while((pos=indexOf(S, chars))!=-1) S=S.substring(0,pos)+S.substring(pos+1);
		return S;
	}
71343
public function cleanString()
		{
			//get rid of newline holders in values
			$this->processString = str_replace('\\\\\\\\n', ' ', $this->processString);

			//replace newline holders with newline
			$this->processString = str_replace('\n', "\n", $this->processString);

			//match returns extra curly bracket at EOL, get rid of it
			$this->processString = substr($this->processString, 0, -1);

			//convert unicode encoded characters to html entities hex
			$this->processString = preg_replace('/\\\\u([0-9a-fA-F]{4})/', '&#x$1;', $this->processString);

			//get rid of escapes added for javascript
			$this->processString = stripslashes($this->processString);
		}
81394
function somechars() {
		var was = false;
		if(!stringmode && !commentmode) {
			if(prototype) {
				switch (character) {
					case '(':
						prencount ++;
						break;
					case ')':
						was = prencount > 0;
						prencount --;
						if(was && prencount === 0) {
							prototype = null;
						}
						break;
					case '{':
						curlcount ++;
						break;
					case '}':
						was = curlcount > 0;
						curlcount --;
						if(was && curlcount === 0) {
							prototype = null;
						}
						break;
				}
			}
		}
	}
54648
public function getChar()
    {
        if (!$this->handle) $this->open('r');
        return $this->fs->fgetc($this->handle);
    }
66652
protected function isHtmlspecialcharSafeVar()
	{
		return ($this->tokens[$this->i    ]    === [T_VARIABLE,        '$node']
		     && $this->tokens[$this->i + 1]    === [T_OBJECT_OPERATOR, '->']
		     && ($this->tokens[$this->i + 2]   === [T_STRING,          'localName']
		      || $this->tokens[$this->i + 2]   === [T_STRING,          'nodeName'])
		     && $this->tokens[$this->i + 3]    === ','
		     && $this->tokens[$this->i + 4][0] === T_LNUMBER
		     && $this->tokens[$this->i + 5]    === ')');
	}
1070305
private static function RemoveUndefinedVars(){
            $oThis = self::CreateInstanceIfNotExists();
            $iOffset = 0;

            while(preg_match('/{\$(.*?)}/i', $oThis->sBuffer, $aMatches, PREG_OFFSET_CAPTURE, $iOffset)){
                $oThis->sBuffer = str_replace($aMatches[0][0], "false", $oThis->sBuffer);
                $iOffset = $aMatches[0][1]+strlen($aMatches[0][0]);
            }
        }