From 50f60a69937db763145d433238ec66389e5974f2 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 5 Aug 2020 15:57:22 +0200 Subject: [PATCH 1/2] ".git" extension is not allowed on the end of the repository name since it confuses the git protocol --- CHANGELOG.md | 4 ++++ .../src/repos/components/form/repositoryValidation.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd1413127c..7d52e869d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Fixed +- Repository names may not end with ".git" ([#1277](https://github.com/scm-manager/scm-manager/pull/1277)) + ## [2.3.1] - 2020-08-04 ### Added - New api to resolve SCM-Manager root url ([#1276](https://github.com/scm-manager/scm-manager/pull/1276)) diff --git a/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.ts b/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.ts index 1b8c48f588..b9ff7f6adb 100644 --- a/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.ts +++ b/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.ts @@ -24,7 +24,7 @@ import { validation } from "@scm-manager/ui-components"; -const nameRegex = /(?!^\.\.$)(?!^\.$)(?!.*[\\\[\]])^[A-Za-z0-9\.][A-Za-z0-9\.\-_]*$/; +const nameRegex = /(?!^\.\.$)(?!^\.$)(?!.*[.]git$)(?!.*[\\\[\]])^[A-Za-z0-9\.][A-Za-z0-9\.\-_]*$/; export const isNameValid = (name: string) => { return nameRegex.test(name); From a47b3499527345e11dea5afdef748d77b31c7b23 Mon Sep 17 00:00:00 2001 From: Konstantin Schaper Date: Sun, 9 Aug 2020 23:30:31 +0200 Subject: [PATCH 2/2] add tests for name validation change --- .../src/repos/components/form/repositoryValidation.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.test.ts b/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.test.ts index 7f4139c7e1..b8e91c4c17 100644 --- a/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.test.ts +++ b/scm-ui/ui-webapp/src/repos/components/form/repositoryValidation.test.ts @@ -37,7 +37,7 @@ describe("repository name validation", () => { }); it("should allow same names as the backend", () => { - const validPaths = ["scm", "s", "sc", ".hiddenrepo", "b.", "...", "..c", "d..", "a..c"]; + const validPaths = ["scm", "scm.gitz", "s", "sc", ".hiddenrepo", "b.", "...", "..c", "d..", "a..c"]; validPaths.forEach(path => expect(validator.isNameValid(path)).toBe(true)); }); @@ -91,7 +91,8 @@ describe("repository name validation", () => { "a/..b", "scm/main", "scm/plugins/git-plugin", - "scm/plugins/git-plugin" + "scm/plugins/git-plugin", + "scm.git" ]; invalidPaths.forEach(path => expect(validator.isNameValid(path)).toBe(false));