From cb44cff168708e77b0ad303f23250d4b097e6509 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Mon, 30 Nov 2020 12:59:01 -0800 Subject: [PATCH] Fix watchAsset symbol validation (#9960) --- app/scripts/controllers/preferences.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 5e376a797361..a3c6fec92905 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -800,14 +800,16 @@ export default class PreferencesController { * doesn't fulfill requirements * */ - _validateERC20AssetParams(opts) { - const { rawAddress, symbol, decimals } = opts + _validateERC20AssetParams({ rawAddress, symbol, decimals } = {}) { if (!rawAddress || !symbol || typeof decimals === 'undefined') { throw new Error( `Cannot suggest token without address, symbol, and decimals`, ) } - if (!(symbol.length < 7)) { + if (typeof symbol !== 'string') { + throw new Error(`Invalid symbol: not a string`) + } + if (symbol.length > 6) { throw new Error(`Invalid symbol ${symbol} more than six characters`) } const numDecimals = parseInt(decimals, 10)