diff options
author | Alexander Tkachev | 2019-08-04 04:36:59 +0700 |
---|---|---|
committer | Alexander Tkachev | 2019-08-04 04:36:59 +0700 |
commit | 1c0b697a59472445e7b8847e566974b503ce012d (patch) | |
tree | 93300c205deb791b667db65aa16d21a35956f142 /backends/cloud | |
parent | a769bace7fafadd983a243fc86c5c2aff29c2c27 (diff) | |
download | scummvm-rg350-1c0b697a59472445e7b8847e566974b503ce012d.tar.gz scummvm-rg350-1c0b697a59472445e7b8847e566974b503ce012d.tar.bz2 scummvm-rg350-1c0b697a59472445e7b8847e566974b503ce012d.zip |
CLOUD: Fix OneDriveTokenRefresher
If user doesn't have a "saves" folder, listing it as a first step of
syncing save files would result in 404 from OneDrive.
OneDriveTokenRefresher handles token-related errors (401), so when it
meets 404, it calls its finishError method. But because there was some
strange behaviour from OneDrive with sending invalid JSON, this method
tries fixing JSON and parsing it again. If it is valid, it calls
non-error method again, and in result we get stack overflow.
In order to fix that, I've added a non-JSON prefix "<irrecoverable>", so
finishError won't be able to parse JSON and thus won't call finishJson
again. Saves syncing callback does check string contents apart from
trying to parse JSON, so it still works and correctly handles the
situation when "saves" directory is missing. But, if needed, code can be
updated to search for the prefix I've added and remove it before parsing
original JSON.
Diffstat (limited to 'backends/cloud')
-rw-r--r-- | backends/cloud/onedrive/onedrivetokenrefresher.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp index 1654869e07..10992c5927 100644 --- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp +++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp @@ -98,7 +98,8 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) { irrecoverable = false; if (irrecoverable) { - finishError(Networking::ErrorResponse(this, false, true, json->stringify(true), httpResponseCode)); + Common::String errorContents = "<irrecoverable> " + json->stringify(true); + finishError(Networking::ErrorResponse(this, false, true, errorContents, httpResponseCode)); delete json; return; } |