fix: Redefine window.confirm() in preload#307
fix: Redefine window.confirm() in preload#307ajinkya-browserstack wants to merge 1 commit intomasterfrom
Conversation
WalkthroughThis change modifies src/main/preload.js to override the global window.confirm function on Windows platforms. The dialog module is imported from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Warning Tools execution failed with the following error: Failed to run tools: 14 UNAVAILABLE: read ECONNRESET Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can generate walkthrough in a markdown collapsible section to save space.Enable the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/preload.js`:
- Around line 47-49: The fallback in the catch block inside the confirm shim
currently returns true when both showMessageBoxSync and originalConfirm are
unavailable, which auto-confirms on error; change the catch to return
originalConfirm ? originalConfirm(message) : false (or otherwise explicitly
deny) and optionally log the caught error so failures do not grant implicit
consent; update the catch that references showMessageBoxSync and originalConfirm
in preload.js accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2bdb2e23-46cc-42db-b33a-d51d5a6dea38
📒 Files selected for processing (1)
src/main/preload.js
| } catch (e) { | ||
| // Fallback to original confirm if dialog fails for any reason | ||
| return originalConfirm ? originalConfirm(message) : true; |
There was a problem hiding this comment.
Do not auto-confirm on fallback failure.
Line 49 returns true when both showMessageBoxSync and originalConfirm are unavailable. That turns a dialog error into implicit user consent and can execute destructive flows without confirmation.
🛠️ Proposed fix
- return originalConfirm ? originalConfirm(message) : true;
+ return originalConfirm ? originalConfirm.call(window, message) : false;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/preload.js` around lines 47 - 49, The fallback in the catch block
inside the confirm shim currently returns true when both showMessageBoxSync and
originalConfirm are unavailable, which auto-confirms on error; change the catch
to return originalConfirm ? originalConfirm(message) : false (or otherwise
explicitly deny) and optionally log the caught error so failures do not grant
implicit consent; update the catch that references showMessageBoxSync and
originalConfirm in preload.js accordingly.
Summary by CodeRabbit