Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix security issue Uncaught DOMException when click to share #356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/share-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default {
return {
popupTop: 0,
popupLeft: 0,
popupWindow: undefined,
popupInterval: null
}
},
Expand Down Expand Up @@ -211,18 +210,18 @@ export default {
*/
share () {
this.resizePopup()

let popupWindow;
// If a popup window already exist, we close it and trigger a change event.
if (this.popupWindow && this.popupInterval) {
if (popupWindow && this.popupInterval) {
clearInterval(this.popupInterval)

// Force close (for Facebook)
this.popupWindow.close()
popupWindow.close()

this.emit('change')
}

this.popupWindow = $window.open(
popupWindow = $window.open(
this.shareLink,
'sharer-' + this.key,
',height=' + this.popup.height +
Expand All @@ -234,16 +233,16 @@ export default {
)

// 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) {
if (!popupWindow || popupWindow.closed) {
clearInterval(this.popupInterval)

this.popupWindow = null
popupWindow = null

this.emit('close')
}
Expand Down