git://git.exim.org
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
076b11e
)
Return multi-values attributes from an LDAP lookup in parsable form (bug 660).
author
Jeremy Harris
<jgh146exb@wizmail.org>
Mon, 23 Apr 2012 20:46:03 +0000
(21:46 +0100)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Tue, 1 May 2012 19:58:02 +0000
(20:58 +0100)
src/src/lookups/ldap.c
patch
|
blob
|
history
diff --git
a/src/src/lookups/ldap.c
b/src/src/lookups/ldap.c
index 52972fc0b2563928f1ecc4effe631e7199527b40..698928a6a852e9a16aa8aa0e6817d34419956dc7 100644
(file)
--- 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)
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
/* 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)
{
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);
{
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] == '\\')
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 */
/* Move on to the next value */