Skip to content

Commit

Permalink
add protection for system.redirect_logging risks
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 15, 2018
1 parent 2c2d514 commit 6c5b763
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,9 @@ public static void adjustSystem(Mechanism mechanism) {
DenizenCore.logInterceptor.standardOutput();
}
}

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,27 @@ public LogInterceptor() {
// -->
@Override
public void print(String s) {
if (antiLoop) {
super.print(s);
return;
}
antiLoop = true;
HashMap<String, dObject> context = new HashMap<String, dObject>();
context.put("message", new Element(DenizenCore.getImplementation().cleanseLogString(s)));
List<String> Determinations = OldEventManager.doEvents(Arrays.asList("console output"), // TODO: ScriptEvent
DenizenCore.getImplementation().getEmptyScriptEntryData(), context);
for (String str : Determinations) {
if (str.equalsIgnoreCase("cancelled")) {
antiLoop = false;
return;
}
}
super.print(s);
antiLoop = false;
}

private boolean antiLoop = false;

public void redirectOutput() {
if (redirected) {
return;
Expand Down

0 comments on commit 6c5b763

Please sign in to comment.