Skip to content

Write large message HTML content out without changing the encoding

Writing a byte array to a QTextStream assumes the input is UTF-8, which is not always the case for us. So we end up potentially converting non- UTF-8 content to UTF-16 internally and then back to UTF-8 for the output.

That broke causing e.g. bug 416758, which was subsequently fixed by encoding the output in the codec of the original input again, via Util::htmlCodec(), hoping it would survive the roundtrip through QString.

With the port to QStringConverter and thus Util::htmlEncoding we lost that ability though, as the QStringConverter enums can only distinguish between different Unicode variants and Latin1 but don't cover the legacy codecs that are actually the problem here.

So, instead all of that, write out the input data directly as unmodified byte array, skipping the entire QTextStream and codec handling.

There's a bunch of things that can be cleaned up now, but I first want to confirm the analysis and reasoning here is sound.

Merge request reports

Loading