@Test public void validateNameReturnsFalseOnInvalidNames() throws Exception { assertThat(validName("hello!")).isFalse(); assertThat(validName("hello world")).isFalse(); assertThat(validName("$$ bill yall")).isFalse(); assertThat(validName("blah/../../../etc/passwd")).isFalse(); assertThat(validName("bad/I-am-secret.yml")).isFalse(); assertThat(validName(".almostvalid")).isFalse(); assertThat(validName("bad\tI-am-secret.yml")).isFalse(); List<String> specialCharacters = Arrays.asList("&", "|", "(", ")", "[", "]", "{", "}", "^", ";", ",", "\\", "/", "<", ">", "\t", "\n", "\r", "`", "'", "\"", "?", "#", "%", "*", "+", "=", "\0", "\u0002", "\000"); for (String name : specialCharacters) { assertFalse("Failed character: \"" + name + '"', validName(name)); } }
public static boolean validName(String name) { return !name.startsWith(".") && name.matches(VALID_NAME_PATTERN); }
Utilities { public static boolean validName(String name) { return !name.startsWith(".") && name.matches(VALID_NAME_PATTERN); } }
Utilities { public static boolean validName(String name) { return !name.startsWith(".") && name.matches(VALID_NAME_PATTERN); }  }
Utilities { public static boolean validName(String name) { return !name.startsWith(".") && name.matches(VALID_NAME_PATTERN); }  static boolean validName(String name); }
Utilities { public static boolean validName(String name) { return !name.startsWith(".") && name.matches(VALID_NAME_PATTERN); }  static boolean validName(String name); static final String VALID_NAME_PATTERN; }