Returns an escaped string for use in an LDAP filter.

@param string $value
@param string $ignore
@param $flags

@return string
549766
public function escape($value, $ignore = '', $flags = 0)
    {
        if (!$this->isEscapingSupported()) {
            return $this->escapeManual($value, $ignore, $flags);
        }

        return ldap_escape($value, $ignore, $flags);
    }
766414
public function escape($string, $flags = null) {
        if ($flags === null) {
            $flags = ENT_QUOTES;
        }

        $flags |= ENT_SUBSTITUTE;

        return htmlentities($string, $flags, 'UTF-8', false);
    }
853152
public function sanitize_ignored_themes( $value ) {
		$value = (array) $value;
		$valid_slugs = array_values( wp_list_pluck( wp_get_themes(), 'stylesheet' ) );
		$invalid_slugs = array_diff( $value, $valid_slugs );

		if ( ! empty( $invalid_slugs ) ) {
			add_settings_error(
				'soter_ignored_plugins',
				'invalid_soter_ignored_plugins',
				sprintf(
					'Only currently installed themes can be ignored. The following invalid theme slugs were provided: %s',
					implode( ', ', array_map( 'esc_html', $invalid_slugs ) )
				)
			);

			return $this->ignored_themes;
		}

		return $value;
	}
917239
public function escape( $value ) {
		$value = (string)$value;

		if( $this->enableBool ) {
			if( $value == '' ) {
				return 'false';
			} elseif( $value == '1' ) {
				return 'true';
			}
		}

		if( $this->enableNumeric && is_numeric($value) ) {
			return (string)$value;
		}

		if( $this->enableAlphaNumeric && is_string($value) && ctype_alnum($value) && !is_numeric($value) ) {
			return (string)$value;
		}

		return var_export($value, true);
	}
560815
public function orWhereLike($field, $value, $flags = 'imxsu', $delimiter = null)
    {
        return $this->whereLike($field, $value, $flags, $delimiter, '$or');
    }
1996
public function valueObject($value, $exclude = false, $meaning = null)
    {
        switch (gettype($value)) {
            case 'boolean':
                $propertyValue = [
                    'booleanValue' => $value
                ];

                break;

            case 'integer':
                $propertyValue = [
                    'integerValue' => $value
                ];

                break;

            case 'double':
                $propertyValue = [
                    'doubleValue' => $value
                ];

                break;

            case 'string':
                $propertyValue = [
                    'stringValue' => $value
                ];

                break;

            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    $propertyValue = $this->convertArrayToEntityValue($value);
                } else {
                    $propertyValue = $this->convertArrayToArrayValue($value);
                }

                break;

            case 'object':
                $propertyValue = $this->objectProperty($value);
                break;

            case 'resource':
                $content = stream_get_contents($value);

                $propertyValue = [
                    'blobValue' => ($this->encode)
                        ? base64_encode($content)
                        : $content
                ];
                break;

            case 'NULL':
                $propertyValue = [
                    'nullValue' => null
                ];
                break;

            //@codeCoverageIgnoreStart
            case 'unknown type':
                throw new \InvalidArgumentException(sprintf(
                    'Unknown type for `%s',
                    $content
                ));
                break;

            default:
                throw new \InvalidArgumentException(sprintf(
                    'Invalid type for `%s',
                    $content
                ));
                break;
            //@codeCoverageIgnoreEnd
        }

        if ($exclude) {
            $propertyValue['excludeFromIndexes'] = true;
        }

        if ($meaning) {
            $propertyValue['meaning'] = $meaning;
        }

        return $propertyValue;
    }
223740
public static function _($value, $filters = 'raw')
    {
        if (is_string($filters)) {
            $filters = Str::trim($filters);
            $filters = explode(',', $filters);

            if (count($filters) > 0) {
                foreach ($filters as $filter) {
                    $filterName = self::cmd($filter);

                    if ($filterName) {
                        if (method_exists(__CLASS__, $filterName)) {
                            $value = self::$filterName($value);
                        } else {
                            throw new Exception('Undefined filter method: ' . $filter);
                        }
                    }
                }
            }
        } elseif ($filters instanceof \Closure) {
            $value = $filters($value);
        }

        return $value;
    }
