jsParse: Replace eval()

The evil() function is considered eval, replace it like we
already did in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
This commit is contained in:
Florian Müllner 2023-07-13 01:52:06 +02:00 committed by Marge Bot
parent a66ffcfc74
commit 13e20e47bf

View File

@ -197,7 +197,9 @@ function getPropertyNamesFromExpression(expr, commandHeader = '') {
let obj = {};
if (!isUnsafeExpression(expr)) {
try {
obj = eval(commandHeader + expr);
const lines = expr.split(';');
lines.push(`return ${lines.pop()}`);
obj = Function(commandHeader + lines.join(';'))();
} catch (e) {
return [];
}