URLs to issues/pull-requests for repos or users with dash in the name are not linked correctly #8611

Closed
opened 2025-11-02 08:12:24 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @rtpt-alexanderneumann on GitHub (Feb 25, 2022).

Gitea Version

1.16.2

Git Version

2.30.2

Operating System

Debian 11

How are you running Gitea?

I'm using the released version of Gitea downloaded from GitHub as a systemd service. The same issue reproduces on https://try.gitea.io

Database

SQLite

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

Description

Full URLs to issues and pull requests are not correctly linked and there is no hover preview when the owner's name or the repository name contains a dash. For example, create the repos firstrepo and second-repo on the demo instance, create an issue in each of them and then submit the following text as a new issue:

 * https://try.gitea.io/username/firstrepo/issues/1
 * https://try.gitea.io/username/second-repo/issues/1

It is rendered as:

 * username/firstrepo#1
 * https://try.gitea.io/username/second-repo/issues/1

Screenshots

screenshot1
screenshot2

Originally created by @rtpt-alexanderneumann on GitHub (Feb 25, 2022). ### Gitea Version 1.16.2 ### Git Version 2.30.2 ### Operating System Debian 11 ### How are you running Gitea? I'm using the released version of Gitea downloaded from GitHub as a systemd service. The same issue reproduces on https://try.gitea.io ### Database SQLite ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist - ### Description Full URLs to issues and pull requests are not correctly linked and there is no hover preview when the owner's name or the repository name contains a dash. For example, create the repos `firstrepo` and `second-repo` on the demo instance, create an issue in each of them and then submit the following text as a new issue: ``` * https://try.gitea.io/username/firstrepo/issues/1 * https://try.gitea.io/username/second-repo/issues/1 ``` It is rendered as: ``` * username/firstrepo#1 * https://try.gitea.io/username/second-repo/issues/1 ``` ### Screenshots ![screenshot1](https://user-images.githubusercontent.com/62751754/155679603-435a8a18-3bc0-48cf-8e43-2a74c86689aa.png) ![screenshot2](https://user-images.githubusercontent.com/62751754/155679611-39fd142a-f4e6-42bc-a5e0-623f43fa7bfd.png)
GiteaMirror added the type/bug label 2025-11-02 08:12:24 -06:00
Author
Owner

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022):

It looks like there's a mismatch between the set of characters of valid repo/usernames and the regexp used for matching full URLs. For the user/repo names the only reference I found is here, but it does not match upper case characters:

e4ef61ee0f/modules/references/references.go (L25)

The regex used to match full URLs, which uses \w+ here:

e4ef61ee0f/modules/markup/html.go (L101-L103)

I propose to extend the regex from \w+ to [\w_.-]+ and will open a PR shortly. If there is a better way (like a central regex that we could reference instead) please let me know!

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022): It looks like there's a mismatch between the set of characters of valid repo/usernames and the regexp used for matching full URLs. For the user/repo names the only reference I found is here, but it does not match upper case characters: https://github.com/go-gitea/gitea/blob/e4ef61ee0fc319c5329dcb8e6cd961bb297730d1/modules/references/references.go#L25 The regex used to match full URLs, which uses `\w+` here: https://github.com/go-gitea/gitea/blob/e4ef61ee0fc319c5329dcb8e6cd961bb297730d1/modules/markup/html.go#L101-L103 I propose to extend the regex from `\w+` to `[\w_.-]+` and will open a PR shortly. If there is a better way (like a central regex that we could reference instead) please let me know!
Author
Owner

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022):

@KN4CK3R mentioned in #18890 that a dot in a character list (within []) still matches any character, so probably the regexp in references.go is wrong as well and should be corrected to ^[a-z0-9_\.-]+$. Is that correct? Shall I create another PR?

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022): @KN4CK3R mentioned in #18890 that a dot in a character list (within `[]`) still matches any character, so probably the regexp in `references.go` is wrong as well and should be corrected to `^[a-z0-9_\.-]+$`. Is that correct? Shall I create another PR?
Author
Owner

@KN4CK3R commented on GitHub (Feb 25, 2022):

No, it's ok without escaping. I was wrong.

@KN4CK3R commented on GitHub (Feb 25, 2022): No, it's ok without escaping. I was wrong.
Author
Owner

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022):

Ok, thanks for the feedback. I used a wrong test case first and thought you were right...

@rtpt-alexanderneumann commented on GitHub (Feb 25, 2022): Ok, thanks for the feedback. I used a wrong test case first and thought you were right...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8611