1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 11:08:09 +01:00

Use JSON.parse rather than eval to parse strings.

--HG--
extra : transplant_source : %7B%40A%81%9F3%F4N%A7%0A%C37%A5%3D%D0%B9d%80%14%FE
This commit is contained in:
Kris Maglione
2010-10-06 23:28:42 -04:00
parent dd3d79ea73
commit d6fd5d929d
2 changed files with 2 additions and 4 deletions

View File

@@ -917,7 +917,7 @@ const Commands = Module("commands", {
if ((res = re2.exec(str))) if ((res = re2.exec(str)))
arg += keepQuotes ? res[0] : res[2].replace(/\\(.)/g, "$1"); arg += keepQuotes ? res[0] : res[2].replace(/\\(.)/g, "$1");
else if ((res = /^(")((?:[^\\"]|\\.)*)("?)/.exec(str))) else if ((res = /^(")((?:[^\\"]|\\.)*)("?)/.exec(str)))
arg += keepQuotes ? res[0] : window.eval(res[0] + (res[3] ? "" : '"')); arg += keepQuotes ? res[0] : JSON.parse(res[0] + (res[3] ? "" : '"'));
else if ((res = /^(')((?:[^']|'')*)('?)/.exec(str))) else if ((res = /^(')((?:[^']|'')*)('?)/.exec(str)))
arg += keepQuotes ? res[0] : res[2].replace("''", "'", "g"); arg += keepQuotes ? res[0] : res[2].replace("''", "'", "g");
else else

View File

@@ -478,9 +478,7 @@ const JavaScript = Module("javascript", {
// The top of the stack is the sting we're completing. // The top of the stack is the sting we're completing.
// Wrap it in its delimiters and eval it to process escape sequences. // Wrap it in its delimiters and eval it to process escape sequences.
let string = this._str.substring(this._get(-1).offset + 1, this._lastIdx); let string = this._str.substring(this._get(-1).offset + 1, this._lastIdx);
// This is definitely a properly quoted string. string = JSON.parse(this._last + string + this._last);
// Just eval it normally.
string = window.eval(this._last + string + this._last);
// Is this an object accessor? // Is this an object accessor?
if (this._get(-2).char == "[") { // Are we inside of []? if (this._get(-2).char == "[") { // Are we inside of []?