improve validation of repository name

This commit is contained in:
Sebastian Sdorra
2012-05-10 18:53:56 +02:00
parent 945dbba396
commit bb3e417a58
2 changed files with 24 additions and 3 deletions

View File

@@ -52,10 +52,12 @@ public class ValidationUtil
private static final String REGEX_NAME = "^[A-z0-9\\.\\-_]+$";
/** Field description */
private static final String REGEX_REPOSITORYNAME = "^[A-z0-9\\.\\-_/]+$";
private static final String REGEX_REPOSITORYNAME =
"^[A-z0-9][A-z0-9\\.\\-_/]*$";
/** Field description */
private static final String REGEX_USERNAME = "^[A-z0-9\\.\\-_@]|[^ ]([A-z0-9\\.\\-_@ ]*[A-z0-9\\.\\-_@]|[^ ])?$";
private static final String REGEX_USERNAME =
"^[A-z0-9\\.\\-_@]|[^ ]([A-z0-9\\.\\-_@ ]*[A-z0-9\\.\\-_@]|[^ ])?$";
//~--- get methods ----------------------------------------------------------
@@ -139,7 +141,8 @@ public class ValidationUtil
*/
public static boolean isRepositoryNameValid(String name)
{
return Util.isNotEmpty(name) && name.matches(REGEX_REPOSITORYNAME);
return Util.isNotEmpty(name) && name.matches(REGEX_REPOSITORYNAME)
&&!name.contains("..") &&!name.endsWith("/.") &&!name.endsWith(".");
}
/**