Skip to content

Commit fa17699

Browse files
committed
fix(security): prevent XSS attack on toast, related to #1353
1 parent eb7ba73 commit fa17699

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/shell-chrome/src/devtools-background.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function onContextMenu ({ id }) {
6868
}, 'Open Vue devtools to see component details')
6969
} else {
7070
pendingAction = null
71-
toast('No Vue component was found', 'warn')
71+
toast('component-not-found')
7272
}
7373
})
7474
}
@@ -113,7 +113,15 @@ function onPanelHidden () {
113113

114114
// Toasts
115115

116-
function toast (message, type = 'normal') {
116+
const toastMessages = {
117+
'component-not-found': { message: 'No Vue component was found', type: 'warn' }
118+
}
119+
120+
function toast (id) {
121+
if (!Object.keys().includes(id)) return
122+
123+
const { message, type } = toastMessages[id]
124+
117125
const src = `(function() {
118126
__VUE_DEVTOOLS_TOAST__(\`${message}\`, '${type}');
119127
})()`

0 commit comments

Comments
 (0)