From b33b110e4e34c2c6d980ec83e961ddfabcb9edfc Mon Sep 17 00:00:00 2001 From: Matteo Bitussi Date: Tue, 12 Dec 2023 10:47:05 +0100 Subject: [PATCH] fix: bug in url-decode and session ops parsing --- tool/src/main/java/migt/Check.java | 2 +- tool/src/main/java/migt/Operation.java | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tool/src/main/java/migt/Check.java b/tool/src/main/java/migt/Check.java index 90b077d..37e3e87 100644 --- a/tool/src/main/java/migt/Check.java +++ b/tool/src/main/java/migt/Check.java @@ -323,7 +323,7 @@ private String url_decode(String string) { try { string = URLDecoder.decode(string, StandardCharsets.UTF_8); } catch (IllegalArgumentException e) { - throw new RuntimeException("Failed URL-decode in check: " + e); + System.err.println("Failed URL-decode in check: " + e); } } return string; diff --git a/tool/src/main/java/migt/Operation.java b/tool/src/main/java/migt/Operation.java index 33c7221..22f82cc 100644 --- a/tool/src/main/java/migt/Operation.java +++ b/tool/src/main/java/migt/Operation.java @@ -67,13 +67,6 @@ public Operation(JSONObject operation_json, String session = operation_json.getString("session"); String action = operation_json.getString("action"); - List lsop = SessionOperation.parseFromJson(operation_json); - if (lsop != null) { - for (SessionOperation sop : lsop) { - session_operations.add(sop); - } - } - setSession(session); setSessionAction(action); isSessionOp = true; @@ -138,6 +131,16 @@ public Operation(JSONObject operation_json, } } + // Session Operations + if (operation_json.has("session operations")) { + List session_ops = SessionOperation.parseFromJson(operation_json); + if (session_ops != null) { + for (SessionOperation sop : session_ops) { + session_operations.add(sop); + } + } + } + // Edit operations if (operation_json.has("edits")) { editOperations = Tools.parseEditsFromJSON(operation_json.getJSONArray("edits")); @@ -242,7 +245,7 @@ public void setDecodeOperations(List decodeOperations) { * * @return An array of Object elements, the first is the edited operation, the second is the updated variables */ - public List executeSessionOps(Test t, + public List executeSessionOps(Test t, //TODO add this to the input api of Operation List vars) throws ParsingException { List updated_vars = vars; for (SessionOperation sop : this.session_operations) { @@ -458,6 +461,10 @@ public void execute() { executeChecks(this, api.vars); if (!applicable | !result) return; + // TODO: move this here instead of Execute Actives + //executeSessionOps(, api.vars); + //if (!applicable | !result) + // return; } catch (ParsingException | PatternSyntaxException e) { applicable = false;