Skip to content

Commit cf2aa81

Browse files
committed
Remove optional minus sign in hex/bin/oct/dec number regexes
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')`.
1 parent bf2a6fe commit cf2aa81

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,14 @@ public static void checkPlugin(String name, Target t) throws ConfigRuntimeExcept
537537
/**
538538
* Regex patterns
539539
*/
540-
private static final Pattern INVALID_HEX = Pattern.compile("-?0x[a-fA-F0-9]*[^a-fA-F0-9]+[a-fA-F0-9]*");
541-
private static final Pattern VALID_HEX = Pattern.compile("-?0x[a-fA-F0-9]+");
542-
private static final Pattern INVALID_BINARY = Pattern.compile("-?0b[01]*[^01]+[01]*");
543-
private static final Pattern VALID_BINARY = Pattern.compile("-?0b[01]+");
544-
private static final Pattern INVALID_OCTAL = Pattern.compile("-?0o[0-7]*[^0-7]+[0-7]*");
545-
private static final Pattern VALID_OCTAL = Pattern.compile("-?0o[0-7]+");
546-
private static final Pattern VALID_DECIMAL = Pattern.compile("-?0m[0-9]+");
547-
private static final Pattern INVALID_DECIMAL = Pattern.compile("-?0m[0-9]*[^0-9]+[0-9]*");
540+
private static final Pattern INVALID_HEX = Pattern.compile("0x[a-fA-F0-9]*[^a-fA-F0-9]+[a-fA-F0-9]*");
541+
private static final Pattern VALID_HEX = Pattern.compile("0x[a-fA-F0-9]+");
542+
private static final Pattern INVALID_BINARY = Pattern.compile("0b[01]*[^01]+[01]*");
543+
private static final Pattern VALID_BINARY = Pattern.compile("0b[01]+");
544+
private static final Pattern INVALID_OCTAL = Pattern.compile("0o[0-7]*[^0-7]+[0-7]*");
545+
private static final Pattern VALID_OCTAL = Pattern.compile("0o[0-7]+");
546+
private static final Pattern VALID_DECIMAL = Pattern.compile("0m[0-9]+");
547+
private static final Pattern INVALID_DECIMAL = Pattern.compile("0m[0-9]*[^0-9]+[0-9]*");
548548

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

0 commit comments

Comments
 (0)