Horde_Ldap_Filter::_parseLeaf PHP Method

_parseLeaf() protected static method

Parses a single leaf component.
protected static _parseLeaf ( string $filter ) : Horde_Ldap_Filter
$filter string An LDAP filter string.
return Horde_Ldap_Filter
    protected static function _parseLeaf($filter)
    {
        // Detect multiple leaf components.
        // [TODO] Maybe this will make problems with filters containing
        // brackets inside the value.
        if (strpos($filter, ')(')) {
            throw new Horde_Ldap_Exception('Invalid filter syntax: multiple leaf components detected');
        }
        $filter_parts = preg_split('/(?<!\\\\)(=|=~|>|<|>=|<=)/', $filter, 2, PREG_SPLIT_DELIM_CAPTURE);
        if (count($filter_parts) != 3) {
            throw new Horde_Ldap_Exception('Invalid filter syntax: unknown matching rule used');
        }
        // [TODO]: Do we need to escape at all? what about *-chars user provide
        //         and that should remain special?  I think, those prevent
        //         escaping! We need to check against PERL Net::LDAP!
        // $value_arr = Horde_Ldap_Util::escapeFilterValue(array($filter_parts[2]));
        // $value     = $value_arr[0];
        return new Horde_Ldap_Filter(array('filter' => '(' . $filter_parts[0] . $filter_parts[1] . $filter_parts[2] . ')'));
    }