aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Fitzsimmons2015-03-05 21:53:37 -0500
committerThomas Fitzsimmons2015-03-05 21:54:27 -0500
commitbfebebbc72c6a6ea375c6e8ed7f8641b25439770 (patch)
tree1c5ccc4f24091d1aed85a15d4411e002c197d367
parentb08f8bb06a012b46cb932762b002a48c6efe5396 (diff)
downloademacs-bfebebbc72c6a6ea375c6e8ed7f8641b25439770.tar.gz
emacs-bfebebbc72c6a6ea375c6e8ed7f8641b25439770.zip
Fix EUDC LDAP duplicate mail handling
Fixes: debbugs:17720 * net/eudcb-ldap.el (eudc-ldap-cleanup-record-simple): Mark as obsolete. (eudc-ldap-cleanup-record-filtering-addresses): Add docstring. Don't clean up postal addresses if ldap-ignore-attribute-codings is set. Combine mail addresses into one field. (Bug#17720) (eudc-ldap-simple-query-internal): Call eudc-ldap-cleanup-record-filtering-addresses instead of eudc-ldap-cleanup-record-simple. (eudc-ldap-get-field-list): Likewise.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/net/eudcb-ldap.el53
2 files changed, 42 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0f905e65711..edea71cda52 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12015-03-06 Thomas Fitzsimmons <fitzsim@fitzsim.org>
2
3 * net/eudcb-ldap.el (eudc-ldap-cleanup-record-simple): Mark as
4 obsolete.
5 (eudc-ldap-cleanup-record-filtering-addresses): Add docstring.
6 Don't clean up postal addresses if ldap-ignore-attribute-codings
7 is set. Combine mail addresses into one field. (Bug#17720)
8 (eudc-ldap-simple-query-internal): Call
9 eudc-ldap-cleanup-record-filtering-addresses instead of
10 eudc-ldap-cleanup-record-simple.
11 (eudc-ldap-get-field-list): Likewise.
12
12015-03-05 Ivan Shmakov <ivan@siamics.net> 132015-03-05 Ivan Shmakov <ivan@siamics.net>
2 14
3 * net/eww.el (eww-html-p): New function (bug#20009). 15 * net/eww.el (eww-html-p): New function (bug#20009).
diff --git a/lisp/net/eudcb-ldap.el b/lisp/net/eudcb-ldap.el
index 1d426a7b7b0..d22dff615ee 100644
--- a/lisp/net/eudcb-ldap.el
+++ b/lisp/net/eudcb-ldap.el
@@ -74,13 +74,10 @@
74 74
75(defun eudc-ldap-cleanup-record-simple (record) 75(defun eudc-ldap-cleanup-record-simple (record)
76 "Do some cleanup in a RECORD to make it suitable for EUDC." 76 "Do some cleanup in a RECORD to make it suitable for EUDC."
77 (declare (obsolete eudc-ldap-cleanup-record-filtering-addresses "25.1"))
77 (mapcar 78 (mapcar
78 (function 79 (function
79 (lambda (field) 80 (lambda (field)
80 ;; Some servers return case-sensitive names (e.g. givenName
81 ;; instead of givenname); downcase the field's name so that it
82 ;; can be matched against
83 ;; eudc-ldap-attributes-translation-alist.
84 (cons (intern (downcase (car field))) 81 (cons (intern (downcase (car field)))
85 (if (cdr (cdr field)) 82 (if (cdr (cdr field))
86 (cdr field) 83 (cdr field)
@@ -90,22 +87,36 @@
90(defun eudc-filter-$ (string) 87(defun eudc-filter-$ (string)
91 (mapconcat 'identity (split-string string "\\$") "\n")) 88 (mapconcat 'identity (split-string string "\\$") "\n"))
92 89
93;; Cleanup a LDAP record to make it suitable for EUDC:
94;; Make the record a cons-cell instead of a list if it is single-valued
95;; Filter the $ character in addresses into \n if not done by the LDAP lib
96(defun eudc-ldap-cleanup-record-filtering-addresses (record) 90(defun eudc-ldap-cleanup-record-filtering-addresses (record)
97 (mapcar 91 "Clean up RECORD to make it suitable for EUDC.
98 (function 92Make the record a cons-cell instead of a list if it is
99 (lambda (field) 93single-valued. Change the `$' character in postal addresses to a
94newline. Combine separate mail fields into one mail field with
95multiple addresses."
96 (let ((clean-up-addresses (or (not (boundp 'ldap-ignore-attribute-codings))
97 (not ldap-ignore-attribute-codings)))
98 result mail-addresses)
99 (dolist (field record)
100 ;; Some servers return case-sensitive names (e.g. givenName
101 ;; instead of givenname); downcase the field's name so that it
102 ;; can be matched against
103 ;; eudc-ldap-attributes-translation-alist.
100 (let ((name (intern (downcase (car field)))) 104 (let ((name (intern (downcase (car field))))
101 (value (cdr field))) 105 (value (cdr field)))
102 (if (memq name '(postaladdress registeredaddress)) 106 (when (and clean-up-addresses
103 (setq value (mapcar 'eudc-filter-$ value))) 107 (memq name '(postaladdress registeredaddress)))
104 (cons name 108 (setq value (mapcar 'eudc-filter-$ value)))
105 (if (cdr value) 109 (if (eq name 'mail)
106 value 110 (setq mail-addresses (append mail-addresses value))
107 (car value)))))) 111 (push (cons name (if (cdr value)
108 record)) 112 value
113 (car value)))
114 result))))
115 (push (cons 'mail (if (cdr mail-addresses)
116 mail-addresses
117 (car mail-addresses)))
118 result)
119 (nreverse result)))
109 120
110(defun eudc-ldap-simple-query-internal (query &optional return-attrs) 121(defun eudc-ldap-simple-query-internal (query &optional return-attrs)
111 "Query the LDAP server with QUERY. 122 "Query the LDAP server with QUERY.
@@ -118,11 +129,7 @@ RETURN-ATTRS is a list of attributes to return, defaulting to
118 (if (listp return-attrs) 129 (if (listp return-attrs)
119 (mapcar 'symbol-name return-attrs)))) 130 (mapcar 'symbol-name return-attrs))))
120 final-result) 131 final-result)
121 (if (or (not (boundp 'ldap-ignore-attribute-codings)) 132 (setq result (mapcar 'eudc-ldap-cleanup-record-filtering-addresses result))
122 ldap-ignore-attribute-codings)
123 (setq result
124 (mapcar 'eudc-ldap-cleanup-record-filtering-addresses result))
125 (setq result (mapcar 'eudc-ldap-cleanup-record-simple result)))
126 133
127 (if (and eudc-strict-return-matches 134 (if (and eudc-strict-return-matches
128 return-attrs 135 return-attrs
@@ -148,7 +155,7 @@ attribute names are returned. Default to `person'"
148 (let ((ldap-host-parameters-alist 155 (let ((ldap-host-parameters-alist
149 (list (cons eudc-server 156 (list (cons eudc-server
150 '(scope subtree sizelimit 1))))) 157 '(scope subtree sizelimit 1)))))
151 (mapcar 'eudc-ldap-cleanup-record-simple 158 (mapcar 'eudc-ldap-cleanup-record-filtering-addresses
152 (ldap-search 159 (ldap-search
153 (eudc-ldap-format-query-as-rfc1558 160 (eudc-ldap-format-query-as-rfc1558
154 (list (cons "objectclass" 161 (list (cons "objectclass"