mirror of
https://github.com/go-gitea/gitea.git
synced 2026-12-01 19:16:04 +01:00
Several markup processors stopped scanning a text node after skipping one match. An external issue or code preview URL hid later local ones, an SSH remote like `git@host:org/repo.git` hid a later email address, a short link with a disallowed scheme hid later short links, and a text node ending in an ellipsis left all its URLs unlinked. The processors now continue past skipped matches. Only a URL in the last word of a text node ending in an ellipsis is treated as truncated. Fixes: https://github.com/go-gitea/gitea/issues/40505 Assisted-by: OpenCode:gemini-4-neon Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: silverwind <me@silverwind.io>
24 lines
696 B
Go
24 lines
696 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package markup
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dev/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestShortLinkProcessor(t *testing.T) {
|
|
test := func(input, expected string) {
|
|
sb := new(strings.Builder)
|
|
err := postProcess(NewTestRenderContext("/base"), []processor{shortLinkProcessor}, strings.NewReader(input), sb)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, test.NormalizeHTMLSpaces(expected), test.NormalizeHTMLSpaces(sb.String()))
|
|
}
|
|
test("[[name=foo|link=javascript:bar]] and [[name=ok|link=./link]]", `[[name=foo|link=javascript:bar]] and <a href="/base/link">ok</a>`)
|
|
}
|