Sanitize a valaue

@param   scalar  Variable to be sanitized
@return  string
346795
protected function _sanitize($value)
    {
        $value      = trim(strtolower($value));
        $pattern    = '/[^a-f0-9]*/';
        return substr(preg_replace($pattern, '', $value), 0, 32);
    }
880537
public function sanitize($value)
    {
        //remove any quotation and replace with whitespace
        $value = preg_replace('/\"/', '', $value);

        //remove any '-' from the string they will be used as concatonater
        $value = str_replace($this->_separator, ' ', $value);

        //convert to ascii characters
        $value = $this->getObject('lib:filter.ascii')->sanitize($value);

        //lowercase and trim
        $value = trim(strtolower($value));

        //remove any duplicate whitespace, and ensure all characters are alphanumeric
        $value = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array($this->_separator,''), $value);

        //remove repeated occurrences of the separator
        $value = preg_replace('/['.preg_quote($this->_separator, '/').']+/', $this->_separator, $value);

        //limit length
        if (strlen($value) > $this->_length) {
            $value = substr($value, 0, $this->_length);
        }

        //remove unwanted separators from the ends
        $value = trim($value, $this->_separator);

        return $value;
    }
533219
static protected function evaluateScalar($scalar)
  {
    $scalar = trim($scalar);

    if ('1.1' === sfYaml::getSpecVersion())
    {
      $trueValues = array('true', 'on', '+', 'yes', 'y');
      $falseValues = array('false', 'off', '-', 'no', 'n');
    }
    else
    {
      $trueValues = array('true');
      $falseValues = array('false');
    }

    switch (true)
    {
      case 'null' == strtolower($scalar):
      case '' == $scalar:
      case '~' == $scalar:
        return null;
      case 0 === strpos($scalar, '!str'):
        return (string) substr($scalar, 5);
      case 0 === strpos($scalar, '! '):
        return intval(self::parseScalar(substr($scalar, 2)));
      case 0 === strpos($scalar, '!!php/object:'):
        return unserialize(substr($scalar, 13));
      case ctype_digit($scalar):
        $raw = $scalar;
        $cast = intval($scalar);
        return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
      case in_array(strtolower($scalar), $trueValues):
        return true;
      case in_array(strtolower($scalar), $falseValues):
        return false;
      case is_numeric($scalar):
        return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
      case 0 == strcasecmp($scalar, '.inf'):
      case 0 == strcasecmp($scalar, '.NaN'):
        return -log(0);
      case 0 == strcasecmp($scalar, '-.inf'):
        return log(0);
      case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
        return floatval(str_replace(',', '', $scalar));
      case preg_match(self::getTimestampRegex(), $scalar):
        return strtotime($scalar);
      default:
        return (string) $scalar;
    }
  }
1217307
public function sanitize($value)
    {
        $value = trim($value);

        $parts  = explode('-', $value, 2);
        if(2 != count($parts)) {
            return null;
        }

        $parts[0]   = substr(preg_replace('/[^a-z]*/', '', $parts[0]), 0, 2);
        $parts[1]   = substr(preg_replace('/[^A-Z]*/', '', $parts[1]), 0, 2);
        $result = implode('-', $parts);

        // just making sure :-)
        if($this->validate($result)) {
            return $result;
        }

        return null;
    }
163867
public function scrub($var)
	{
		if (is_string($var)) {
			// Sanitize strings
			return $this->escape($var);

		} elseif (is_array($var)) {
			// Sanitize arrays
                        foreach($var as $key => $value){
				// casting key to string for the case of numeric indexed arrays
				// i.e. 0, 1, etc. b/c 0 == any string in php
				if (!in_array((string)$key, $this->unguarded)) {
					$var[$key] = $this->scrub($value);
				}
			}

			return $var;
		} elseif (is_object($var)) {
			// Sanitize objects
			$values = get_object_vars($var);

			foreach ($values as $key => $value) {
				$var->$key = $this->scrub($value);
			}
			return $var;

		} else {
			// Not sure what this is. null or bool? Just return it.
			return $var;
		}
	}
