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.9 6.8 6.5 5.15
Change-Id: Ifd9736b7808226c8462e3d39798abda7b245c6d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2025-04-18 17:53:23 +02:00
parent 88f2d7aacb
commit f8987b2d0a

View File

@ -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,