#5146 404 if repository name ends with ".git"
Opened by ponzipo. Modified

The UI allows the creation of new repositories with a name ending in ".git", but these repositories cannot be accessed, giving a 404 error. It's probably because the name interferes with the ".git" route that redirects to the same route without ".git".

How to reproduce: create a new repository called ".git"


Metadata Update from @wombelix:
- Issue assigned to wombelix

Behavior of other platforms if .git is part of the project/repo name

GitHub: remove all occurences of '.git' from the name and proceed with the creation, for example "test.git" just becomes automatically "test"
Gitlab: throws "The form contains the following errors"
          Project namespace path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'
          Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'
Codeberg (Gitea): throws "The pattern '*.git' is not allowed in a repository name."

Metadata Update from @wombelix:
- Issue set to the milestone: 5.13
- Issue tagged with: bug

Responding with an error message seem the better approach, silently removing .git from the name and proceed with the creation doesn't make the user aware about the fact that this suffix isn't allowed.

Possible Solution:

  • Check if name contains .git in https://pagure.io/pagure/blob/master/f/pagure/ui/app.py#_1041 and return error.

  • Define API Error Message in https://pagure.io/pagure/blob/master/f/pagure/api/init.py#_76.

  • Check if name contains .git in https://pagure.io/pagure/blob/master/f/pagure/api/project.py#_1350 and return error 400 with previous defined API Error Message.

  • Adjust unit tests in https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_api_project.py and https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_ui_app.py

Metadata Update from @wombelix:
- Issue set to the milestone: 6.0 (was: 5.13)

Metadata Update from @wombelix:
- Assignee reset

Metadata Update from @wombelix:
- Issue tagged with: easyfix

Metadata