Commits

Sebastian Sdorra committed 579f60e

do not allow "/./" or "//" in repository names

Comments (0)

Files changed (3)

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

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

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

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

scm-webapp/src/main/webapp/resources/js/override/ext.form.vtypes.js

            && ! val.contains('..')
            && ! val.endsWith('/.') 
            && ! val.endsWith('/')
-           && ! val.endsWith('.');
+           && ! val.endsWith('.')
+           && ! val.contains('/./')
+           && ! val.contains('//');
   },
   
   repositoryNameText: 'The name of the repository is invalid.',