From 679dc18c43212cd9cf179670b3354e11f08865d1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 18 Apr 2025 17:53:23 +0200 Subject: [PATCH] qdataurl: extend the unittests Check: - data: urls with a host are treated as malformed - if the mime type is omitted, it's set to "text/plain;charset=US-ASCII" as per the RFC[1] - the mime type of urls with a `charset` attribute are normalized by adding "text/plain;" (Qt implementation detail) if it's missing [1] https://www.rfc-editor.org/rfc/rfc2397.html Pick-to: 6.8 6.5 5.15 Change-Id: Ifd9736b7808226c8462e3d39798abda7b245c6d8 Reviewed-by: Thiago Macieira (cherry picked from commit f8987b2d0a0835bdc2e6e4f2204e6e40db33da5f) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp index 943b168e056..e57443368aa 100644 --- a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp +++ b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp @@ -28,8 +28,15 @@ void tst_QDataUrl::decode_data() }; row("nonData", "http://test.com", false); + 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-default-mimetype", "data:,", true, + "text/plain;charset=US-ASCII"_L1, ""); + row("emptyData-only-charset", "data:charset=ISO-8859-1,", true, + "text/plain;charset=ISO-8859-1"_L1, ""); row("alreadyPercentageEncoded", "data:text/plain,%E2%88%9A", true, "text/plain"_L1, QByteArray::fromPercentEncoding("%E2%88%9A")); row("everythingIsCaseInsensitive", "Data:texT/PlaiN;charSet=iSo-8859-1;Base64,SGVsbG8=", true,