Bracketed-paste or why does my mutt-in-screen-IMAP-login not work anymore?

After I upgraded my IRC-host to the next Debian release, I rebooted the box, restarted the IRC and mail client to get things back up again, and wanted to log into my mailbox again. I pasted the password from the password store into mutt (running inside screen) as I had always done and got login failed. Wat?

The IMAP login still worked fine via Thunderbird or mobile app from other devices, and dovecot wasn’t logging anything related to the failed login attempts from mutt. Wat?!

When I start mutt directly on that very box, so outside screen, login works just fine, too. WAT?

So, enable some verbose auth logging in dovecot, including incorrect passwords in plain text, to see what’s going on here:

# From /etc/dovecot/dovecot.conf

# Verbose logging for authentication things
auth_verbose = yes

# Log passwords from invalid logings in plaintext, use carefully!
auth_verbose_passwords = plain

With that in place, I could see, that the password pasted into mutt‘s password prompt, when running inside screen, resulted in the password being prepended by 200~ and having a trailing 201~, WAT?!

Noting my findings in the DENOG IRC channel, someone pointed me to Bracketed-paste, which explained the control characters I was seeing. Without that pointer in the right direction, I would have search way longer – I love the DENOG and Open Source communities 💜.

  • ESC [ 200 ~ to signify the beginning of pasted text and
  • ESC [ 201 ~ to signify the end.
Description of bracketed-paste (Wikipedia)

That lead to the discovery that you can disable this behavior in multiple ways, including adding the following line into ~/.inputrc:

set enable-bracketed-paste 0

And hence, I can paste happily ever after.

Leave a Reply