ezshine / wxapkg-convertor

一个反编译微信小程序的工具,仓库也收集各种微信小程序/小游戏.wxapkg文件
MIT License
1.35k stars 373 forks source link

src/wuWxapkg.js Line 158 缺陷未考虑workDir不是文件夹的情况 #32

Open stathamcheng opened 1 year ago

stathamcheng commented 1 year ago
          let findDir = function (dir, oldDir) {
                let files = fs.readdirSync(dir);
                for (const file of files) {
                    let workDir = path.join(dir, file);   //此处workDir不是文件夹会导致fs.readdirSync(dir)抛异常,未考虑其处理逻辑
                    if (fs.existsSync(path.resolve(workDir, "app-service.js"))) {
                        console.log("sub package word dir: " + workDir);
                        mainDir = path.resolve(oldDir, mainDir);
                        console.log("real mainDir: " + mainDir);
                        dealThreeThings(workDir, mainDir, oldDir);
                        doSubPkg = true;
                        return true;
                    } else {
                        findDir(workDir, oldDir);
                    }
                }

            };
stathamcheng commented 1 year ago

而且,如果遍历完成后仍未 满足 if (fs.existsSync(path.resolve(workDir, "app-service.js"))) 条件,将会抛178行ERROR:(throw new Error("检测到此包是分包后的子包, 请通过 -s 参数指定存放路径后重试, 如 node wuWxapkg.js -s=/xxx/xxx ./testpkg/test-pkg-sub.wxapkg");)