1234445
public function filter($value)
    {
        $normalized = preg_replace('/\s+/', ' ', strtolower(trim($value)));
        if (array_key_exists($normalized, $this->states) === true) {
            return $this->states[$normalized];
        }
        if (
            $this->getConfig('includeTerritories') === true &&
            array_key_exists($normalized, $this->territories) === true
        ) {
            return $this->territories[$normalized];
        }
        if ($this->getConfig('abortOnInvalidInput') === true) {
            throw new \UnexpectedValueException('Input value can not be mapped to a state name.');
        }
        return $value;
    }
1138864
public static function escape( $value )
    {
        if ( is_string($value) ){
            $res = htmlspecialchars($value, ENT_QUOTES, mb_internal_encoding());
//log_debug( "debug", "escape:" . print_r($res,true) );
            return $res;
        }
        elseif ( is_array($value) ){
            $ret = array();
            foreach( $value as $key => $item ){
                $ret[$key] = self::escape( $item );
            }
            return $ret;
        }
        elseif ( is_object($value) ){
            $object = $value;
            $vars = get_object_vars($object);
            foreach( $vars as $key => $value ){
                $object->$key = self::escape( $value );
            }
            return $object;
        }
        return $value;
    }
968948
private static function jsonEncode($value, int $flags = null, int $maxDepth = 512): string
    {
        $flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION);

        if (!\is_array($value) && !$value instanceof \JsonSerializable) {
            throw new InvalidArgumentException(sprintf('Option "json" must be array or JsonSerializable, %s given.', \is_object($value) ? \get_class($value) : \gettype($value)));
        }

        try {
            $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth);
        } catch (\JsonException $e) {
            throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
        }

        if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
            throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', json_last_error_msg()));
        }

        return $value;
    }
1114536
public function escape($value = null, array $doNotEscape = [])
    {
        $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape));

        if (\is_null($value)) {
            return 'NULL';
        }
        if (\is_int($value) || \is_float($value)) {
            return $value;
        }
        if (\is_array($value) || \is_object($value)) {
            return $this->dbClass->escape(\serialize($value));
        }

        foreach ($this->doNotEscape as $doNotEscape) {
            if (\preg_match('/^'.\str_replace('*', '\\*', $doNotEscape).'/i', (string)$value)) {
                return $value;
            }
        }
        return $this->dbClass->escape($value);
    }
64495
protected function parse_value($value, array $replacements = null) {
		//remove double-slashes (//)
		$value = preg_replace('/[\/]{2,}/', '\/', $value);

		//remove leading slash for string replaces (i.e. "{/MAIN/SITE_ROOT}" becomes "{MAIN/SITE_ROOT}")
		$value = preg_replace('/{\//', '{', $value);

		//replace special vars.
		$value = ToolBox::mini_parser($value, $replacements, '{', '}');
		
		if(strlen($value)) {
			$value = ToolBox::resolve_path_with_dots($value);
		}
		
		return($value);
	}
636271
private function stringEscaped($value)
    {
        $value = $this->string($value);
        $value = str_replace(self::$strReplaceFrom, self::$strReplaceTo, $value);

        return $value;
    }
280178
protected static function placeholderEscape($value) {
    return SafeMarkup::isSafe($value) ? (string) $value : Html::escape($value);
  }
15260
public function filter($value) {
    	    	
    	$value   = str_replace(["\r", "\r\n", "\n"], '', $value);
    	$decoded = json_decode($value,true);
    	if(is_null($decoded)){
    		return null;
    	}    	
    	
    	switch($this->options["format"]){
    	    case self::DECODED:
    	        return $decoded;
    	    case self::JSON:
    	        return $value;
    	    case self::SERIALIZED:
    	        return serialize($decoded);
    	    default:
    	        throw new FilterException("unknown format for JSON filter specified");
    	}
    }
1250434
public static function quote($value)
    {
        $escapedValue = preg_quote($value);
        if (substr_count($escapedValue, '/') && !substr_count($escapedValue, '\/')) {
            $escapedValue = str_replace('/', '\/', $escapedValue);
        }

        return $escapedValue;
    }
925374
protected static function maskHasFlag($mask, $flag)
    {
        $flag   = (int)$flag;
        return ((int)$mask & $flag) === $flag;
    }