go-message icon indicating copy to clipboard operation
go-message copied to clipboard

Support fallback/ignore encoding

Open fcuenca4 opened this issue 9 months ago • 0 comments

Hey there! 👋

I'm using go-message for an email archiving application and ran into a challenge with emails that have invalid encoding.

The problem happens in the encodingReader function (https://github.com/emersion/go-message/blob/master/encoding.go) when it encounters malformed content. For example, this email snippet:

Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML>
===
<html>
<body>
    <p>Hello, World!</p>
    <p>This has some =ZZ invalid quoted-printable stuff.</p>
    <p>Another example: =</p>
    <p>This text after the invalid parts never gets processed.</p>
</body>
</html>

The reader fails at the first invalid sequence, and we can't get any of the content.

For archiving purposes, I'd love an option to just get whatever content is available, even if some parts can't be decoded perfectly. I'm prioritizing content preservation over perfect rendering.

Maybe an option to skip encoding validation via Options?

fcuenca4 avatar Apr 29 '25 01:04 fcuenca4