all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#12724: ldap.el Problem and Solution
@ 2012-10-24 18:33 Noah Lavine
  2012-10-24 20:39 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Noah Lavine @ 2012-10-24 18:33 UTC (permalink / raw)
  To: 12724

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





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

* bug#12724: ldap.el Problem and Solution
  2012-10-24 18:33 bug#12724: ldap.el Problem and Solution Noah Lavine
@ 2012-10-24 20:39 ` Stefan Monnier
  2012-10-24 21:42   ` Noah Lavine
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2012-10-24 20:39 UTC (permalink / raw)
  To: Noah Lavine; +Cc: 12724

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

Can you confirm the patch below works?


        Stefan


=== modified file 'lisp/net/ldap.el'
--- lisp/net/ldap.el	2012-07-11 23:13:41 +0000
+++ lisp/net/ldap.el	2012-10-24 20:39:11 +0000
@@ -604,6 +604,7 @@
 	;; Skip error message when retrieving attribute list
 	(if (looking-at "Size limit exceeded")
 	    (forward-line 1))
+        (if (looking-at "version:") (forward-line 1)) ;bug#12724.
 	(while (progn
 		 (skip-chars-forward " \t\n")
 		 (not (eobp)))






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

* bug#12724: ldap.el Problem and Solution
  2012-10-24 20:39 ` Stefan Monnier
@ 2012-10-24 21:42   ` Noah Lavine
  2012-10-25 12:41     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Noah Lavine @ 2012-10-24 21:42 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 12724

Yes, that works.

Thanks a lot for such a quick response,
Noah

On Wed, Oct 24, 2012 at 4:39 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> (if (looking-at "version:")
>>     (forward-line 1))
>
> Can you confirm the patch below works?
>
>
>         Stefan
>
>
> === modified file 'lisp/net/ldap.el'
> --- lisp/net/ldap.el    2012-07-11 23:13:41 +0000
> +++ lisp/net/ldap.el    2012-10-24 20:39:11 +0000
> @@ -604,6 +604,7 @@
>         ;; Skip error message when retrieving attribute list
>         (if (looking-at "Size limit exceeded")
>             (forward-line 1))
> +        (if (looking-at "version:") (forward-line 1)) ;bug#12724.
>         (while (progn
>                  (skip-chars-forward " \t\n")
>                  (not (eobp)))
>





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

* bug#12724: ldap.el Problem and Solution
  2012-10-24 21:42   ` Noah Lavine
@ 2012-10-25 12:41     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-10-25 12:41 UTC (permalink / raw)
  To: Noah Lavine; +Cc: 12724-done

> Yes, that works.

Thank you, installed,


        Stefan





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

end of thread, other threads:[~2012-10-25 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24 18:33 bug#12724: ldap.el Problem and Solution Noah Lavine
2012-10-24 20:39 ` Stefan Monnier
2012-10-24 21:42   ` Noah Lavine
2012-10-25 12:41     ` Stefan Monnier

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.