gitea/modules
Gregorius Bima Kharisma Wicaksana 83527d3f8a
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Support closing keywords with URL references (#36221)
## Summary

This PR adds support for closing keywords (`closes`, `fixes`, `reopens`,
etc.) with full URL references in markdown links.

**Before:**
- `closes #123`  works
- `closes org/repo#123`  works  
- `Closes [this issue](https://gitea.io/user/repo/issues/123)`  didn't
work
- `Fixes [#456](https://gitea.io/org/project/issues/456)`  didn't work

**After:**
All of the above now work correctly.

## Problem

When users reference issues using full URLs in markdown links (e.g.,
`Closes [this issue](https://gitea.io/user/repo/issues/123)`), the
closing keywords were not detected. This was because the URL processing
code explicitly stated:

```go
// Note: closing/reopening keywords not supported with URLs
```

Both methods of writing the reference render the same in the UI, so
users expected the closing keywords to behave the same.

## Solution

The fix works by:
1. Passing the original (unstripped) content to
`findAllIssueReferencesBytes`
2. When processing URL links from markdown, finding the URL position in
the original content
3. For markdown links `[text](url)`, finding the opening bracket `[`
position
4. Using that position to detect closing keywords before the link

## Testing

Added test cases for:
- `Closes [this issue](url)` - single URL with closing keyword
- `This fixes [#456](url)` - keyword in middle of text
- `Reopens [PR](url)` - reopen keyword with pull request URL
- Multiple URLs where only one has a closing keyword

All existing tests continue to pass.

Fixes #27549
2025-12-27 09:05:24 -08:00
..
actions Limit reading bytes instead of ReadAll (#35928) 2025-11-12 19:44:49 +08:00
activitypub Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
analyze
assetfs use experimental go json v2 library (#35392) 2025-09-28 08:03:36 +00:00
auth Fix oauth2 session gob register (#36017) 2025-11-26 23:25:34 +08:00
avatar Fix various typos in codebase (#35480) 2025-09-13 10:34:43 -04:00
badge Add flat-square action badge style (#34062) 2025-04-01 09:42:10 +00:00
base Refactor ls-tree and git path related problems (#35858) 2025-11-05 17:48:38 +00:00
cache enforce explanation for necessary nolints and fix bugs (#34883) 2025-06-27 21:48:03 +08:00
cachegroup Cache GPG keys, emails and users when list commits (#34086) 2025-04-09 16:34:38 +00:00
charset Fix code highlighting on blame page (#36157) 2025-12-14 12:40:55 +02:00
commitstatus enforce nolint scope (#34851) 2025-06-27 07:59:55 +02:00
container
csv Disable Field count validation of CSV viewer (#35228) 2025-09-04 09:54:58 -07:00
dump Use github.com/mholt/archives replace github.com/mholt/archiver (#35390) 2025-09-01 19:40:12 +00:00
emoji Avoid emoji mismatch and allow to only enable chosen emojis (#35692) 2025-10-19 13:06:45 -07:00
eventsource
fileicon fix some file icon ui (#36078) 2025-12-04 19:47:23 +01:00
generate
git Fix panic when get editor config file (#36241) 2025-12-25 19:26:23 -08:00
gitrepo Move blame to gitrepo (#36161) 2025-12-16 16:14:14 -08:00
glob Replace gobwas/glob package (#35478) 2025-09-13 18:01:00 +00:00
globallock Upgrade golang to 1.25.1 and add descriptions for the swagger structs' fields (#35418) 2025-09-06 16:52:41 +00:00
graceful Fix shutdown waitgroup panic (#35676) 2025-10-25 00:02:58 -07:00
gtprof Add start time on perf trace because it seems some steps haven't been recorded. (#35282) 2025-08-18 15:17:19 +00:00
hcaptcha Mock external service in hcaptcha TestCaptcha (#35604) 2025-10-10 06:21:45 +02:00
highlight Fix code highlighting on blame page (#36157) 2025-12-14 12:40:55 +02:00
hostmatcher Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
htmlutil Improve labels-list rendering (#34846) 2025-06-27 23:12:25 +08:00
httpcache Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
httplib Fix bug when viewing the commit diff page with non-ANSI files (#36149) 2025-12-13 21:54:03 +08:00
indexer Enable bodyclose linter (#36168) 2025-12-16 14:08:43 +01:00
issue/template Limit reading bytes instead of ReadAll (#35928) 2025-11-12 19:44:49 +08:00
json Drop json-iterator dependency (#35544) 2025-09-28 22:30:28 +08:00
label Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
lfs Drop json-iterator dependency (#35544) 2025-09-28 22:30:28 +08:00
lfstransfer Fix missing Close when error occurs and abused connection pool (#35658) 2025-10-15 09:47:12 +00:00
log Address some CodeQL security concerns (#35572) 2025-10-04 01:21:26 +08:00
markup remove nolint (#36252) 2025-12-26 22:55:30 -08:00
mcaptcha
metrics Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
migration Use a migration test instead of a wrong test which populated the meta test repositories and fix a migration bug (#36160) 2025-12-17 12:00:07 -08:00
nosql
optional use experimental go json v2 library (#35392) 2025-09-28 08:03:36 +00:00
options Refactor embedded assets and drop unnecessary dependencies (#34692) 2025-06-12 03:59:33 +00:00
packages Fix various bugs (#36139) 2025-12-12 18:56:05 +00:00
paginator Only use prev and next buttons for pagination on user dashboard (#33981) 2025-03-23 19:52:43 +00:00
pprof
private Fix missing Close when error occurs and abused connection pool (#35658) 2025-10-15 09:47:12 +00:00
process
proxy Replace gobwas/glob package (#35478) 2025-09-13 18:01:00 +00:00
proxyprotocol Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
public Upgrade gopls to v0.19.0, add make fix (#34772) 2025-06-18 19:30:40 +00:00
queue Fix various typos in codebase (#35480) 2025-09-13 10:34:43 -04:00
recaptcha
references Support closing keywords with URL references (#36221) 2025-12-27 09:05:24 -08:00
regexplru Enable testifylint rules (#34075) 2025-03-31 01:53:48 -04:00
repository Move commit related functions to gitrepo package (#35600) 2025-12-05 00:20:23 +00:00
reqctx Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
secret
session Add proper error message if session provider can not be created (#35520) 2025-09-28 12:24:19 +00:00
setting Replace CSRF cookie with CrossOriginProtection (#36183) 2025-12-25 12:33:34 +02:00
sitemap
ssh Update x/crypto package and make builtin SSH use default parameters (#34667) 2025-06-09 19:51:02 +00:00
storage Allow to display embed images/pdfs when SERVE_DIRECT was enabled on MinIO storage (#35882) 2025-11-09 21:31:25 -08:00
structs Support updating branch via API (#35951) 2025-12-10 19:23:26 +00:00
svg Support selecting theme on the footer (#35741) 2025-10-28 18:25:00 +08:00
system Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
tailmsg
tempdir Address some CodeQL security concerns (#35572) 2025-10-04 01:21:26 +08:00
templates Bump golangci-lint to 2.7.2, enable modernize stringsbuilder (#36180) 2025-12-17 20:50:53 +00:00
test Validate hex colors when creating/editing labels (#34623) 2025-06-07 11:25:08 +03:00
testlogger Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
timeutil Refactor embedded assets and drop unnecessary dependencies (#34692) 2025-06-12 03:59:33 +00:00
translation Use flatten translation keys (#36225) 2025-12-25 12:51:33 -08:00
turnstile
typesniffer Fix various typos in codebase (#35480) 2025-09-13 10:34:43 -04:00
updatechecker Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
uri
user
util Limit reading bytes instead of ReadAll (#35928) 2025-11-12 19:44:49 +08:00
validation update golangci-lint to v2.7.0 (#36079) 2025-12-04 09:06:44 +00:00
web Make Golang correctly delete temp files during uploading (#36128) 2025-12-11 19:59:42 +01:00
webhook Add workflow_run api + webhook (#33964) 2025-06-20 20:14:00 +08:00
zstd Refactor embedded assets and drop unnecessary dependencies (#34692) 2025-06-12 03:59:33 +00:00