Skip to content

Commit

Permalink
ensure the sha is a string before comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Sep 14, 2017
1 parent 94bc482 commit ec228dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion client/src/components/Camera.js
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion client/src/containers/Toad.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/src/store.js
Expand Up @@ -14,7 +14,7 @@ const loadPicture = sha =>
localforage.getItem(sha)

const checkPicture = (picture, sha) =>
shasum(picture) === sha
shasum(picture).toString() === sha

module.exports = {
storePicture,
Expand Down

0 comments on commit ec228dd

Please sign in to comment.