[exim-dev] [Bug 660] multi-valued attributes returned from a…

Top Page

Reply to this message
Author: Git Commit
Date:  
To: exim-dev
Old-Topics: [exim-dev] [Bug 660] New: multi-valued attributes returned from an ldap lookup parsing is hard
Subject: [exim-dev] [Bug 660] multi-valued attributes returned from an ldap lookup parsing is hard
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=660

Git Commit <git@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |git@???





--- Comment #3 from Git Commit <git@???> 2012-05-01 22:17:07 ---
Git commit:
http://git.exim.org/exim.git/commitdiff/7bba24ebe4e17b40cbcca88fdb3f247f7f9cd02c

commit 7bba24ebe4e17b40cbcca88fdb3f247f7f9cd02c
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Mon Apr 23 21:46:03 2012 +0100
Commit:     Jeremy Harris <jgh146exb@???>
CommitDate: Tue May 1 20:58:02 2012 +0100


    Return multi-values attributes from an LDAP lookup in parsable form (bug
660).
---
 src/src/lookups/ldap.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)


diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index 52972fc..698928a 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -725,10 +725,10 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr,
&result)) ==
             DEBUG(D_lookup) debug_printf("LDAP attr loop %s:%s\n", attr,
value);


             if (values != firstval)
-              data = string_cat(data, &size, &ptr, US", ", 2);
+              data = string_cat(data, &size, &ptr, US",", 1);


             /* For multiple attributes, the data is in quotes. We must escape
-            internal quotes, backslashes, newlines. */
+            internal quotes, backslashes, newlines, and must double commas. */


             if (attr_count != 1)
               {
@@ -737,6 +737,8 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr,
&result)) ==
                 {
                 if (value[j] == '\n')
                   data = string_cat(data, &size, &ptr, US"\\n", 2);
+                else if (value[j] == ',')
+                  data = string_cat(data, &size, &ptr, US",,", 2);
                 else
                   {
                   if (value[j] == '\"' || value[j] == '\\')
@@ -746,9 +748,20 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr,
&result)) ==
                 }
               }


-            /* For single attributes, copy the value verbatim */
+            /* For single attributes, just double commas */
+
+           else
+             {
+             int j;
+             for (j = 0; j < len; j++)
+               {
+               if (value[j] == ',')
+                 data = string_cat(data, &size, &ptr, US",,", 2);
+               else
+                 data = string_cat(data, &size, &ptr, value+j, 1);
+               }
+             }


-            else data = string_cat(data, &size, &ptr, value, len);


             /* Move on to the next value */




--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email