Subject: Re: bug#16946: 24.3; Rmail behaviour with a username containing "@"

From: Robert Thorpe <[email-masked]>
Date: Sun, 06 Dec 2020 23:50:32 +0000

Lars Ingebrigtsen <[email-masked]> writes:

> Robert Thorpe <[email-masked]> writes:
>
>> I think it's caused by movemail from GNU Mailutils though.  Mailutils
>> can't deal with two "@" symbols (one in the username and another for the
>> server).  I can replicate this by using movemail on the command line
>> without any Emacs involvement.  I think this is a bug in mailutils.
>> Would you agree?  If so I'll report it.
>
> I'm not quite sure.  As you point out:

I think that the GNU Mailutils manual should at least mention that it's
necessary.  Ideally though, there should be another options format which
splits up the information in a more sensible way.  One where the server,
username, port and password are all passed in separate options rather
than one big one.

I will send a message to [email-masked].

>> I'm not sure that it would be possible for the Mailutils maintainers to
>> fix it without changing the options format for the command.  On the
>> other hand I think the options format really should be changed.
>>
>> The kludge to fix this is to use "%40" in the email address instead of
>> "@".  That's what I've been using.
>
> So perhaps we should just fix Emacs to allow %40, and document that.
> You said:
>
>> To solve this for myself I've edited the function
>> rmail-insert-inbox-text just after this bit:
>>       ;; At this point, TOFILE contains the name to read:
>>       ;; Either the alternate name (if we renamed)
>>       ;; or the actual inbox (if not renaming).
>>
>> I've put in some code to substitute %40 for @ in tofile.  That fixes the
>> problem for me, but it's not a real fix.
>
> Could you submit a patch for that, so that we could see what that'd look
> like?

I forgot to tell you about that part of it.  I don't need my work-around
anymore.  I think it's been fixed in mailutils.  I don't see any fix in
rmail-insert-inbox-text.

The problem was the treatment of the %40.  It appears in the filename
"tofile" that's passed in Rmail.  In the past, movemail decoded it to @
and created a file with @ in the name.  That confused Rmail which didn't
do that with it's tofile.  So, I added (setq tofile (url-unhex-string
tofile)) just before Rmail opens the file.

Now though, movemail keeps the URL encoding in the filename, it keeps
the %40 and doesn't change it to @.  That solved that problem.

But, you still have to put in %40 when setting the username, and the
Rmail manual doesn't mention that.  Perhaps it should, I can write a
patch for that if you want.

BR,
Robert Thorpe