emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 d2246b26275 1/2: Fix parsing of dn line if WITHDN is non-nil


From: Eli Zaretskii
Subject: emacs-29 d2246b26275 1/2: Fix parsing of dn line if WITHDN is non-nil
Date: Sat, 17 Jun 2023 04:00:10 -0400 (EDT)

branch: emacs-29
commit d2246b2627531523dc0decd6bee863820dd2f5bf
Author: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix parsing of dn line if WITHDN is non-nil
    
    Function `ldap-search' errors out with `wrong-type-argument listp'
    when called with WITHDN non-nil.
    * lisp/net/ldap.el (ldap-search-internal): Parse the dn line
    correctly so that `ldap-search' can grok it.  (Bug#64089)
---
 lisp/net/ldap.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index 78405414a28..4275b45e6f5 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -703,7 +703,17 @@ an alist of attribute/value pairs."
        (while (progn
                 (skip-chars-forward " \t\n")
                 (not (eobp)))
-          (setq dn (buffer-substring (point) (line-end-position)))
+          ;; Ignore first (dn) line if WITHDN equals nil.  If WITHDN
+          ;; is non-nil, check syntax of the line and split it into a
+          ;; pair as expected by `ldap-decode-attribute' (Bug#64089).
+          ;; If the syntax is wrong, better throw an error here, since
+          ;; otherwise `ldap-decode-attribute' would throw a much less
+          ;; comprehensible error later.
+          (cond ((not withdn))
+                ((looking-at "^dn[=:\t ]+\\(.*\\)$")
+                 (setq dn (list "dn" (match-string 1))))
+                (t (error "Incorrect dn line \"%s\" in ldapsearch result"
+                          (buffer-substring (point) (line-end-position)))))
          (forward-line 1)
           (while (looking-at "^\\([A-Za-z][-A-Za-z0-9]*\
 \\|[0-9]+\\(?:\\.[0-9]+\\)*\\)\\(;[-A-Za-z0-9]+\\)*[=:\t ]+\



reply via email to

[Prev in Thread] Current Thread [Next in Thread]