Skip to content

Conversation

rtpt-alexanderneumann
Copy link
Contributor

@rtpt-alexanderneumann rtpt-alexanderneumann commented Feb 25, 2022

This PR extends the regex which is used to match full URLs in all texts to issues/PRs in repos hosted on Gitea so that user/repo names with dashes, dots or underscores (e.g. http://localhost:5000/some-user/reponame) are matched correctly. The first commit introduces tests that fail, the second commit extends the regex from \w+ to [\w_.-]+.

I haven't found a central place where the user/repo name validation is performed. If there is a better way to do this please let me know. Thanks!

Closes #18888

This commit adds tests for full URLs referencing repos names and user
names containing a dash.
@rtpt-alexanderneumann rtpt-alexanderneumann changed the title Fix reference repo dash Correctly link URLs to users/repos with dashes, dots or underscores Feb 25, 2022
@lunny lunny added backport/v1.16 type/bug skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Feb 25, 2022
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 25, 2022
@KN4CK3R
Copy link
Member

KN4CK3R commented Feb 25, 2022

Sorry, mistake on my side. Inside [ ] the dot is simply a dot and does not need to be escaped.

@rtpt-alexanderneumann
Copy link
Contributor Author

Ah, no worries, my test case was wrong as well 😝

I'll revert it.

@rtpt-alexanderneumann
Copy link
Contributor Author

For the reference, here's my (now correct) simple test: https://go.dev/play/p/b4owdEOFUt3

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 25, 2022
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 25, 2022
@techknowlogick techknowlogick added this to the 1.17.0 milestone Feb 25, 2022
@6543
Copy link
Member

6543 commented Feb 25, 2022

🤖

@6543 6543 merged commit fd273b0 into go-gitea:main Feb 25, 2022
@lunny
Copy link
Member

lunny commented Feb 26, 2022

Please send backport

silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 26, 2022
…o-gitea#18890)

* Add tests for references with dashes

This commit adds tests for full URLs referencing repos names and user
names containing a dash.

* Extend regex to match URLs to repos/users with dashes
@silverwind
Copy link
Member

Backport in #18908.

@Gusted
Copy link
Contributor

Gusted commented Feb 26, 2022

Why is this marked to skip changelog?

@lunny
Copy link
Member

lunny commented Feb 26, 2022

@Gusted The fix will be in v1.16.3's changelog, so it should not be in 1.17's changelog.

6543 pushed a commit that referenced this pull request Feb 26, 2022
…18890) (#18908)

* Add tests for references with dashes

This commit adds tests for full URLs referencing repos names and user
names containing a dash.

* Extend regex to match URLs to repos/users with dashes

Co-authored-by: Alexander Neumann <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 27, 2022
* giteaofficial/main:
  Fix page and missing return on unadopted repos API (go-gitea#18848)
  [skip ci] Updated licenses and gitignores
  Allow adminstrator teams members to see other teams (go-gitea#18918)
  Update nginx reverse proxy docs (go-gitea#18922)
  Don't treat BOM escape sequence as hidden character. (go-gitea#18909)
  Remove CodeMirror dependencies (go-gitea#18911)
  Uncapitalize errors (go-gitea#18915)
  Disable service worker by default (go-gitea#18914)
  Set is_empty in fixtures (go-gitea#18869)
  Don't update email for organisation (go-gitea#18905)
  Correctly link URLs to users/repos with dashes, dots or underscores (go-gitea#18890)
  Set is_private in fixtures. (go-gitea#18868)
  Fix team management UI (go-gitea#18886)
  Update JS dependencies (go-gitea#18898)
  Fix migration v210 (go-gitea#18892)
  migrations: add test for importing pull requests in gitea uploader (go-gitea#18752)
@zeripath zeripath added the backport/done All backports for this PR have been created label Mar 9, 2022
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
…o-gitea#18890)

* Add tests for references with dashes

This commit adds tests for full URLs referencing repos names and user
names containing a dash.

* Extend regex to match URLs to repos/users with dashes
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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