Skip to content

Commit

Permalink
Hardening clipboardData handling in EnsInput (#11822)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanml authored Aug 12, 2021
1 parent e0692db commit 428b86f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ui/pages/send/send-content/add-recipient/ens-input.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ export default class EnsInput extends Component {
}

onPaste = (event) => {
event.clipboardData.items[0].getAsString((text) => {
const input = text.trim();
if (
!isBurnAddress(input) &&
isValidHexAddress(input, { mixedCaseUseChecksum: true })
) {
this.props.onPaste(input);
}
});
if (event.clipboardData.items?.length) {
const clipboardItem = event.clipboardData.items[0];
clipboardItem?.getAsString((text) => {
const input = text.trim();
if (
!isBurnAddress(input) &&
isValidHexAddress(input, { mixedCaseUseChecksum: true })
) {
this.props.onPaste(input);
}
});
}
};

onChange = ({ target: { value } }) => {
Expand Down

0 comments on commit 428b86f

Please sign in to comment.