Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading (mutt) aliases from a file can not handle non-ascii characters #515

Open
romanofski opened this issue Dec 31, 2024 · 1 comment · May be fixed by purebred-mua/purebred-email#88 or #517
Open

Comments

@romanofski
Copy link
Member

Describe the bug
Adding non ASCII characters to the Name fails parsing currently.

The current code uses the wrong charset lookup, that is easily fixed (see fix/muttaliasparsing), but configuring it with the icu charsets from Purebred.Plugin.ICU.icuCharsets has no bearing on the parsed addresses with non-ASCII characters.

To Reproduce
Steps to reproduce the behavior:

  1. Configure an alias file. E.g. I've put mine under ${HOME}/.config/purebred/alias
  2. Add contents (see below)
  3. Configure the config file to parse and use the aliases
  4. Compose a new mail
  5. For the To: use the configured nick and press <TAB>

Example alias:

alias foo Foo Bah <[email protected]>
alias bar Füh Bäh <[email protected]>

Example purebred config:

main = do
  -- [..]
  addressbook <- initMuttAliasFileAddressBook Purebred.Plugin.ICU.icuCharsets "<path to alias>"
    >>= either (die . show) pure
  --
    purebred
    [ usePlugin . tweakConfig $
          over -- [...]
          . set confAddressBook [addressBook]
          . Purebred.Plugin.ICU.enable
    -- [..]
    ]

Expected behavior
The email is populated with the configured name in the alias file

Additional context
I checked by trying out the parser in a repl, but no luck:

λ: import qualified Data.ByteString as B
λ: import Purebred.Plugin.ICU (icuCharsets)
λ: import Data.MIME (address)
λ: import Data.Attoparsec.ByteString (parseOnly)
λ: parseOnly (address icuCharsets) "Foo Bar <[email protected]>"
Right (Single (Mailbox (Just "Foo Bar") (AddrSpec "foo" (DomainDotAtom ("example" :| ["test"])))))
λ: parseOnly (address icuCharsets) "F\195\188h B\195\164h <[email protected]>"
Left "@: Failed reading: satisfy"

There must be something fundamental I'm missing here, since we're already parsing addresses successfully in the application without any problems.

What am I missing?

@romanofski
Copy link
Member Author

Ah dang.. I know what's going on. Above example in a repl:

λ: let b = Single $ Mailbox (Just "Füh Bäh") (AddrSpec "f" (DomainDotAtom $ pure "example.test"))
λ: b
Single (Mailbox (Just "F\252h B\228h") (AddrSpec "f" (DomainDotAtom ("example.test" :| []))))

looks rendered:

λ: renderAddress b
"=?utf-8?B?RsO8aCBCw6Ro?= <[email protected]>"

Which means if I currently want to use non-ascii characters in the alias file I obviously need to represent it that way or write another address parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant