Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1767 from kvhnuke/bug/change-regex
Browse files Browse the repository at this point in the history
bug/change-regex
  • Loading branch information
kvhnuke authored Apr 13, 2018
2 parents 9ca1085 + f562411 commit f53e093
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Release v3.21.07

#### Fixes
- Fix regex checking on save local token [#1767](https://github.com/kvhnuke/etherwallet/pull/1767)
- Fix contest page mobile issue [Commit](https://github.com/kvhnuke/etherwallet/commit/c5bf76718770939972419e134315cef1ea2c8ae5)
- Add COIL token to defaults [#1764](https://github.com/kvhnuke/etherwallet/pull/1764)
- Add "x" to on boarding modal for more explicit closing [#1768](https://github.com/kvhnuke/etherwallet/pull/1768)
Expand Down
9 changes: 7 additions & 2 deletions app/scripts/globalFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ globalFuncs.getRandomBytes = function(num) {
return ethUtil.crypto.randomBytes(num);
};

globalFuncs.isAlphaNumericOrSpec = function(value) {
return !/^[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/.test(value);
}

function getFromLS(key, errorMsg) {
var localStorageItemString = globalFuncs.localStorage.getItem(key);
if (!localStorageItemString && errorMsg) {
Expand Down Expand Up @@ -302,7 +306,7 @@ globalFuncs.saveTokenToLocal = function(localToken, callback) {
try {
if (!ethFuncs.validateEtherAddress(localToken.contractAdd)) {throw globalFuncs.errorMsgs[5]}
else if (!globalFuncs.isNumeric(localToken.decimals) || parseFloat(localToken.decimals) < 0) {throw globalFuncs.errorMsgs[7]}
else if (!globalFuncs.isAlphaNumeric(localToken.symbol) || localToken.symbol == "") {throw globalFuncs.errorMsgs[19]}
else if (globalFuncs.isAlphaNumericOrSpec(localToken.symbol) || localToken.symbol === "") {throw globalFuncs.errorMsgs[19]}
var storedTokens = globalFuncs.localStorage.getItem("localTokens", null) != null ? JSON.parse(globalFuncs.localStorage.getItem("localTokens")) : [];

// catch if TOKEN SYMBOL is already in storedTokens
Expand Down Expand Up @@ -341,9 +345,10 @@ globalFuncs.saveTokenToLocal = function(localToken, callback) {
});

} catch (e) {
const newE = e.message ? e.message : e;
callback({
error: true,
msg: e.message
msg: newE
});
}
};
Expand Down

0 comments on commit f53e093

Please sign in to comment.