Permalink
Browse files

Bug 817563 - [PhoneNumberJS] Remove .eval() from code

  • Loading branch information...
1 parent b0e1277 commit 1da94a199db45d095073d141a7b5a7a156c6f611 @gregorwagner gregorwagner committed Dec 6, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 shared/js/phoneNumberJS/PhoneNumber.js
@@ -11,6 +11,8 @@ var PhoneNumber = (function (dataBase) {
const NON_DIALABLE_CHARS = /[^+\*\d]/g;
const PLUS_CHARS = /^[+\uFF0B]+/;
const BACKSLASH = /\\/g;
+ const COMMACOMMA = /,,/g;
+ const COMMABRACKET = /,]/g;
const SPLIT_FIRST_GROUP = /^(\d+)(.*)$/;
// Format of the string encoded meta data. If the name contains "^" or "$"
@@ -53,7 +55,7 @@ var PhoneNumber = (function (dataBase) {
// Parse string encoded meta data into a convenient object
// representation.
function ParseMetaData(countryCode, md) {
- var array = eval(md.replace(BACKSLASH, "\\\\"));
+ var array = JSON.parse(md.replace(BACKSLASH, "\\\\").replace(COMMACOMMA, ', null,').replace(COMMACOMMA, ', null,').replace(COMMABRACKET, ', null]'));
md = ParseArray(array,
META_DATA_ENCODING,
{ countryCode: countryCode });

0 comments on commit 1da94a1

Please sign in to comment.