escape() public static method

Returns an escaped string for use in an LDAP filter.
public static escape ( string $value, string $ignore = '', $flags ) : string
$value string
$ignore string
$flags
return string
Esempio n. 1
0
 /**
  * Constructor.
  *
  * @param string $field
  * @param string $operator
  * @param string $value
  *
  * @throws InvalidQueryOperatorException
  */
 public function __construct($field, $operator, $value)
 {
     // We'll escape the field to avoid allowing unsafe characters inside.
     $this->field = Utilities::escape($field, null, 3);
     // Validate and retrieve the operator.
     $this->operator = $this->validateOperator($operator);
     // Completely escape the value.
     $this->value = Utilities::escape($value);
 }
Esempio n. 2
0
 /**
  * Assembles an RDN with the specified attribute and value.
  *
  * @param string $attribute
  * @param array  $values
  *
  * @return null|string
  */
 protected function assembleRdns($attribute, array $values = [])
 {
     if (count($values) > 0) {
         $values = array_reverse($values);
         $values = array_map(function ($value) use($attribute) {
             return sprintf('%s=%s', $attribute, Utilities::escape($value, '', 2));
         }, $values);
         return implode(',', $values);
     }
     return;
 }
Esempio n. 3
0
 /**
  * Adds a binding to the query.
  *
  * @param string $field
  * @param string $operator
  * @param string $value
  * @param string $type
  *
  * @throws InvalidQueryOperatorException
  *
  * @return Builder
  */
 public function addBinding($field, $operator, $value, $type = 'where')
 {
     if (!array_key_exists($type, $this->bindings)) {
         throw new InvalidArgumentException("Invalid binding type: {$type}.");
     }
     $operator = $this->getOperator($operator);
     $value = Utilities::escape($value);
     $this->{$this->bindings[$type]}[] = compact('field', 'operator', 'value');
     return $this;
 }
Esempio n. 4
0
 /**
  * Assembles an RDN with the specified attribute and value.
  *
  * @param string $attribute
  * @param array  $values
  *
  * @return string
  */
 protected function assembleRdns($attribute, array $values = [])
 {
     return implode(',', array_map(function ($value) use($attribute) {
         return sprintf('%s=%s', $attribute, Utilities::escape($value, '', 2));
     }, $values));
 }