Blame SOURCES/0053-Ticket-48265-Complex-filter-in-a-search-request-doen.patch

a2f18f
From c03a9f7c121355aefadc92ed67bcb6f400196017 Mon Sep 17 00:00:00 2001
b161c9
From: Noriko Hosoi <nhosoi@redhat.com>
b161c9
Date: Wed, 2 Sep 2015 14:28:27 -0700
a2f18f
Subject: [PATCH 53/54] Ticket #48265 - Complex filter in a search request
b161c9
 doen't work as expected. (regression)
b161c9
b161c9
Description: commit c2658c14802783d0a8919783aa7123be9e749c18 to fix
b161c9
Ticket 47521 - Complex filter in a search request doen't work as expected.
b161c9
regressed this case:
b161c9
  "(&(&(|(l=A)(l=B)(l=C))(|(C=D)(c=E)))(|(uid=*test*)(cn=*test*))(o=X))"
b161c9
in which a simple filter follows a complex filter which choice is
b161c9
different from the outer choice.  I.e., '|' for (uid=...)(cn=...)
b161c9
is different from the first '&'.
b161c9
b161c9
The fix for 47521 solves this case:
b161c9
  "(&(&(uid=A)(cn=B))(&(givenname=C))(mail=D)(&(description=E)))"
b161c9
in this case, (mail=D) used to be dropped from the filter in the
b161c9
function index_subsys_flatten_filter.
b161c9
b161c9
The 47521 fix saved the simple filter "(mail=D)" in the 2nd example,
b161c9
but it forced to skip the complex filter with the different choice
b161c9
and converted the 1st example to:
b161c9
  "(&(&(|(l=A)(l=B)(l=C))(|(C=D)(c=E)))(o=X))"
b161c9
This patch saves such a complex filter, as well.
b161c9
b161c9
https://fedorahosted.org/389/ticket/48265
b161c9
b161c9
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
b161c9
b161c9
(cherry picked from commit 8c3d3e4648fbb5229e329e2154d46f1ae808ba02)
b161c9
(cherry picked from commit 3d9dbf2d441e551495a1f3169dc2020324c484b4)
b161c9
---
b161c9
 ldap/servers/slapd/index_subsystem.c | 5 +++++
b161c9
 1 file changed, 5 insertions(+)
b161c9
b161c9
diff --git a/ldap/servers/slapd/index_subsystem.c b/ldap/servers/slapd/index_subsystem.c
a2f18f
index fdaef6a..93bf9d5 100644
b161c9
--- a/ldap/servers/slapd/index_subsystem.c
b161c9
+++ b/ldap/servers/slapd/index_subsystem.c
a2f18f
@@ -412,6 +412,11 @@ static void index_subsys_flatten_filter(Slapi_Filter *flist)
b161c9
 				}
b161c9
 				else
b161c9
 				{
b161c9
+					/* don't loose a nested filter having a different choice */
b161c9
+					if (flast) {
b161c9
+						flast->f_next = f;
b161c9
+						flast = f;
b161c9
+					}
b161c9
 					fprev = f;
b161c9
 					f = f->f_next;
b161c9
 				}
b161c9
-- 
b161c9
1.9.3
b161c9