Skip to content

Commit

Permalink
Update EvalPlus.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium authored Nov 30, 2024
1 parent cb5f8b9 commit a28694b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions featured/EvalPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,33 @@
reporterBlock({ CODE }) {
CODE = cast.toString(CODE);
try {
if (!this.enabled) return null;
if (!this.enabled) return "";
return eval(CODE);
} catch (error) {
console.error("Error:", error);
return null;
return "";
}
}

capturedReporter({ CODE }) {
CODE = cast.toString(CODE);
try {
if (!this.enabled) return null;
if (!this.enabled) return "";
this.consoleOutput = [];
const self = this;

const originalLog = console.log;

console.log = function (...args) {
self.consoleOutput.push(args.join(' '));
};
eval(CODE)
delete console.log

console.log = originalLog

return this.consoleOutput.join('\n');
} catch (error) {
console.error("Error:", error);
return null;
return "";
}
}

Expand Down Expand Up @@ -276,14 +279,14 @@
restrictedReporterBlock({ CODE }) {
CODE = cast.toString(CODE);
try {
if (!this.enabled) return null;
if (!this.enabled) return "";
if (!/^[a-zA-Z0-9\s()\[\]{};.,\-+=*\/%]*$/.test(CODE)) {
throw new Error("Invalid characters detected.");
}
return eval(CODE);
} catch (error) {
console.error("Error:", error);
return null;
return "";
}
}

Expand Down

0 comments on commit a28694b

Please sign in to comment.