@Test public void testValidateImageName() { assertValid("xx.png"); assertValid("xx.svg"); assertValid("xx"); assertValid("xx.v1.png"); assertValid("xx_v1.png"); assertValid("xx-v1.png"); assertValid("dir/xx.png"); assertValid("dir assertInvalid("dir/../xx.png"); assertInvalid("../xx.png"); }
public static String validateImageName(String filename) { if (!VALID_LETTERS.matcher(filename).matches() || INVALID_PARTS.matcher(filename).matches()) { throw new IllegalArgumentException("invalid image name: " + filename); } return filename; }
InputSanitizer { public static String validateImageName(String filename) { if (!VALID_LETTERS.matcher(filename).matches() || INVALID_PARTS.matcher(filename).matches()) { throw new IllegalArgumentException("invalid image name: " + filename); } return filename; } }
InputSanitizer { public static String validateImageName(String filename) { if (!VALID_LETTERS.matcher(filename).matches() || INVALID_PARTS.matcher(filename).matches()) { throw new IllegalArgumentException("invalid image name: " + filename); } return filename; } private  InputSanitizer(); }
InputSanitizer { public static String validateImageName(String filename) { if (!VALID_LETTERS.matcher(filename).matches() || INVALID_PARTS.matcher(filename).matches()) { throw new IllegalArgumentException("invalid image name: " + filename); } return filename; } private  InputSanitizer(); static String validateImageName(String filename); }
InputSanitizer { public static String validateImageName(String filename) { if (!VALID_LETTERS.matcher(filename).matches() || INVALID_PARTS.matcher(filename).matches()) { throw new IllegalArgumentException("invalid image name: " + filename); } return filename; } private  InputSanitizer(); static String validateImageName(String filename);  }