all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noah Lavine <noah.b.lavine@gmail.com>
To: 12724@debbugs.gnu.org
Subject: bug#12724: ldap.el Problem and Solution
Date: Wed, 24 Oct 2012 14:33:06 -0400	[thread overview]
Message-ID: <jwvk3ufg1qq.fsf-monnier+emacs@gnu.org> (raw)

Hello,

I recently hit a problem in which ldap-search (in ldap.el) would
return a list of records where the first record would always be nil.
As far as I can tell, the rest of the list was correct; it just had an
extra nil in the beginning.

After some debugging, I think the issue is that my ldapsearch program
(from OpenLDAP) doesn't quite use the output format ldap.el expects.
The expected format is

dn: ..........
<attribute>: <value>
<attribute>: <value>
.... more attributes here ......

This is the ldif format, which seems to be standardized. But
tragically, my ldapsearch program prints a header, which makes the
results look like this:

version: 1

dn: .........
<attribute>: <value>
.... more attributes .....

This confuses the ldap.el parsing. I can tell this is the problem
because when I step through in the debugger, the "dn" variable is set
to "version: 1", instead of the obviously correct value. Then when it
attempts to parse its results it finds an empty record, and so pushes
'nil onto its results list, which is what causes the problem.

The solution is to insert this after line 579 of ldap.el:

(if (looking-at "version:")
    (forward-line 1))

I have tested this, and it seems to work for me.

The other option is to make the ldapsearch program not print its
version header, but looking at its man page, I don't see a way to do
that.

If this solution doesn't seem good, I am happy to try a different
approach, but it seems like the easiest solution to me. I have already
signed copyright papers, although for a change as small as this they
might not even be needed.

Thanks,
Noah Lavine





             reply	other threads:[~2012-10-24 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 18:33 Noah Lavine [this message]
2012-10-24 20:39 ` bug#12724: ldap.el Problem and Solution Stefan Monnier
2012-10-24 21:42   ` Noah Lavine
2012-10-25 12:41     ` Stefan Monnier

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=jwvk3ufg1qq.fsf-monnier+emacs@gnu.org \
    --to=noah.b.lavine@gmail.com \
    --cc=12724@debbugs.gnu.org \
    /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.