Skip to content

Commit

Permalink
fix: don't allow {} as emailProtectionUserData when sending data …
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Nov 23, 2022
1 parent eaadd7d commit e35cdb9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shared/js/background/classes/privacy-dashboard-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* The return type of this function comes from a schema defined in the Privacy Dashboard,
*
* @param {import("./tab.es6.js")} tab
* @param {EmailProtectionUserData | undefined} userData
* @param {EmailProtectionUserData | undefined | {}} userData
* @returns {ExtensionGetPrivacyDashboardData}
*/
export function dashboardDataFromTab (tab, userData) {
Expand All @@ -37,6 +37,12 @@ export function dashboardDataFromTab (tab, userData) {

const requests = convertToRequests(tab, protectionsEnabled)

// Only assign `emailProtectionUserData` if we're sure it is valid data - otherwise allow it to be undefined.
let emailProtectionUserData
if (userData && 'userName' in userData) {
emailProtectionUserData = userData
}

return {
tab: {
id: tab.id,
Expand All @@ -49,7 +55,7 @@ export function dashboardDataFromTab (tab, userData) {
requestData: {
requests
},
emailProtectionUserData: userData
emailProtectionUserData
}
}

Expand Down

0 comments on commit e35cdb9

Please sign in to comment.