Skip to content

The username format should be stricter #21640

Closed
@wolfogre

Description

@wolfogre

Description

The current username format check is

Username should contain only alphanumeric, dash ('-'), underscore ('_') and dot ('.') characters.

But I think it should be stricter, maybe

Username should contain only alphanumeric, dash ('-'), underscore ('_') and dot ('.') characters, and cannot begin or end with non-alphanumeric, consecutive non-alphanumerics are also not allowed.

What GitHub does:

Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.

You might think this is a suggestion, not a Bug Report, so let me show you the bug.

  1. Create a user named test..test;
  2. Create a repo with default README.md.
  3. Edit the file online and click "Commit Changes", not "Create a new branch".

I also think we can find the cause and fix the bug, but why not restrict the username format to avoid it?

image

Gitea Version

main@9b3e2c545

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Binary file.

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions