From 9958da96c90644fb8e87e12ef429e561db32ff8a Mon Sep 17 00:00:00 2001 From: Matt Holtzman Date: Tue, 16 Nov 2021 17:24:06 -0500 Subject: [PATCH] render messages to sign if utf-8 encoded --- .../Main/Account/Requests/SignatureRequest/index.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/App/Panel/Main/Account/Requests/SignatureRequest/index.js b/app/App/Panel/Main/Account/Requests/SignatureRequest/index.js index 153bb2da2..e81aabfa1 100644 --- a/app/App/Panel/Main/Account/Requests/SignatureRequest/index.js +++ b/app/App/Panel/Main/Account/Requests/SignatureRequest/index.js @@ -1,17 +1,14 @@ import React from 'react' import Restore from 'react-restore' -import { fromWei, toAscii, isHex } from 'web3-utils' -import { addHexPrefix } from 'ethereumjs-util' +import { fromWei, isHex } from 'web3-utils' +import { stripHexPrefix } from 'ethereumjs-util' import svg from '../../../../../../../resources/svg' import link from '../../../../../../../resources/link' -const DISPLAYABLE = /^[\x20-\x7E]*$/ - function decodeMessage (rawMessage) { if (isHex(rawMessage)) { - // attempt to decode plaintext (unhashed) hex messages to ASCII for display - const ascii = toAscii(addHexPrefix(rawMessage)) - return ascii.match(DISPLAYABLE) ? ascii : rawMessage + const buff = Buffer.from(stripHexPrefix(rawMessage), 'hex') + return buff.length === 32 ? rawMessage : buff.toString('utf8') } return rawMessage