From: Kurt Zeilenga Date: Tue, 24 Aug 1999 01:13:30 +0000 (+0000) Subject: Rename filter entry's strcpy_special() to strcpy_regex() to better X-Git-Tag: TWEB_OL_BASE~123 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d2719123dc05d1b5327f03acdd6f39e9465d294;p=openldap Rename filter entry's strcpy_special() to strcpy_regex() to better reflect its purpose. Modify switch to support REG_EXTENDED expressions. Use REG_EXTENDED instead of REG_BASIC everywhere. Modify to support for testing purposes. Requires: env CPPFLAGS="-DHAVE_GNUREGEX_H=1" LIBS=-lgnuregex ./configure --- diff --git a/include/ac/regex.h b/include/ac/regex.h index 99afaec3d8..30a3482359 100644 --- a/include/ac/regex.h +++ b/include/ac/regex.h @@ -25,6 +25,10 @@ For NT: http://people.delphi.com/gjc/hs_regex.html */ #error "No POSIX REGEX available." + +#elif HAVE_GNUREGEX_H + /* system has GNU gnuregex.h */ +# include #else /* have regex.h, assume it's POSIX compliant */ # include diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index b0a181a8ef..2c06810ab6 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -253,7 +253,7 @@ ldap_getfirstfilter( continue; /* compile flp->ifl_pattern, continue if we fail */ - if (regcomp(&re, flp->lfl_pattern, 0) != 0) + if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED) != 0) continue; /* match ifl_pattern and lfd_curval, continue if we fail */ diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index dd6da92f64..f65c8472a8 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -283,18 +283,24 @@ test_filter_list( } static void -strcpy_special( char *d, char *s ) +strcpy_regex( char *d, char *s ) { for ( ; *s; s++ ) { switch ( *s ) { + case '^': case '.': - case '\\': case '[': - case ']': + case ']': /* ? */ + case '$': + case '(': + case ')': /* ? */ + case '|': case '*': case '+': - case '^': - case '$': + case '?': + case '{': + case '}': /* ? */ + case '\\': *d++ = '\\'; /* FALL */ default: @@ -356,7 +362,7 @@ test_substring_filter( 0, 0, 0 ); return( -1 ); } - strcpy_special( p, f->f_sub_initial ); + strcpy_regex( p, f->f_sub_initial ); p = strchr( p, '\0' ); } if ( f->f_sub_any != NULL ) { @@ -369,7 +375,7 @@ test_substring_filter( } strcpy( p, ".*" ); p = strchr( p, '\0' ); - strcpy_special( p, f->f_sub_any[i] ); + strcpy_regex( p, f->f_sub_any[i] ); p = strchr( p, '\0' ); } } @@ -382,7 +388,7 @@ test_substring_filter( } strcpy( p, ".*" ); p = strchr( p, '\0' ); - strcpy_special( p, f->f_sub_final ); + strcpy_regex( p, f->f_sub_final ); p = strchr( p, '\0' ); strcpy( p, "$" ); } @@ -390,7 +396,7 @@ test_substring_filter( /* compile the regex */ Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n", pat, 0, 0 ); - if ((rc = regcomp(&re, pat, 0))) { + if ((rc = regcomp(&re, pat, REG_EXTENDED))) { char error[512]; regerror(rc, &re, error, sizeof(error));