emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.02k stars 288 forks source link

Find filename in upper or lower case and decode it #584

Closed rakoo closed 5 months ago

rakoo commented 5 months ago

This PR fixes two issues:

emersion commented 5 months ago

Thanks for the patch!

sometimes in the bodystructure the key is in upper case; the lib couldn't find it

Maybe we should lower-case keys when populating the map?

sometimes the filename is written as RFC2047-encoded words

Ideally we'd be using Client.options.decodeText so that users can add support for additional charsets (by default mime.WordDecoder only supports UTF-8).

rakoo commented 5 months ago

Simon Ser @.***> wrote:

Maybe we should lower-case keys when populating the map?

Good idea, this'll make it available for other fields as well

sometimes the filename is written as RFC2047-encoded words

Ideally we'd be using Client.options.decodeText so that users can add support for additional charsets (by default mime.WordDecoder only supports UTF-8).

Ah indeed ! I'll use that instead

-- Matthieu Rakotojaona

rakoo commented 5 months ago

I didn't know what would be possible, and I was kinda afraid passing the options directly would mess up the clean separation of functionalities. But if that's ok for you, I'll do it :)

-- Matthieu Rakotojaona

emersion commented 5 months ago

Yeah, I'd prefer to pass the options. It's an internal function anyways.

rakoo commented 5 months ago

Updated

emersion commented 5 months ago

Note that it's not strictly correct to decode all parameters, as encoded words are only allowed for some parameters and should be left as-is for others… But we do the same in go-message for simplicity's sake and haven't received a bug report about this yet.

rakoo commented 5 months ago

Thanks for your patience !

Are there really cases where some values are encoded but we don't want them decoded ? I can't imagine any, but let's see when that happens