Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

1 participant

@gregorwagner
Owner

No description provided.

@gregorwagner gregorwagner merged commit 93dd992 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 shared/js/phoneNumberJS/PhoneNumber.js
View
4 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 });
Something went wrong with that request. Please try again.