Modernize Electron app: fix Drive link parsing, harden security#22
Merged
Conversation
- Upgrade Electron 13.6.6 -> 43.x (plus electron-builder/electron-packager/asar)
- main.js: remove nodeIntegration/webviewTag, enable contextIsolation+sandbox
- preload.js: expose IPC via contextBridge instead of leaving it inert
- renderer.js: use the new bridge instead of require('electron'); parse
both the legacy open?id= link and the current file/d/ID/view link
format (Drive's share UI no longer generates the old format); fix
</webview> typo to </iframe>
- index.html: drop the module.exports jQuery workaround, now unnecessary
without nodeIntegration
There was a problem hiding this comment.
Pull request overview
Modernizes the Electron-based Google Drive video player by upgrading to a current Electron major, fixing Google Drive share-link parsing to support both legacy and current formats, and tightening renderer/main boundaries by moving window-control actions behind a preload contextBridge API.
Changes:
- Update Drive URL parsing to support both
open?id=...and/file/d/ID/...formats and fix the generated player closing tag to</iframe>. - Replace
require('electron')usage in the renderer with awindow.gdPlayerpreload bridge. - Upgrade Electron/tooling dependencies and harden BrowserWindow webPreferences (context isolation + sandbox) while removing the jQuery module workaround.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| renderer.js | Adds robust Drive link parsing, fixes iframe closing tag, and switches window-control actions to window.gdPlayer. |
| preload.js | Introduces contextBridge API (gdPlayer) to send IPC commands from a locked-down renderer. |
| main.js | Updates BrowserWindow security-related webPreferences (context isolation + sandbox). |
| index.html | Removes the module workaround now that nodeIntegration is disabled; keeps jQuery + renderer script loading. |
| package.json | Upgrades Electron and packaging toolchain versions to current major releases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- renderer.js: declare url/id/parsed/fileMatch/player with const/let instead of leaking as implicit globals - main.js: explicitly set nodeIntegration:false and webviewTag:false instead of relying on defaults - preload.js: whitelist the resizeWindow size argument before interpolating it into the IPC channel name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
drive.google.com/open?id=...link format. Google's share UI now only generatesdrive.google.com/file/d/ID/view?usp=sharing, so current links silently failed. Both formats are now supported.main.js/preload.js/renderer.js: removenodeIntegration/webviewTag, enablecontextIsolation+sandbox, bridge IPC throughcontextBridgein preload instead ofrequire('electron')in the renderermodule.exportsjQuery workaround inindex.html, which is no longer needed oncenodeIntegrationis off</webview>→</iframe>closing-tag typo in the generated player HTMLNo feature/UI changes — this is a fix-and-modernize pass. jQuery itself was intentionally left in place.
Test plan
open?id=, currentfile/d/ID/viewwith/without query string, invalid input)window.gdPlayer.{resizeWindow,maximize,toggleAlwaysOnTop}are exposed andwindow.requireisundefined(contextIsolation working), no console errors<iframe>playernpm audit: 0 vulnerabilities after dependency bump🤖 Generated with Claude Code
Generated by Claude Code