Skip to content

Instantly share code, notes, and snippets.

View 0x4380's full-sized avatar
⚠️

Timur Nebesniy 0x4380

⚠️
View GitHub Profile
@0x4380
0x4380 / filterInput.java
Created February 7, 2023 13:47
filterInput
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.");
@0x4380
0x4380 / filterNullByte.java
Last active February 7, 2023 13:48
Java function to filter nullbytes
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.");
}
}
}