diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-03-09 14:21:36 +0100 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-03-11 19:15:49 +0000 |
commit | d743fd0d0a0387d4435dd8d35f57023492a6d54b (patch) | |
tree | d54ec7866b7e34a53191f347902d56c346c4d524 /tests/auto/corelib/io | |
parent | cfa4879b41a786f5493ff73c59d55c65334856d8 (diff) |
qDecodeDataUrl(): treat ";base64" marker as case-insensitive
RFC2397 doesn't explicitly mention it, but references RFC2045, which,
in Section 2, states:
> All media type values, subtype values, and parameter names as
> defined are case-insensitive.
and goes on, in 6.1:
> mechanism := "7bit" / "8bit" / "binary" /
> "quoted-printable" / "base64" /
> ietf-token / x-token
>
> These values are not case sensitive
So regardless of whether "base64" is a parameter name, or a mechanism,
we need to treat it case-insensitively.
Use QLatin1String::endsWith() instead of QByteArray::endsWith(),
because the former takes Qt::CaseInsensitive while the latter would
need a toLower().
Add a test.
As a drive-by, use the same trick for the existing case-insensitive
comparison with "charset".
As a further drive-by, fix inappropriate uses of QLatin1String (=
where they don't prevent allocations).
[ChangeLog][QtCore][QUrl] Now recognizes the ";base64" marker in
"data:" URLs case-insensitively.
Pick-to: 6.3 6.2
Change-Id: Ife6ba771553aaad3b7c119c1fa631f41ffa8f590
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r-- | tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp index 2a743194b7..dc1278b150 100644 --- a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp +++ b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp @@ -57,6 +57,8 @@ void tst_QDataUrl::decode_data() "text/plain;charset=US-ASCII"_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, + "texT/PlaiN;charSet=iSo-8859-1"_L1, QByteArrayLiteral("Hello")); } void tst_QDataUrl::decode() |