Removes any invalid characters from term's name.

@param string $value Term's name
@return string
18693
protected function _setName($value)
    {
        $value = strip_tags($value);
        $value = str_replace(["\n", "\r"], '', $value);

        return trim($value);
    }
1197030
public static function unescapeValue($value)
    {
        $callback = function ($matches) {
            return chr(hexdec($matches[1]));
        };

        return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', $callback, $value);
    }
729490
private static function normalizeValue($value)
    {
        if (is_string($value)) {
            $value = str_ireplace(['&nbsp;', '&#160;'], ' ', $value);
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
923706
public function validate($value) {
        if($this->sanitizable->getRawValue()===$value) {
            return new ValidationResult(true);
        }
        
        return new ValidationResult(false, 'The given value contains illegal characters');
    }
874414
public function filter($value)
        {
            // perform trimming according to the specified criteria
            switch($this->type) {
                case "left":
                    $value = ltrim($value, $this->chars);
                    break;
                case "right":
                    $value = rtrim($value,$this->chars);
                    break;
                default:
                    $value = trim($value,$this->chars);
                    break;
            }

            // we're left with the filtered value
            return $value;
        }
63614
public function sanitize($value)
    {
        // Escape UTF-8 characters
        $value = strtr(rawurlencode($value), static::$_special_characters);

        return filter_var($value, FILTER_SANITIZE_URL);
    }
1119176
public static function stripInvalidXMLCharacters($value)
    {
        if (Lang::isUnicodeCompiled()) {
            return preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $value);
        } else {
            $ret = '';

            if (empty($value)) {
                return $ret;
            }

            $length = strlen($value);

            for ($i=0; $i < $length; $i++) {
                $current = ord($value{$i});
                if (($current == 0x9) ||
                    ($current == 0xA) ||
                    ($current == 0xD) ||
                    (($current >= 0x20) && ($current <= 0xD7FF)) ||
                    (($current >= 0xE000) && ($current <= 0xFFFD)) ||
                    (($current >= 0x10000) && ($current <= 0x10FFFF))) {
                    $ret .= chr($current);
                }
            }

            return $ret;
        }
    }
266638
protected static function getValueAsINI($value)
    {
        $string = '';

        switch (gettype($value)) {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(["\r\n", "\n"], '\\n', $value) . '"';
                break;
        }

        return $string;
    }
733799
protected function _validate($value)
    {
        $value = trim($value);
        return (is_string($value) && ($value === filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)));
    }
407307
public function filter($value)
    {
        $chars = ' ';
        if ($this->getExtras()) {
            $chars .= $this->getExtras();
        }
        return trim($value, $chars);
    }
493324
protected function _sanitize($value)
    {
        $value = (string) $value;

        // Filter var for XSS and other 'bad' code etc.
        if (!empty($value)) {
            $value = $this->_remove($this->_decode($value));
        }

        return $value;
    }
1032523
protected function normalizeSortingString($value)
    {
        if (!is_string($value)) {
            // return if value is not a string
            return $value;
        }

        $value = mb_strtolower($value, 'utf-8');
        $value = preg_replace("/\s+/", '', $value); // remove whitespace
        $value = preg_replace('/-/', '', $value); // remove hyphens e.g. from double names
        $value = preg_replace('/ü/', 'u', $value); // remove umlauts
        $value = preg_replace('/ä/', 'a', $value);
        $value = preg_replace('/ö/', 'o', $value);
        $value = preg_replace('/ë/', 'e', $value);
        $value = preg_replace('/é/', 'e', $value);
        $value = preg_replace('/è/', 'e', $value);
        $value = preg_replace('/ç/', 'c', $value);
        return $value;
    }
800980
public static function clean($value) {
    if (!get_magic_quotes_gpc() && !self::$forceStripSlashes) return $value;
    
    return is_array($value) ?
            array_map(array('GPC','clean'), $value) :
            stripslashes($value);
  }
1199643
protected static function sanitiseVariableValue($value)
        {
            $value = trim($value);

            if (!$value) {
                return '';
            }

            if (strpbrk($value[0], '"\'') !== false) { // value starts with a quote
                $quote = $value[0];

                $regexPattern = sprintf('/^
                    %1$s          # match a quote at the start of the value
                    (             # capturing sub-pattern used
                     (?:          # we do not need to capture this
                      [^%1$s\\\\] # any character other than a quote or backslash
                      |\\\\\\\\   # or two backslashes together
                      |\\\\%1$s   # or an escaped quote e.g \"
                     )*           # as many characters that match the previous rules
                    )             # end of the capturing sub-pattern
                    %1$s          # and the closing quote
                    .*$           # and discard any string after the closing quote
                    /mx',
                    $quote
                );

                $value = preg_replace($regexPattern, '$1', $value);
                $value = str_replace("\\$quote", $quote, $value);
                $value = str_replace('\\\\', '\\', $value);
            } else {
                $parts = explode(' #', $value, 2);
                $value = $parts[0];
            }

            return trim($value);
        }
838743
protected function checkExpression( string$value ):string
	{
		return preg_match('/^\(.*\)$/',$value) ? '<?=str_replace(\'"\',\'&quot;\','.substr($value,1,-1).')?>' : str_replace('"','&quot;',$value);
	}
767128
protected function validate_taxonomies($value) {
        $terms = explode(',', $value);

        foreach ($terms as $term) {
            if (!empty($term) && !array_key_exists($term, self::get_taxonomies_list())) {
                return new lang_string('invalidtaxonomy', 'core_competency', $term);
            }
        }

        return true;
    }
446933
public function sanitize_installed_version( $value ) {
		$value = trim( (string) $value );

		if ( (bool) preg_match( '/[^\d\.]/', $value ) ) {
			add_settings_error(
				'soter_installed_version',
				'invalid_soter_installed_version',
				'Installed version can only contain the following characters: 0123456789.'
			);

			return $this->installed_version;
		}

		return $value;
	}