Skip to content

Commit

Permalink
content script domain validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nsjames committed Jun 20, 2018
1 parent 0acb9be commit 06f3ab0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class Content {
return;
}

const domain = location.host.replace('www', '');
if(msg.hasOwnProperty('domain') && msg.domain !== domain) throw new Error('Bad domain');
if(msg.hasOwnProperty('payload') && msg.payload.hasOwnProperty('domain') && msg.payload.domain !== domain)
throw new Error('Bad domain');

console.log(msg);

let nonSyncMessage = NetworkMessage.fromJson(msg);
switch(msg.type){
case 'sync': this.sync(msg); break;
Expand Down

0 comments on commit 06f3ab0

Please sign in to comment.