From ec228dd4e8f4f07e11a0fa7a6a33e275afd5b447 Mon Sep 17 00:00:00 2001 From: chee Date: Thu, 14 Sep 2017 03:08:36 +0100 Subject: [PATCH] ensure the sha is a string before comparison --- client/src/components/Camera.js | 1 - client/src/containers/Toad.js | 6 +++++- client/src/store.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/Camera.js b/client/src/components/Camera.js index e7c11f0..c691b2e 100644 --- a/client/src/components/Camera.js +++ b/client/src/components/Camera.js @@ -57,7 +57,6 @@ class Camera extends React.Component { ) storePicture(this.canvas.toDataURL('image/jpeg', true)) .then(picture => { - console.log(picture) this.props.addPicture(picture) this.clearTakingPicture() videoStream.getTracks()[0].stop() diff --git a/client/src/containers/Toad.js b/client/src/containers/Toad.js index aeda698..ffb1d10 100644 --- a/client/src/containers/Toad.js +++ b/client/src/containers/Toad.js @@ -79,7 +79,11 @@ class Toad extends Component { loadPicture(data.sha).then(picture => { picture && connection.send(response(data.sha, picture)) }) - } else if (data.response && checkPicture(data.picture, data.sha)) { + } else if (data.response) { + const pictureValid = checkPicture(data.picture, data.sha) + if (!pictureValid) { + return console.error('invalid picture received') + } const index = this.state.list.indexOf(data.sha) this.setState(state => { state.pictures[index] = data.picture diff --git a/client/src/store.js b/client/src/store.js index f613a0b..d24a19d 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -14,7 +14,7 @@ const loadPicture = sha => localforage.getItem(sha) const checkPicture = (picture, sha) => - shasum(picture) === sha + shasum(picture).toString() === sha module.exports = { storePicture,