Skip to content

Commit

Permalink
Avoid crashes if postMessage data is null
Browse files Browse the repository at this point in the history
axe-core crashes if another process sends a `window.postMessage` with
data equals to `null`.

In the previous version, because `null` has a type of `'object'`, it
crashed when trying to access the `channelId` on `null`.
  • Loading branch information
esanzgar committed Nov 2, 2021
1 parent 112b960 commit 8bc1ef4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/core/utils/frame-messenger/message-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function parseMessage(dataString) {
*/
function isRespondableMessage(postedMessage) {
return (
postedMessage !== null &&
typeof postedMessage === 'object' &&
typeof postedMessage.channelId === 'string' &&
postedMessage.source === getSource()
Expand Down

0 comments on commit 8bc1ef4

Please sign in to comment.