QCborValue: check parsing of invalid URL
QUrl will reject invalid URLs for us, so we don't get normalization. The original junk should be retrievable, of course. Change-Id: Ibdc95e9af7bd456a94ecfffd160610f5b2c8e1a2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
8366c06d46
commit
821e71fded
@ -827,9 +827,11 @@ static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d)
|
|||||||
// normalize to a short (decoded) form, so as to save space
|
// normalize to a short (decoded) form, so as to save space
|
||||||
QUrl url(e.flags & Element::StringIsUtf16 ?
|
QUrl url(e.flags & Element::StringIsUtf16 ?
|
||||||
b->asQStringRaw() :
|
b->asQStringRaw() :
|
||||||
b->toUtf8String());
|
b->toUtf8String(), QUrl::StrictMode);
|
||||||
QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8();
|
if (url.isValid()) {
|
||||||
replaceByteData(encoded, encoded.size(), {});
|
QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8();
|
||||||
|
replaceByteData(encoded, encoded.size(), {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return QCborValue::Url;
|
return QCborValue::Url;
|
||||||
}
|
}
|
||||||
|
@ -2053,6 +2053,14 @@ void tst_QCborValue::extendedTypeValidation_data()
|
|||||||
qSwap(c, dt[i]);
|
qSwap(c, dt[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Improperly-encoded URLs
|
||||||
|
{
|
||||||
|
const char badurl[] = "%zz";
|
||||||
|
QTest::newRow("Url:Invalid")
|
||||||
|
<< encode(0xd8, int(QCborKnownTags::Url), 0x60 + int(strlen(badurl)), badurl)
|
||||||
|
<< QCborValue(QCborKnownTags::Url, QLatin1String(badurl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QCborValue::extendedTypeValidation()
|
void tst_QCborValue::extendedTypeValidation()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user