Subject: Re: bug#12511: 24.1; parse-netrc does not properly handle newlines

From: Ted Zlatanov <[email-masked]>
Date: Sat, 15 Jun 2013 04:18:57 -0400

On Wed, 26 Sep 2012 07:46:53 -0700 Erik Hetzner <[email-masked]> wrote: 

EH> At Tue, 25 Sep 2012 18:12:27 -0400,
EH> Glenn Morris wrote:
>> 
>> Just to comment that there is also ange-ftp-parse-netrc, which looks
>> like it might handle newlines. I don't know why Emacs needs this and
>> also netrc-parse (and also tramp-parse-netrc).

Sorry for the late reply.

Basically, the answer is "cruft."

`ange-ftp-parse-netrc' is a very different beast from the auth-source
netrc parser.  It mixes file handling, security checks, and other
functionality with the actual parsing.  It doesn't handle queries on the
parsed contents, limiting the number of matches, or enclosing the
password token in a closure so it's not visible when printed (this is an
auth-source feature: all passwords it returns are thus enclosed).

The original auth-source netrc parser came from Gnus' netrc.el parser
but also got the features above and more.  Gnus used to be a standalone
package that had to work with Emacs and XEmacs so I assume it needed a
standalone reliable netrc parser...  Perhaps `tramp-parse-netrc' was
motivated similarly.

I didn't remove netrc.el because other packages may use it and may even
depend on its particular parsing behavior.  But Gnus doesn't, AFAIK.

EH> And, in fact, it seems my problem with auth-source-netrc-parse, which
EH> url.el uses.

EH> So: netrc-parse, tramp-parse-netrc, and auth-source-netrc-parse all do
EH> not handle linefeeds in ~/.netrc files.

EH> ange-ftp-parse-netrc, on the other hand, does.

EH> For what it’s worth, I didn’t create a ~/.netrc file myself with
EH> linefeeds; it was created for me by other software.

I've comitted a new version of the auth-source netrc parser to the Gnus
repo (it will be synchronized to Emacs later) that can handle
single-quoted strings and multiline entries.  Basically what "man netrc"
says it should, except for "macdef" which I have never seen in the wild.

I've tested the code but please let me know if it works for you.

Ted