ldap/servers/plugins/syntaxes/string.c | 6 +++---
ldap/servers/slapd/filterentry.c | 19 ++++++++++++++++---
ldap/servers/slapd/proto-slap.h | 2 ++
3 files changed, 21 insertions(+), 6 deletions(-)
New commits:
commit 41c5be046a21f06a1e743513631814186c7df79b
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 25 11:51:26 2010 -0600
Bug 576074 - search filters with parentheses fail
https://bugzilla.redhat.com/show_bug.cgi?id=576074
Resolves: bug 576074
Bug Description: search filters with parentheses fail
Reviewed by: nhosoi (Thanks!)
Branch: Directory_Server_8_2_Branch
Fix Description: PCRE requires '(' and ')' to be escaped to match a
literal
parenthesis. Otherwise, it thinks the parenthesis is used for grouping.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit c1d2e7461ac41f39f5f27f3d9dcd6084bb4435a5)
diff --git a/ldap/servers/plugins/syntaxes/string.c
b/ldap/servers/plugins/syntaxes/string.c
index ad607dc..dd44a80 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -262,7 +262,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char
*final,
if ( initial != NULL ) {
value_normalize( initial, syntax, 1 /* trim leading blanks */ );
*p++ = '^';
- filter_strcpy_special( p, initial );
+ filter_strcpy_special_ext( p, initial, FILTER_STRCPY_ESCAPE_PARENS );
p = strchr( p, '\0' );
}
if ( any != NULL ) {
@@ -271,7 +271,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char
*final,
/* ".*" + value */
*p++ = '.';
*p++ = '*';
- filter_strcpy_special( p, any[i] );
+ filter_strcpy_special_ext( p, any[i], FILTER_STRCPY_ESCAPE_PARENS );
p = strchr( p, '\0' );
}
}
@@ -280,7 +280,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char
*final,
/* ".*" + value */
*p++ = '.';
*p++ = '*';
- filter_strcpy_special( p, final );
+ filter_strcpy_special_ext( p, final, FILTER_STRCPY_ESCAPE_PARENS );
strcat( p, "$" );
}
diff --git a/ldap/servers/slapd/filterentry.c b/ldap/servers/slapd/filterentry.c
index f566676..f163b47 100644
--- a/ldap/servers/slapd/filterentry.c
+++ b/ldap/servers/slapd/filterentry.c
@@ -647,7 +647,7 @@ test_filter_list(
}
void
-filter_strcpy_special( char *d, char *s )
+filter_strcpy_special_ext( char *d, char *s, int flags )
{
for ( ; *s; s++ ) {
switch ( *s ) {
@@ -660,14 +660,27 @@ filter_strcpy_special( char *d, char *s )
case '^':
case '$':
*d++ = '\\';
- /* FALL */
+ break;
+ case '(':
+ case ')':
+ if (flags & FILTER_STRCPY_ESCAPE_PARENS) {
+ *d++ = '\\';
+ }
+ break;
default:
- *d++ = *s;
+ break;
}
+ *d++ = *s;
}
*d = '\0';
}
+void
+filter_strcpy_special( char *d, char *s )
+{
+ return filter_strcpy_special_ext(d, s, 0);
+}
+
int test_substring_filter(
Slapi_PBlock *pb,
Slapi_Entry *e,
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 5608670..d428ff9 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -574,6 +574,8 @@ void set_hash_filters(int i);
* filterentry.c
*/
void filter_strcpy_special( char *d, char *s );
+#define FILTER_STRCPY_ESCAPE_PARENS 0x01
+void filter_strcpy_special_ext( char *d, char *s, int flags );
/*