tjy-gitnub / win12

Windows 12 网页版,在线体验 点击下面的链接在线体验
https://tjy-gitnub.github.io/win12/desktop.html
Eclipse Public License 2.0
6.52k stars 791 forks source link

[漏洞] #201

Closed skyclouds2001 closed 1 year ago

skyclouds2001 commented 1 year ago

描述

开发者工具报错,报错如下

sw.js:28 Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Request scheme 'chrome-extension' is unsupported

重现

  1. Chrome 浏览器下载 Wappalyzer 浏览器插件(可能其他插件也行)
  2. 浏览网页(此时浏览器插件会请求资源),可以在开发者工具注意到报错

截图

image

测试环境

浏览器:[Chrome] 浏览器版本:[116.0.5845.141] 操作系统:[Windows 10]

其他

不保证该报错会对程序运行一定会造成影响,但建议可以对拦截的请求进行筛选

this.addEventListener('fetch', function (event) {
  event.respondWith(
    caches.match(event.request).then(res => {
      let fl = false;
      dymanic.forEach(d => {
        if (event.request.url.indexOf(d) > 0) {
          fl = true;
          return;
        }
      });
      if (fl) {
        console.log('动态请求', event.request.url);
        return fetch(event.request);
      }
      return res ||
        fetch(event.request)
          .then(responese => {
            // console.log(event.request);
            const responeseClone = responese.clone();
            caches.open('def').then(cache => {
              console.log('下载数据', responeseClone.url);
              cache.put(event.request, responeseClone);
            })
            return responese;
          })
          .catch(err => {
            console.log(err);
          });
    })
  )
});
NebulaTechs commented 1 year ago

其实可以的话,建议交Pull Request

tjy-gitnub commented 1 year ago

这个是因为页面发起了一个拓展的请求,所以被浏览器拦截,并没有太大问题的。感谢您的反馈。