1274300
function sanitize (val) {
  if (typeof val !== 'string') {
    return '';
  }
  val = val.replace(/&/g,'&amp;');
  val = val.replace(/"/g,'&quot;');
  val = val.replace(/'/g,'&#039;');
  val = val.replace(/</g,'&lt;');
  val = val.replace(/>/g,'&gt;');
  val = val.replace(/\n/g,'<br />');
  return val ;
}
293228
public function sanitize($value)
    {
        $value = (string) $value;

        if (!empty($value)) {
            $value = JComponentHelper::filterText($value);
        }

        return $value;
    }
1344680
protected function _sanitize($value)
    {
        $value = parent::_sanitize($value);
        $pattern = '/[()<\/>\"\']*/';
        $value = preg_replace_callback($pattern, function($matches) { return '';} , $value);

        return $value;
    }
1084298
protected function _sanitize($value)
    {
        //Tidy is not installed, return the input
        if ($tidy = $this->getTidy($value)) {
            if ($tidy->cleanRepair()) {
                $value = (string) $tidy;
            }
        }

        return $value;
    }
906766
public static String sanitize(String s) {
        if (s != null) {
            StringBuilder b = new StringBuilder(s.length());
            for (int i = 0, count = s.length(); i < count; i++) {
                char c = s.charAt(i);
                switch (c) {
                case '<':
                    b.append("&lt;");
                    break;
                case '>':
                    b.append("&gt;");
                    break;
                case '\'':
                    b.append("&#39;");
                    break;
                case '"':
                    b.append("&quot;");
                    break;
                case '&':
                    b.append("&amp;");
                    break;
                default:
                    b.append(c);
                }
            }
            return b.toString();
        }
        return "";
    }
91963
protected function sanitize($value)
    {
        $value = escapeshellarg(trim((string) $value));
        $value = str_replace("\n", ' ', $value);

        return $value;
    }
45750
static public function sanitizeInjectively($string) {
        $sanitized = '';
        foreach (str_split($string) as $char) {
            $sanitized .= isset(self::$ALLOWED_CHARACTERS[$char]) ? $char : '='.base64_encode($char);
        }
        return $sanitized;
    }
770743
public static function sanitize_recursive( $values, $sanitizer ) {
		if ( ! is_array( $values ) ) {
			return is_scalar( $values ) ? $sanitizer( $values ) : $values;
		}

		foreach ( $values as $key => $value ) {
			if ( is_array( $value ) ) {
				$values[ $key ] = static::sanitize_recursive( $value, $sanitizer );
			} else {
				$values[ $key ] = is_scalar( $value ) ? $sanitizer( $value ) : $value;
			}
		}

		return $values;
	}
270058
function normalizeString(val, normalizer) {
    if (!normalizer) {
        normalizer = (str) => str.toLowerCase().trim();
    }
    return normalizer(toStringSafe(val));
}
357070
public function sanitize( $value ) {
		if ( is_array( $value ) ) {
			foreach ( $value as $key => $subvalue ) {
				if ( '' !== $subvalue || isset( $this->choices[''] ) ) {
					$key           = sanitize_key( $key );
					$value[ $key ] = sanitize_text_field( $subvalue );
				}
			}
			return $value;
		}
		return sanitize_text_field( $value );
	}
151909
protected function sanitize($var) {
        try {
            $this->checkDialect();
        } catch (DialectException $e) {
            return $var;
        }

        if (is_string($var)) {
            return $this->dialect->sanitize($var);
        } else if (is_array($var)) {
            array_walk_recursive($var, function (&$item) {
                if (is_string($item)) {
                    $item = $this->dialect->sanitize($item);
                }
            });

            return $var;
        } else {
            return $var;
        }
    }
1132811
def p_static_scalar(p):
    ''''''
    if len(p) == 2:
        p[0] = p[1]
    elif len(p) == 3:
        p[0] = ''
    else:
        p[0] = p[2].decode('string_escape')