8
8
"strings"
9
9
"testing"
10
10
11
+ "code.gitea.io/gitea/modules/log"
11
12
"code.gitea.io/gitea/modules/markup"
12
13
. "code.gitea.io/gitea/modules/markup/markdown"
13
14
"code.gitea.io/gitea/modules/setting"
@@ -94,10 +95,11 @@ func TestRender_Images(t *testing.T) {
94
95
title := "Train"
95
96
href := "https://gitea.io"
96
97
result := util .URLJoin (AppSubURL , url )
98
+ // hint: With Markdown v2.5.2, there is a new syntax: [link](URL){:target="_blank"} , but we do not support it now
97
99
98
100
test (
99
101
"" ,
100
- `<p><a href="` + result + `" rel="nofollow"><img src="` + result + `" alt="` + title + `"/></a></p>` )
102
+ `<p><a href="` + result + `" target="_blank" rel="nofollow noopener "><img src="` + result + `" alt="` + title + `"/></a></p>` )
101
103
102
104
test (
103
105
"[[" + title + "|" + url + "]]" ,
@@ -109,7 +111,7 @@ func TestRender_Images(t *testing.T) {
109
111
url = "/../../.images/src/02/train.jpg"
110
112
test (
111
113
"" ,
112
- `<p><a href="` + result + `" rel="nofollow"><img src="` + result + `" alt="` + title + `"/></a></p>` )
114
+ `<p><a href="` + result + `" target="_blank" rel="nofollow noopener "><img src="` + result + `" alt="` + title + `"/></a></p>` )
113
115
114
116
test (
115
117
"[[" + title + "|" + url + "]]" ,
@@ -373,6 +375,7 @@ func TestMarkdownRenderRaw(t *testing.T) {
373
375
}
374
376
375
377
for _ , testcase := range testcases {
378
+ log .Info ("Test markdown render error with fuzzy data: %x, the following errors can be recovered" , testcase )
376
379
_ , err := RenderRawString (& markup.RenderContext {}, string (testcase ))
377
380
assert .NoError (t , err )
378
381
}
@@ -382,8 +385,8 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
382
385
testcase := `
383
386

384
387
`
385
- expected := `<p><a href="/image1" rel="nofollow"><img src="/image1" alt="image1"></a><br>
386
- <a href="/image2" rel="nofollow"><img src="/image2" alt="image2"></a></p>
388
+ expected := `<p><a href="/image1" target="_blank" rel="nofollow noopener "><img src="/image1" alt="image1"></a><br>
389
+ <a href="/image2" target="_blank" rel="nofollow noopener "><img src="/image2" alt="image2"></a></p>
387
390
`
388
391
res , err := RenderRawString (& markup.RenderContext {}, testcase )
389
392
assert .NoError (t , err )
0 commit comments