From fb0af1bf1c9c632766f4b4def4c72145bbf16756 Mon Sep 17 00:00:00 2001 From: abar1 Date: Tue, 21 Nov 2023 15:25:54 +0200 Subject: [PATCH 1/2] fix security issue Uncaught DOMException when click to share --- src/share-network.js | 54 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/share-network.js b/src/share-network.js index f3f17fd..c068970 100644 --- a/src/share-network.js +++ b/src/share-network.js @@ -99,7 +99,6 @@ export default { return { popupTop: 0, popupLeft: 0, - popupWindow: undefined, popupInterval: null } }, @@ -210,46 +209,53 @@ export default { * Shares URL in specified network. */ share () { - this.resizePopup() - + + this.resizePopup(); + let popupWindow; // If a popup window already exist, we close it and trigger a change event. - if (this.popupWindow && this.popupInterval) { - clearInterval(this.popupInterval) + if (popupWindow && this.popupInterval) { + clearInterval(this.popupInterval); // Force close (for Facebook) - this.popupWindow.close() + popupWindow.close(); - this.emit('change') + this.emit("change"); } - this.popupWindow = $window.open( + popupWindow = $window.open( this.shareLink, - 'sharer-' + this.key, - ',height=' + this.popup.height + - ',width=' + this.popup.width + - ',left=' + this.popupLeft + - ',top=' + this.popupTop + - ',screenX=' + this.popupLeft + - ',screenY=' + this.popupTop - ) + "sharer-" + this.key, + ",height=" + + this.popup.height + + ",width=" + + this.popup.width + + ",left=" + + this.popupLeft + + ",top=" + + this.popupTop + + ",screenX=" + + this.popupLeft + + ",screenY=" + + this.popupTop + ); // If popup are prevented (AdBlocker, Mobile App context..), popup.window stays undefined and we can't display it - if (!this.popupWindow) return + if (!popupWindow) return; - this.popupWindow.focus() + popupWindow.focus(); // Create an interval to detect popup closing event this.popupInterval = setInterval(() => { - if (!this.popupWindow || this.popupWindow.closed) { - clearInterval(this.popupInterval) + if (!popupWindow || popupWindow.closed) { + clearInterval(this.popupInterval); - this.popupWindow = null + popupWindow = null; - this.emit('close') + this.emit("close"); } - }, 500) + }, 500); - this.emit('open') + this.emit("open"); }, /** From 029a3e366314aae03b6f620524d2edcff3fd7b8e Mon Sep 17 00:00:00 2001 From: abar1 Date: Tue, 21 Nov 2023 15:42:46 +0200 Subject: [PATCH 2/2] fix formating --- src/share-network.js | 45 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/share-network.js b/src/share-network.js index c068970..ac09b1a 100644 --- a/src/share-network.js +++ b/src/share-network.js @@ -209,53 +209,46 @@ export default { * Shares URL in specified network. */ share () { - - this.resizePopup(); + this.resizePopup() let popupWindow; // If a popup window already exist, we close it and trigger a change event. if (popupWindow && this.popupInterval) { - clearInterval(this.popupInterval); + clearInterval(this.popupInterval) // Force close (for Facebook) - popupWindow.close(); + popupWindow.close() - this.emit("change"); + this.emit('change') } popupWindow = $window.open( this.shareLink, - "sharer-" + this.key, - ",height=" + - this.popup.height + - ",width=" + - this.popup.width + - ",left=" + - this.popupLeft + - ",top=" + - this.popupTop + - ",screenX=" + - this.popupLeft + - ",screenY=" + - this.popupTop - ); + 'sharer-' + this.key, + ',height=' + this.popup.height + + ',width=' + this.popup.width + + ',left=' + this.popupLeft + + ',top=' + this.popupTop + + ',screenX=' + this.popupLeft + + ',screenY=' + this.popupTop + ) // If popup are prevented (AdBlocker, Mobile App context..), popup.window stays undefined and we can't display it - if (!popupWindow) return; + if (!popupWindow) return - popupWindow.focus(); + popupWindow.focus() // Create an interval to detect popup closing event this.popupInterval = setInterval(() => { if (!popupWindow || popupWindow.closed) { - clearInterval(this.popupInterval); + clearInterval(this.popupInterval) - popupWindow = null; + popupWindow = null - this.emit("close"); + this.emit('close') } - }, 500); + }, 500) - this.emit("open"); + this.emit('open') }, /**