diff --git a/src/corelib/io/qdataurl.cpp b/src/corelib/io/qdataurl.cpp index c5ecca8fb82..2d2426e8ea5 100644 --- a/src/corelib/io/qdataurl.cpp +++ b/src/corelib/io/qdataurl.cpp @@ -20,8 +20,6 @@ Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray if (uri.scheme() != "data"_L1 || !uri.host().isEmpty()) return false; - mimeType = QStringLiteral("text/plain;charset=US-ASCII"); - // the following would have been the correct thing, but // reality often differs from the specification. People have // data: URIs with ? and # @@ -56,6 +54,8 @@ Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray if (!data.isEmpty()) mimeType = textPlain + QLatin1StringView(data.trimmed()); + else + mimeType = QStringLiteral("text/plain;charset=US-ASCII"); } return true; diff --git a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp index 7fbf4be56b9..39d860adaf7 100644 --- a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp +++ b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp @@ -31,8 +31,7 @@ void tst_QDataUrl::decode_data() row("malformed-host", "data://test.com", false); row("malformed-host2", "data://text/plain;charset=ISO-8859-1", false); row("malformed-host3", "data://test.com/,", false); - row("emptyData", "data:text/plain", true, - "text/plain;charset=US-ASCII"_L1); + row("emptyData", "data:text/plain", true); row("emptyData-default-mimetype", "data:,", true, "text/plain;charset=US-ASCII"_L1, ""); row("emptyData-only-charset", "data:charset=ISO-8859-1,", true,