Просмотр исходного кода

fix: don't send expired cookies, #953

tophf 6 лет назад
Родитель
Сommit
57fd7d0983
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      src/background/utils/requests.js

+ 3 - 2
src/background/utils/requests.js

@@ -270,11 +270,12 @@ async function httpRequest(details, src, cb) {
   xhr.timeout = Math.max(0, Math.min(0x7FFF_FFFF, details.timeout)) || 0;
   xhr.timeout = Math.max(0, Math.min(0x7FFF_FFFF, details.timeout)) || 0;
   if (overrideMimeType) xhr.overrideMimeType(overrideMimeType);
   if (overrideMimeType) xhr.overrideMimeType(overrideMimeType);
   if (shouldSendCookies) {
   if (shouldSendCookies) {
-    const cookies = await browser.cookies.getAll({
+    const now = Date.now() / 1000;
+    const cookies = (await browser.cookies.getAll({
       url,
       url,
       storeId: src.tab.cookieStoreId,
       storeId: src.tab.cookieStoreId,
       ...ua.isFirefox >= 59 && { firstPartyDomain: null },
       ...ua.isFirefox >= 59 && { firstPartyDomain: null },
-    });
+    })).filter(c => c.session || c.expirationDate > now); // FF reports expired cookies!
     if (cookies.length) {
     if (cookies.length) {
       req.noNativeCookie = true;
       req.noNativeCookie = true;
       vmHeaders.push({
       vmHeaders.push({