Sanitise the added value

@param mixed $value Value to sanitise

@return string
518773
private function sanitise($value)
    {
        if ($value instanceof VerbalExpression) {
            // no need to run sanitisation on an existing expression object
            return $value;
        }

        if (!is_string($value)) {
            $value = (string)$value;
        }

        $regExp  = '/[^\w]/';

        return preg_replace_callback(
            $regExp,
            function ($matches) {
                return "\\" . $matches[0];
            },
            $value
        );
    }
652203
private static function sanitizeString($value)
    {
        // $_GET and $_REQUEST already urldecode()'d
        // decode
        // note: before php 5.2.7, htmlspecialchars() double encodes &#x hex items
        $value = html_entity_decode($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');

        $value = self::sanitizeNullBytes($value);

        // escape
        $tmp = @htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');

        // note: php 5.2.5 and above, htmlspecialchars is destructive if input is not UTF-8
        if ($value != '' && $tmp == '') {
            // convert and escape
            $value = utf8_encode($value);
            $tmp = htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
            return $tmp;
        }
        return $tmp;
    }
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;
	}
558915
public 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;
    }
1370830
protected function wrapValue($value)
    {
        $value = Str::upper($value);

        return $this->isReserved($value) ? '"' . $value . '"' : $value;
    }
1321518
public function sanitize($value)
    {
        if(!$value instanceof ObjectConfigJson)
        {
            if(is_string($value)) {
                $value = $this->getObject('object.config.factory')->fromString('json', $value);
            } else {
                $value = $this->getObject('object.config.factory')->createFormat('json', $value);
            }
        }

        return $value;
    }
367287
public function sanitizeSetting($value)
    {
        $keys = $this->repository()->getSettings()->collapse()->map(function ($setting) {
            /** @var FieldTypeInterface $setting */
            return $setting->getName();
        });

        $settingName = $keys->slice($this->offset, 1)->first();
        $lastSetting = $this->repository()->getSettings()->collapse()->last();
        $data = collect($_POST);

        if ($this->offset > $keys->count() - 1) {
            if (empty($value)) {
                return '';
            }

            // Sanitize is called one more time with a valid value.
            // Let's get the $settingName based on the given value
            // as we can't rely anymore on the offset.
            $settingName = $data->search($value, true);

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

            // Let's add a "fake" error to avoid duplicate success messages.
            $this->errors++;
        }

        $setting = $this->repository()->getSettingByName($settingName);

        $validator = $this->validator->make(
            $data->all(),
            [$setting->getName() => $setting->getOption('rules')],
            $this->getSettingMessages($setting),
            $this->getSettingPlaceholder($setting)
        );

        // Update setting offset.
        $this->offset++;

        /** @var Validator $validator */
        if ($validator->fails()) {
            $this->errors++;

            add_settings_error(
                $this->getSlug(),
                $setting->getName(),
                $validator->getMessageBag()->first($setting->getName()),
                'error'
            );

            return '';
        }

        if ($settingName === $lastSetting->getName() && ! $this->errors) {
            add_settings_error(
                $this->getSlug(),
                'settings_updated',
                __('Settings saved.'),
                'updated'
            );
        }

        return $value;
    }
1013787
protected function addValue($value)
    {
        $name                = 'where' . $this->whereContainer->getBindingCount();
        $this->values[$name] = $value;

        return ':' . $name;
    }
719436
public static function sanitize($value)
    {
        if (is_array($value) || is_object($value))
        {
            foreach ($value as $key => $val)
            {
                $value[$key] = self::sanitize($val);
            }
        }
        elseif (is_string($value))
        {
            $value = stripslashes($value);
            if (false !== strpos($value, "\r"))
            {
                $value = str_replace([
                    "\r\n",
                    "\r"
                ], "\n", $value);
            }
        }

        return $value;
    }
56120
protected function sanitizeNodeToValue($value)
    {
        $first = strpos($value, '>')+1;
        $last = strrpos($value, '<')-$first;
        $value = substr($value, $first, $last);
        $value = str_replace('"', "'", $value);
        return trim($value);
    }
74832
protected function _sanitize($value)
    {
        if (null === $this->_charList) {
            return trim((string) $value);
        } else {
            return trim((string) $value, $this->_charList);
        }
    }
1045968
public static function sanitize( $value ) {
		if ( class_exists( '\Kirki\Field\Color' ) ) {
			return \Kirki\Field\Color::sanitize( $value );
		}
		return esc_attr( $value );
	}
985683
protected function _sanitize($value)
    {
        $string = htmlentities(utf8_decode($value));
        $string = preg_replace(
            array('/&szlig;/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'),
            array('ss',"$1","$1".'e',"$1"),
            $string
        );

        return $string;
    }
739517
public function clean($value)
    {
        if ($value === true || $value === false) {
            return $value;
        } elseif (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = $this->clean($v);
            }
        } else {
            $value = preg_replace('/^\"|\"$/', '', $value);
            $value = stripcslashes($value);
        }

        return $value;
    }
728189
protected function _sanitize($value)
    {
        $value = trim(str_replace('\\', '/', $value));
        preg_match(self::PATTERN, $value, $matches);
        $match = isset($matches[0]) ? $matches[0] : '';

        return $match;
    }
1330637
public static function FILTER_SANITIZE_HTTP_URL($value)
	{
		if( !preg_match('/^http/i', $value)){
			$value = 'http://'.$value;
		}
		$value =  filter_var($value, FILTER_VALIDATE_URL);
		
		return $value?:null;	
	}
831894
public function stripTags($value)
	{
		if ( ! is_array($value))
		{
			$value = filter_var($value, FILTER_SANITIZE_STRING);
		}
		else
		{
			foreach ($value as $k => $v)
			{
				$value[$k] = $this->stripTags($v);
			}
		}

		return $value;
	}