This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String filterInput(String input, String type) { | |
switch (type) { | |
case "numeric": | |
return filterNumeric(input); | |
case "alphanumeric": | |
return filterAlphanumeric(input); | |
case "other": | |
return filterOther(input); | |
default: | |
throw new IllegalArgumentException("Invalid type specified."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void filterNullBytes(String input) { | |
byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8); | |
for (byte b : inputBytes) { | |
if (b == 0x00) { | |
throw new IllegalArgumentException("Input contains nullbyte character, which is not allowed."); | |
} | |
} | |
} |