Commit aaad7198 authored by Volker Krause's avatar Volker Krause
Browse files

Explicitly truncate strings at the first null byte

Qt5 did that implicitly, Qt6 doesn't.
parent 5567f6f0
......@@ -59,12 +59,16 @@ QJSValue JsApi::ByteArray::fromBase64(const QString &b64) const
QString JsApi::ByteArray::decodeUtf8(const QByteArray &input) const
{
return QString::fromUtf8(input);
// explicitly truncate at the first null byte, Qt6 doesn't do that automatically anymore
const auto idx = input.indexOf('\0');
return QString::fromUtf8(input.constData(), idx >= 0 ? idx : input.size());
}
QString JsApi::ByteArray::decodeLatin1(const QByteArray &input) const
{
return QString::fromLatin1(input);
// explicitly truncate at the first null byte, Qt6 doesn't do that automatically anymore
const auto idx = input.indexOf('\0');
return QString::fromLatin1(input.constData(), idx >= 0 ? idx : input.size());
}
QVariant JsApi::ByteArray::toBitArray(const QByteArray &input) const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment