Skip to content

Commit

Permalink
Remove optional minus sign in hex/bin/oct/dec number regexes
Browse files Browse the repository at this point in the history
Minus signs in front of these literals in code are handled elsewhere. Cases where this optional minus sign are present will always return in a `NumberFormatException` due to the substring calls not accounting for it. This only seems to affect `xml_ready()`, which calls the method directly.
Fixes errors in core by for example: `xml_read('<a>-0xFF</a>', 'a')`.
  • Loading branch information
Pieter12345 committed Nov 30, 2024
1 parent bf2a6fe commit cf2aa81
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/laytonsmith/core/Static.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,14 @@ public static void checkPlugin(String name, Target t) throws ConfigRuntimeExcept
/**
* Regex patterns
*/
private static final Pattern INVALID_HEX = Pattern.compile("-?0x[a-fA-F0-9]*[^a-fA-F0-9]+[a-fA-F0-9]*");
private static final Pattern VALID_HEX = Pattern.compile("-?0x[a-fA-F0-9]+");
private static final Pattern INVALID_BINARY = Pattern.compile("-?0b[01]*[^01]+[01]*");
private static final Pattern VALID_BINARY = Pattern.compile("-?0b[01]+");
private static final Pattern INVALID_OCTAL = Pattern.compile("-?0o[0-7]*[^0-7]+[0-7]*");
private static final Pattern VALID_OCTAL = Pattern.compile("-?0o[0-7]+");
private static final Pattern VALID_DECIMAL = Pattern.compile("-?0m[0-9]+");
private static final Pattern INVALID_DECIMAL = Pattern.compile("-?0m[0-9]*[^0-9]+[0-9]*");
private static final Pattern INVALID_HEX = Pattern.compile("0x[a-fA-F0-9]*[^a-fA-F0-9]+[a-fA-F0-9]*");
private static final Pattern VALID_HEX = Pattern.compile("0x[a-fA-F0-9]+");
private static final Pattern INVALID_BINARY = Pattern.compile("0b[01]*[^01]+[01]*");
private static final Pattern VALID_BINARY = Pattern.compile("0b[01]+");
private static final Pattern INVALID_OCTAL = Pattern.compile("0o[0-7]*[^0-7]+[0-7]*");
private static final Pattern VALID_OCTAL = Pattern.compile("0o[0-7]+");
private static final Pattern VALID_DECIMAL = Pattern.compile("0m[0-9]+");
private static final Pattern INVALID_DECIMAL = Pattern.compile("0m[0-9]*[^0-9]+[0-9]*");

/**
* Given a string input, creates and returns a Construct of the appropriate type. This takes into account that null,
Expand Down

0 comments on commit cf2aa81

Please sign in to comment.