Commits

Sebastian Sdorra committed ab5240a

repository names should not end with a slash

Comments (0)

Files changed (2)

scm-core/src/main/java/sonia/scm/util/ValidationUtil.java

   public static boolean isRepositoryNameValid(String name)
   {
     return Util.isNotEmpty(name) && name.matches(REGEX_REPOSITORYNAME)
-           &&!name.contains("..") &&!name.endsWith("/.") &&!name.endsWith(".");
+           &&!name.contains("..") &&!name.endsWith("/.") &&!name.endsWith(".")
+           &&!name.endsWith("/");
   }
 
   /**

scm-core/src/test/java/sonia/scm/util/ValidationUtilTest.java

     assertFalse(ValidationUtil.isRepositoryNameValid(".scm/plugins"));
     assertFalse(ValidationUtil.isRepositoryNameValid("scm/plugins/."));
     assertFalse(ValidationUtil.isRepositoryNameValid("scm/../plugins"));
+    assertFalse(ValidationUtil.isRepositoryNameValid("scm/main/"));
+    assertFalse(ValidationUtil.isRepositoryNameValid("/scm/main/"));
   }
 
   /**