Skip to content

Commit

Permalink
fix: bug in url-decode and session ops parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattebit committed Dec 12, 2023
1 parent 724b954 commit b33b110
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tool/src/main/java/migt/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 15 additions & 8 deletions tool/src/main/java/migt/Operation.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ public Operation(JSONObject operation_json,
String session = operation_json.getString("session");
String action = operation_json.getString("action");

List<SessionOperation> lsop = SessionOperation.parseFromJson(operation_json);
if (lsop != null) {
for (SessionOperation sop : lsop) {
session_operations.add(sop);
}
}

setSession(session);
setSessionAction(action);
isSessionOp = true;
Expand Down Expand Up @@ -138,6 +131,16 @@ public Operation(JSONObject operation_json,
}
}

// Session Operations
if (operation_json.has("session operations")) {
List<SessionOperation> 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"));
Expand Down Expand Up @@ -242,7 +245,7 @@ public void setDecodeOperations(List<DecodeOperation> decodeOperations) {
*
* @return An array of Object elements, the first is the edited operation, the second is the updated variables
*/
public List<Var> executeSessionOps(Test t,
public List<Var> executeSessionOps(Test t, //TODO add this to the input api of Operation
List<Var> vars) throws ParsingException {
List<Var> updated_vars = vars;
for (SessionOperation sop : this.session_operations) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b33b110

Please sign in to comment.