Bug 1889590 - Make cache DB use utf-8 for referrer strings. r=dom-storage-reviewers,janv,asuth

My understanding is that this should be safe to do. These have always
been utf-8 strings / urls anyways, and sqlite seems to handle returning
a TEXT field in both utf16 and utf8, and the DB should already use utf-8
encoding, so this change should just work, ideally?

But I'm not the most familiar with all that code so worth a
double-check.

Differential Revision: https://phabricator.services.mozilla.com/D206611
This commit is contained in:
Emilio Cobos Álvarez 2024-04-05 07:16:33 +00:00
parent 939c42239d
commit adeee35f59

View file

@ -1794,8 +1794,8 @@ nsresult InsertEntry(mozIStorageConnection& aConn, CacheId aCacheId,
QM_TRY(MOZ_TO_RESULT(state->BindUTF8StringByName("request_url_fragment"_ns,
aRequest.urlFragment())));
QM_TRY(MOZ_TO_RESULT(state->BindStringByName(
"request_referrer"_ns, NS_ConvertUTF8toUTF16(aRequest.referrer()))));
QM_TRY(MOZ_TO_RESULT(state->BindUTF8StringByName("request_referrer"_ns,
aRequest.referrer())));
QM_TRY(MOZ_TO_RESULT(state->BindInt32ByName(
"request_referrer_policy"_ns,
@ -2208,11 +2208,8 @@ Result<SavedRequest, nsresult> ReadRequest(mozIStorageConnection& aConn,
MOZ_TO_RESULT(state->GetUTF8String(2, savedRequest.mValue.urlQuery())));
QM_TRY(MOZ_TO_RESULT(
state->GetUTF8String(3, savedRequest.mValue.urlFragment())));
{
nsAutoString referrer;
QM_TRY(MOZ_TO_RESULT(state->GetString(4, referrer)));
CopyUTF16toUTF8(referrer, savedRequest.mValue.referrer());
}
QM_TRY(
MOZ_TO_RESULT(state->GetUTF8String(4, savedRequest.mValue.referrer())));
QM_TRY_INSPECT(const int32_t& referrerPolicy,
MOZ_TO_RESULT_INVOKE_MEMBER(state, GetInt32, 5));