unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17720: 24.3; EUDC LDAP duplicate mail handling broken.
@ 2014-06-06 17:51 Raimund Berger
  2014-12-24  6:30 ` Thomas Fitzsimmons
  2015-03-06  8:05 ` Thomas Fitzsimmons
  0 siblings, 2 replies; 4+ messages in thread
From: Raimund Berger @ 2014-06-06 17:51 UTC (permalink / raw)
  To: 17720

Hi there,

EUDC - and this seems to be a long standing issue - doesn't properly
recognize and handle LDAP entries that have multiple "mail" records.

Example: when having an LDAP entry with cn "John Doe" and two mail
records "john@a.com" "john@b.com" the corresponding inline expansion
LDAP call returns

 ((cn . "John Doe") (mail . "john@a.com") (mail . "john@b.com"))

given the setting
 (eudc-protocol-set 'eudc-inline-expansion-format '("%s <%s>" cn email) 'ldap)

and eudc-duplicate-attribute-handling-method having its default value
((email . duplicate)).

The above list is then passed into eudc-filter-duplicate-attributes,
which unfortunately fails to properly handle or even just recognize
those duplicate "mail" records. This failure then results into inline
expansion just inserting the first mail entry instead of offering a
selection between all available mail records, like it properly happens
with the bbdb backend for example.

Unfortunately, I don't know enough of elisp to maybe fix the issue
myself (all the mapcars, cdrs, etc make me dizzy). But it would be great
if this issue could be dealt with.

I've seen several complaints about this matter on the net btw, one
dating back to 2005. So it seems to be an old one.

Thanks, R.


In GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2014-05-18 on gigli





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#17720: 24.3; EUDC LDAP duplicate mail handling broken.
  2014-06-06 17:51 bug#17720: 24.3; EUDC LDAP duplicate mail handling broken Raimund Berger
@ 2014-12-24  6:30 ` Thomas Fitzsimmons
  2015-03-06  3:26   ` Thomas Fitzsimmons
  2015-03-06  8:05 ` Thomas Fitzsimmons
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Fitzsimmons @ 2014-12-24  6:30 UTC (permalink / raw)
  To: Raimund Berger; +Cc: 17720

[-- Attachment #1: Type: text/plain, Size: 53 bytes --]

Hi Raimund,

Can you try this patch?

Thanks,
Thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs-eudc-ldap-combine-mail-fields.patch --]
[-- Type: text/x-patch, Size: 2174 bytes --]

diff --git a/lisp/net/eudcb-ldap.el b/lisp/net/eudcb-ldap.el
index 6c806d7..1c5bab2 100644
--- a/lisp/net/eudcb-ldap.el
+++ b/lisp/net/eudcb-ldap.el
@@ -74,16 +74,28 @@
 		   '(eudc-ldap-check-base)
 		   'ldap)
 
+(defun eudc-ldap-combine-mail-fields (record)
+  "Combine mail fields in RECORD."
+  (let (result)
+    (dolist (element record)
+      (let ((result-element (assoc (car element) result)))
+	(if (and result-element (eq (car element) 'mail))
+	    (setf (cdr result-element)
+		  (list (cdr result-element) (cdr element)))
+	  (setq result (append result (list element))))))
+    result))
+
 (defun eudc-ldap-cleanup-record-simple (record)
   "Do some cleanup in a RECORD to make it suitable for EUDC."
-  (mapcar
-   (function
-    (lambda (field)
-      (cons (intern (car field))
-	    (if (cdr (cdr field))
-		(cdr field)
-	      (car (cdr field))))))
-   record))
+  (eudc-ldap-combine-mail-fields
+   (mapcar
+    (function
+     (lambda (field)
+       (cons (intern (car field))
+	     (if (cdr (cdr field))
+		 (cdr field)
+	       (car (cdr field))))))
+    record)))
 
 (defun eudc-filter-$ (string)
   (mapconcat 'identity (split-string string "\\$") "\n"))
@@ -92,18 +104,19 @@
 ;;   Make the record a cons-cell instead of a list if it is single-valued
 ;;   Filter the $ character in addresses into \n if not done by the LDAP lib
 (defun eudc-ldap-cleanup-record-filtering-addresses (record)
-  (mapcar
-   (function
-    (lambda (field)
-      (let ((name (intern (car field)))
-	    (value (cdr field)))
-	(if (memq name '(postaladdress registeredaddress))
-	    (setq value (mapcar 'eudc-filter-$ value)))
-	(cons name
-	      (if (cdr value)
-		  value
-		(car value))))))
-   record))
+  (eudc-ldap-combine-mail-fields
+   (mapcar
+    (function
+     (lambda (field)
+       (let ((name (intern (car field)))
+	     (value (cdr field)))
+	 (if (memq name '(postaladdress registeredaddress))
+	     (setq value (mapcar 'eudc-filter-$ value)))
+	 (cons name
+	       (if (cdr value)
+		   value
+		 (car value))))))
+    record)))
 
 (defun eudc-ldap-simple-query-internal (query &optional return-attrs)
   "Query the LDAP server with QUERY.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#17720: 24.3; EUDC LDAP duplicate mail handling broken.
  2014-12-24  6:30 ` Thomas Fitzsimmons
@ 2015-03-06  3:26   ` Thomas Fitzsimmons
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Fitzsimmons @ 2015-03-06  3:26 UTC (permalink / raw)
  To: Raimund Berger; +Cc: 17720

fixed 17720 25.1
thanks

I pushed a fix for this.

Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#17720: 24.3; EUDC LDAP duplicate mail handling broken.
  2014-06-06 17:51 bug#17720: 24.3; EUDC LDAP duplicate mail handling broken Raimund Berger
  2014-12-24  6:30 ` Thomas Fitzsimmons
@ 2015-03-06  8:05 ` Thomas Fitzsimmons
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Fitzsimmons @ 2015-03-06  8:05 UTC (permalink / raw)
  To: 17720-done

This is fixed by the following commit:

commit bfebebbc72c6a6ea375c6e8ed7f8641b25439770
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Date:   Thu Mar 5 21:53:37 2015 -0500

    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.

Closing.

Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-06  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-06 17:51 bug#17720: 24.3; EUDC LDAP duplicate mail handling broken Raimund Berger
2014-12-24  6:30 ` Thomas Fitzsimmons
2015-03-06  3:26   ` Thomas Fitzsimmons
2015-03-06  8:05 ` Thomas Fitzsimmons

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).