Repository navigation
fix(markup): recognize issue references next to CJK punctuation - #40097
Conversation
References like "修复 go-gitea#1。" or "(go-gitea#2)" were neither rendered as links nor picked up as cross references or closing keywords, because the patterns only accepted ASCII delimiters around the reference. Assisted-by: Claude Code:claude-opus-5-5
Build the delimiter class from all non-ASCII \p{P} characters, so quotes
like “go-gitea#4” and other full-width punctuation are covered too. ASCII
punctuation keeps its existing rules ("/home/gitea/go-gitea#1234" is still not
a reference).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Why not simply use |
|
Plain |
OK, but the current implement is too complicated. I guess the best approach is like this: keep the regexp as simple as possible, then use our own code to check the surrounding bytes. This approach should be flexible enough and clear enough. |
…code
The patterns now accept any non-ASCII character next to a reference, and
validReferenceBoundaries checks it: punctuation or a space is fine
("修复 go-gitea#1。", "(go-gitea#2)"), a letter is not ("修复go-gitea#1"). This replaces the
generated character class.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Makes sense, simplified it: the patterns now just accept any non-ASCII character next to the reference, and a small |
* origin/main: (92 commits) feat(release): allow setting a release as the latest (go-gitea#40214) fix(repo): reject unparsable required approvals in branch protection (go-gitea#40213) ci: update giteabot to v1.5.1, label conflict-free backports (go-gitea#40247) fix(pull): enforce user blocks on pull request reviews (go-gitea#40194) feat(auth)!: remove support for obsolete OpenID 2.0 draft (go-gitea#40231) enhance(codeowners): support section / glob / file view display / skip review request (go-gitea#40243) fix: upgrade Alpine base packages in Docker images (go-gitea#40252) fix(deps): update module github.com/andybalholm/brotli to v1.2.7 [security] (go-gitea#40246) fix(perm): keep read access for restricted collaborators on public repos (go-gitea#40234) fix(build): pass `#` test patterns to `go test -run` unchanged (go-gitea#39977) perf: reduce git processes and queries on pull request view (go-gitea#40224) fix(dump): --file extension is ignored when --type is not set (go-gitea#40235) enhance: enable `DEFAULT_DELETE_BRANCH_AFTER_MERGE` by default for new repos (go-gitea#39975) fix(packages): return empty Chef dependencies instead of null (go-gitea#40237) fix(migrations): Do not fail Bitbucket Server migration when pull request activities cannot be loaded (go-gitea#40205) chore(deps): update go.yaml.in/yaml/v4 to v4.0.0 (go-gitea#40222) [skip ci] Updated translations via Crowdin fix: fix missing accessible name on static Fomantic combobox dropdowns (go-gitea#40163) fix(web): build issue popup request from parsed link (go-gitea#40207) fix(web): inline the site manifest (go-gitea#40198) ...
…II characters GitHub links a reference after any non-ASCII character and before anything but a Unicode word character, so "修复go-gitea#1" and "go-gitea#1~go-gitea#5" are references there too. The word character set is now shared with heading anchors. Assisted-by: Claude Code:claude-opus-5-5
The renderer and the cross reference finder repeated the same search, including trailing-space handling that can never apply since the reference itself contains no whitespace. Assisted-by: Claude Code:claude-opus-5-5
…search A mention never contains whitespace, so spaceTrimmedPattern never matched and the search position always advanced to the mention's end. Assisted-by: Claude Code:claude-opus-5-5
|
Pushed these changes and merged
Written by Claude (Opus 5.5). |
* origin/main: (44 commits) fix(markup): recognize issue references next to CJK punctuation (go-gitea#40097) fix: add missing checks to several handlers and services (go-gitea#40120) fix(api): honor branch protection force push and allowlist options on create and edit (go-gitea#39990) fix(repo): mark repository as non-empty before git push returns (go-gitea#40102) [skip ci] Updated translations via Crowdin fix(web): handle TypeCastError when building form validation messages (go-gitea#40212) fix: stop discarding file close and test setup errors (go-gitea#39987) test(e2e): retry clipboard reads rejected by Firefox (go-gitea#40155) refactor: remove duplicated and dead Go code (go-gitea#40244) feat(release): allow setting a release as the latest (go-gitea#40214) fix(repo): reject unparsable required approvals in branch protection (go-gitea#40213) ci: update giteabot to v1.5.1, label conflict-free backports (go-gitea#40247) fix(pull): enforce user blocks on pull request reviews (go-gitea#40194) feat(auth)!: remove support for obsolete OpenID 2.0 draft (go-gitea#40231) enhance(codeowners): support section / glob / file view display / skip review request (go-gitea#40243) fix: upgrade Alpine base packages in Docker images (go-gitea#40252) fix(deps): update module github.com/andybalholm/brotli to v1.2.7 [security] (go-gitea#40246) fix(perm): keep read access for restricted collaborators on public repos (go-gitea#40234) fix(build): pass `#` test patterns to `go test -run` unchanged (go-gitea#39977) perf: reduce git processes and queries on pull request view (go-gitea#40224) ...
| // issueNumericPattern matches string that references to a numeric issue, e.g. #1287 | ||
| issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\")([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$)`) | ||
| // TODO: REFERENCE-REGEXP-PATTERN: findValidReferenceIndex checks a non-ASCII trailing character | ||
| issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\"|[^\x00-\x7f])([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$|[^\x00-\x7f])`) |
There was a problem hiding this comment.
refactor: lazy init global regexp variables - #40269
* origin/main: fix(org): enforce unique team names in the database (go-gitea#40228) fix: truncate strings on character boundaries (go-gitea#40267) feat(packages): add private Terraform module registry (go-gitea#38040) fix(markup): recognize issue references next to CJK punctuation (go-gitea#40097) fix: add missing checks to several handlers and services (go-gitea#40120) fix(api): honor branch protection force push and allowlist options on create and edit (go-gitea#39990) fix(repo): mark repository as non-empty before git push returns (go-gitea#40102) [skip ci] Updated translations via Crowdin fix(web): handle TypeCastError when building form validation messages (go-gitea#40212) fix: stop discarding file close and test setup errors (go-gitea#39987) test(e2e): retry clipboard reads rejected by Firefox (go-gitea#40155) refactor: remove duplicated and dead Go code (go-gitea#40244) feat(release): allow setting a release as the latest (go-gitea#40214) fix(repo): reject unparsable required approvals in branch protection (go-gitea#40213) ci: update giteabot to v1.5.1, label conflict-free backports (go-gitea#40247) fix(pull): enforce user blocks on pull request reviews (go-gitea#40194) feat(auth)!: remove support for obsolete OpenID 2.0 draft (go-gitea#40231) enhance(codeowners): support section / glob / file view display / skip review request (go-gitea#40243) fix: upgrade Alpine base packages in Docker images (go-gitea#40252) fix(deps): update module github.com/andybalholm/brotli to v1.2.7 [security] (go-gitea#40246) Assisted-by: Claude Code:claude-opus-5-5 # Conflicts: # services/release/release_test.go
* origin/main: (66 commits) chore: add report requirements (go-gitea#40262) refactor: lazy init global regexp variables (go-gitea#40269) fix(org): enforce unique team names in the database (go-gitea#40228) fix: truncate strings on character boundaries (go-gitea#40267) feat(packages): add private Terraform module registry (go-gitea#38040) fix(markup): recognize issue references next to CJK punctuation (go-gitea#40097) fix: add missing checks to several handlers and services (go-gitea#40120) fix(api): honor branch protection force push and allowlist options on create and edit (go-gitea#39990) fix(repo): mark repository as non-empty before git push returns (go-gitea#40102) [skip ci] Updated translations via Crowdin fix(web): handle TypeCastError when building form validation messages (go-gitea#40212) fix: stop discarding file close and test setup errors (go-gitea#39987) test(e2e): retry clipboard reads rejected by Firefox (go-gitea#40155) refactor: remove duplicated and dead Go code (go-gitea#40244) feat(release): allow setting a release as the latest (go-gitea#40214) fix(repo): reject unparsable required approvals in branch protection (go-gitea#40213) ci: update giteabot to v1.5.1, label conflict-free backports (go-gitea#40247) fix(pull): enforce user blocks on pull request reviews (go-gitea#40194) feat(auth)!: remove support for obsolete OpenID 2.0 draft (go-gitea#40231) enhance(codeowners): support section / glob / file view display / skip review request (go-gitea#40243) ... # Conflicts: # tests/e2e/webauthn.test.ts
* origin/main: (84 commits) fix(web): don't block README images with `REQUIRE_SIGNIN_VIEW = expensive` (go-gitea#40264) enhance(actions): create commit status for workflow_dispatch runs (go-gitea#39961) fix(repo): do not reuse pull mirror credentials for a new host (go-gitea#39991) chore: add report requirements (go-gitea#40262) refactor: lazy init global regexp variables (go-gitea#40269) fix(org): enforce unique team names in the database (go-gitea#40228) fix: truncate strings on character boundaries (go-gitea#40267) feat(packages): add private Terraform module registry (go-gitea#38040) fix(markup): recognize issue references next to CJK punctuation (go-gitea#40097) fix: add missing checks to several handlers and services (go-gitea#40120) fix(api): honor branch protection force push and allowlist options on create and edit (go-gitea#39990) fix(repo): mark repository as non-empty before git push returns (go-gitea#40102) [skip ci] Updated translations via Crowdin fix(web): handle TypeCastError when building form validation messages (go-gitea#40212) fix: stop discarding file close and test setup errors (go-gitea#39987) test(e2e): retry clipboard reads rejected by Firefox (go-gitea#40155) refactor: remove duplicated and dead Go code (go-gitea#40244) feat(release): allow setting a release as the latest (go-gitea#40214) fix(repo): reject unparsable required approvals in branch protection (go-gitea#40213) ci: update giteabot to v1.5.1, label conflict-free backports (go-gitea#40247) ...
…itea#40097) Issue references next to non-ASCII characters, common in Chinese and Japanese text, are ignored: `修复go-gitea#1`, `(go-gitea#2)` or `Closes go-gitea#3,` create no link or cross reference. Like on GitHub, any non-ASCII character may now precede `go-gitea#123`, `!123` or `owner/repo#123`, and anything but a word character may follow it. Dead trailing-space handling in the reference and mention search is removed. I used Claude Code to write this change. --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: wxiaoguang <[email protected]>

Issue references next to non-ASCII characters, common in Chinese and Japanese text, are ignored:
修复#1,(#2)orCloses #3,create no link or cross reference.Like on GitHub, any non-ASCII character may now precede
#123,!123orowner/repo#123, and anything but a word character may follow it. Dead trailing-space handling in the reference and mention search is removed.I used Claude Code to write this change.