diff --git a/lib/webmail-connexion.js b/lib/webmail-connexion.js index 7803689..b99f857 100644 --- a/lib/webmail-connexion.js +++ b/lib/webmail-connexion.js @@ -136,10 +136,8 @@ function creerOuvreurWebmail({ BrowserWindow, journal = () => {}, debug = () => if (releveur) releveur.arreter(); }); // Pièces jointes, liens : même politique que les popups des onglets. - // #354 : pas de fenêtre ouverte en arrière-plan depuis le webmail non plus. - wc.setWindowOpenHandler(({ url: cible, disposition }) => - disposition !== 'background-tab' && decidePopup(cible) === 'allow' - ? { action: 'allow' } : { action: 'deny' }); + wc.setWindowOpenHandler(({ url: cible }) => + decidePopup(cible) === 'allow' ? { action: 'allow' } : { action: 'deny' }); let tente = false; wc.on('did-finish-load', () => { if (tente || hoteDe(wc.getURL()) !== hote) return; diff --git a/main.js b/main.js index dac6646..9cee846 100644 --- a/main.js +++ b/main.js @@ -305,14 +305,7 @@ function createWindow() { verrouillerOngletFixe(guestContents); return; } - guestContents.setWindowOpenHandler(({ url, disposition }) => { - // Issue #354 : une page d'IA peut vouloir ouvrir une fenêtre EN ARRIÈRE-PLAN - // (disposition « background-tab », typiquement sa messagerie embarquée) : - // refusée — seule une fenêtre demandée au premier plan (clic, lien) s'ouvre. - if (disposition === 'background-tab') { - console.warn('[security] popup refusée (ouverture en arrière-plan, #354) :', hostOf(url)); - return { action: 'deny' }; - } + guestContents.setWindowOpenHandler(({ url }) => { if (decidePopup(url) === 'allow') return { action: 'allow' }; // Schéma non web (http:, data:, javascript:, URL illisible) : refus pur. // Jamais de repli vers le navigateur système : la popup d'authentification @@ -324,10 +317,8 @@ function createWindow() { // même politique (webPreferences de l'invité, jamais celles de l'hôte). guestContents.on('did-create-window', (child) => { try { - child.webContents.setWindowOpenHandler(({ url, disposition }) => - // #354 : même règle pour les fenêtres filles — pas d'arrière-plan. - disposition !== 'background-tab' && decidePopup(url) === 'allow' - ? { action: 'allow' } : { action: 'deny' }); + child.webContents.setWindowOpenHandler(({ url }) => + decidePopup(url) === 'allow' ? { action: 'allow' } : { action: 'deny' }); // Issue #278, lot 2 : suivi des fenêtres filles (popups d'authentification) // pour pouvoir y ancrer le menu des identifiants. const idEnfant = child.webContents.id; diff --git a/test/main-window-security.test.js b/test/main-window-security.test.js index 281f88b..fab2b67 100644 --- a/test/main-window-security.test.js +++ b/test/main-window-security.test.js @@ -258,22 +258,6 @@ test('did-attach-webview : popup non web (data:, javascript:, http:) => deny pur } finally { h.cleanup(); } }); -test('did-attach-webview : popup en arrière-plan (background-tab, #354) => deny', () => { - const h = boot(); - try { - const guest = h.attachGuest(); - // Issue #354 : une page d'IA peut vouloir ouvrir sa messagerie en - // arrière-plan (disposition « background-tab ») — refusé, même sur une - // URL https qui aurait sinon été autorisée. - let result; - const out = capture(() => { result = guest.openHandler({ url: 'https://claude.ai/messagerie', disposition: 'background-tab' }); }); - assert.deepEqual(result, { action: 'deny' }); - assert.equal(out.warn.length, 1); - assert.match(out.warn[0], /popup refusée \(ouverture en arrière-plan/); - assert.deepEqual(h.electron.calls.openExternal, []); - } finally { h.cleanup(); } -}); - test('did-attach-webview : about:blank (flux OAuth) => allow', () => { const h = boot(); try { diff --git a/test/webmail-connexion.test.js b/test/webmail-connexion.test.js index 5e1d6c6..0a705d6 100644 --- a/test/webmail-connexion.test.js +++ b/test/webmail-connexion.test.js @@ -111,11 +111,6 @@ test('ouvrir : fenêtre sans privilèges dans la partition du compte, une tentat assert.equal(win.charge, 'https://mail.dmathilde.fr/'); assert.deepEqual(win.webContents.popup({ url: 'https://mail.dmathilde.fr/piece' }), { action: 'allow' }); assert.deepEqual(win.webContents.popup({ url: 'javascript:alert(1)' }), { action: 'deny' }); - // Issue #354 : une fenêtre que la page veut ouvrir EN ARRIÈRE-PLAN - // (disposition « background-tab ») est refusée, même sur une URL sinon - // autorisée ; au premier plan, elle reste autorisée. - assert.deepEqual(win.webContents.popup({ url: 'https://mail.dmathilde.fr/piece', disposition: 'background-tab' }), { action: 'deny' }); - assert.deepEqual(win.webContents.popup({ url: 'https://mail.dmathilde.fr/piece', disposition: 'foreground-tab' }), { action: 'allow' }); // Page d'un autre hôte (SSO, redirection) : rien n'est rempli. win.url = 'https://ailleurs.example/login'; win.webContents.emit('did-finish-load');