Gracefully handle lack of the cookie

This commit is contained in:
Kaenbyou Rin 2023-11-08 23:58:39 +01:00
parent 1ef84cb879
commit 0477fd5fa6
6 changed files with 13 additions and 4 deletions

View File

@ -122,7 +122,7 @@ function uupFetchUpd(
consoleLogger('Fetching information from the server...');
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags];
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
if($out['error'] != 200) {
if($out === false || $out['error'] != 200) {
consoleLogger('The request has failed');
return array('error' => 'WU_REQUEST_FAILED');
}

View File

@ -399,7 +399,7 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
$composerArgs = [$updateId, $info, $rev, $type];
$out = sendWuPostRequestHelper('clientSecured', 'composeFileGetRequest', $composerArgs);
if($out['error'] != 200) {
if($out === false || $out['error'] != 200) {
consoleLogger('The request has failed');
return array('error' => 'WU_REQUEST_FAILED');
}

View File

@ -60,6 +60,9 @@ function uupEncryptedData() {
if(empty($cookieInfo)) {
$data = sendWuPostRequestHelper('client', 'composeGetCookieRequest', [], false);
if($data === false || $data['error'] != 200)
return false;
$cookieInfo = uupSaveCookieFromResponse($data['out']);
}

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '1.43.1';
return '1.43.2';
}
require_once dirname(__FILE__).'/auths.php';

View File

@ -362,8 +362,11 @@ XML;
// Composes POST data for fetching the latest update information from Windows Update
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
$device = uupDevice();
$encData = uupEncryptedData();
if($encData === false)
return false;
$device = uupDevice();
$uuid = genUUID();
$createdTime = time();

View File

@ -102,6 +102,9 @@ function sendWuPostRequestHelper(
];
$postData = call_user_func_array($postComposer, $postComposerArgs);
if($postData === false)
return false;
$data = sendWuPostRequestInternal($endpoints[$endpoint], $postData, $saveCookie);
if($data['error'] == 500 && preg_match('/<ErrorCode>(ConfigChanged|CookieExpired|InvalidCookie)<\/ErrorCode>/', $data['out'])) {