Skip to content

Commit

Permalink
if command extra boolean validity error check
Browse files Browse the repository at this point in the history
let's see how many people were relying on this silently ignoring invalid values
  • Loading branch information
mcmonkey4eva committed Oct 16, 2021
1 parent 28c7f08 commit c56b1ef
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -284,14 +284,24 @@ public String toString() {
return "[ArgComp: " + argstemp + " res " + result + "]";
}

public static class ArgInternal {
public class ArgInternal {

boolean negative;

ObjectTag value;

boolean boolify() {
return negative != value.toString().equals("true");
String rawValue = value.toString();
if (CoreUtilities.equalsIgnoreCase(rawValue, "true")) {
return !negative;
}
else if (CoreUtilities.equalsIgnoreCase(rawValue, "false")) {
return negative;
}
else {
Debug.echoError(scriptEntry, "Invalid if comparison boolean '" + rawValue + "' - defaulting to false.");
return false;
}
}

@Override
Expand Down Expand Up @@ -567,7 +577,7 @@ else if (args.size() == 3) {
ObjectTag second = tagme(args.size() - 1).value;
boolean outcome = Comparable.compare(first, second, operator, negative, scriptEntry.context);
if (scriptEntry.dbCallShouldDebug()) {
Debug.echoDebug(scriptEntry, "Comparing " + first + (negative ? " not " : " ") + operator.name() + " " + second + (outcome ? " ... true" : " ... false"));
Debug.echoDebug(scriptEntry, "Comparing if " + first + (negative ? " not " : " ") + operator.name() + " " + second + " ... " + outcome);
}
return outcome;
}
Expand Down

0 comments on commit c56b1ef

Please sign in to comment.