MEW-01-003 - Parse JSON pasted into signed message verifier (#979)

This commit is contained in:
William O'Beirne 2018-02-01 17:35:26 -05:00 committed by Daniel Ternyak
parent 0d768d7517
commit e34137270e
1 changed files with 14 additions and 0 deletions

View File

@ -50,6 +50,7 @@ export class VerifyMessage extends Component<Props, State> {
placeholder={signaturePlaceholder}
value={signature}
onChange={this.handleSignatureChange}
onPaste={this.handleSignaturePaste}
/>
</div>
@ -103,6 +104,19 @@ export class VerifyMessage extends Component<Props, State> {
const signature = e.currentTarget.value;
this.setState({ signature });
};
private handleSignaturePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
const text = e.clipboardData.getData('Text');
if (text) {
try {
const signature = JSON.stringify(JSON.parse(text), null, 2);
this.setState({ signature });
e.preventDefault();
} catch (err) {
// Do nothing, it wasn't json they pasted
}
}
};
}
export default connect(null, {