all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jens Schmidt via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 64089@debbugs.gnu.org
Subject: bug#64089: Acknowledgement (30.0.50; `ldap-search' errors out with `wrong-type-argument listp' when called WITHDN == t)
Date: Fri, 16 Jun 2023 00:11:15 +0200	[thread overview]
Message-ID: <a71487a0-3803-3fcf-5f9f-329cd4a13009@vodafonemail.de> (raw)
In-Reply-To: <handler.64089.B.168686453832024.ack@debbugs.gnu.org>

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

With the following patch things work as expected:

(ldap-search "(uid=<uid>)"
               "ldap://<host>"
               '("mail")
               nil
               t)
=> ((("dn" "cn=<NAME>,L=<REGION>,DC=<DOMAIN>,DC=COM") ("mail" 
"<name>@<domain>.com")))

I tried to make the patch as conservative as possible and intentionally 
do not check syntax of the dn line if its parsing is not required.


[-- Attachment #2: 0001-Fix-parsing-of-dn-line-if-WITHDN-is-non-nil.patch --]
[-- Type: text/x-patch, Size: 1687 bytes --]

From a646f5aa23f051f19910286c1bf9f4580a858f0f Mon Sep 17 00:00:00 2001
From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Date: Fri, 16 Jun 2023 00:04:04 +0200
Subject: [PATCH] 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 @@ ldap-search-internal
 	(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 ]+\
-- 
2.30.2


  parent reply	other threads:[~2023-06-15 22:11 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 21:28 bug#64089: 30.0.50; `ldap-search' errors out with `wrong-type-argument listp' when called WITHDN == t Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.64089.B.168686453832024.ack@debbugs.gnu.org>
2023-06-15 22:11   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-06-16  6:01     ` bug#64089: 30.0.50; `ldap-search' errors out with `wrong-type-argument listp' when called WITHDN == t) Eli Zaretskii
2023-06-16 15:12       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-16 18:37         ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-17  8:40           ` Eli Zaretskii
2023-06-16 22:13     ` bug#64089: 30.0.50; `ldap-search' errors out with `wrong-type-argument listp' when called WITHDN == t Filipp Gunbin
2023-06-17  6:03       ` Eli Zaretskii
2023-06-17  8:41         ` Eli Zaretskii
2023-06-17  9:07           ` Eli Zaretskii
2023-06-17 23:14             ` Filipp Gunbin
2023-06-18  5:22               ` Eli Zaretskii
2023-06-19 14:27                 ` Filipp Gunbin
2023-06-19 17:24                   ` Eli Zaretskii
2023-06-19 18:38                     ` Filipp Gunbin
2023-06-19 19:09                       ` Eli Zaretskii
2023-06-19 19:27                         ` Filipp Gunbin
2023-06-19 20:15                           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-19 20:35                             ` Filipp Gunbin
2023-06-19 21:37                               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20 14:23                                 ` Filipp Gunbin
2023-06-20 20:42                                   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20 11:01                           ` Eli Zaretskii
2023-06-20 17:52                             ` Filipp Gunbin
2023-06-18  7:43               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-18  8:51                 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-18  8:56                   ` Eli Zaretskii
2023-06-18 11:04                     ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-18 22:14                 ` bug#64160: " Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-19 14:11                   ` Filipp Gunbin
2023-06-19 15:13                     ` bug#64160: master; Implement various enhancements in ldap.el and EUDC Filipp Gunbin
2023-06-19 21:16                       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20 14:11                         ` Filipp Gunbin
2023-06-20 22:23                           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a71487a0-3803-3fcf-5f9f-329cd4a13009@vodafonemail.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=64089@debbugs.gnu.org \
    --cc=jschmidt4gnu@vodafonemail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.