88 "strings"
99 "testing"
1010
11+ "code.gitea.io/gitea/modules/log"
1112 "code.gitea.io/gitea/modules/markup"
1213 . "code.gitea.io/gitea/modules/markup/markdown"
1314 "code.gitea.io/gitea/modules/setting"
@@ -94,10 +95,11 @@ func TestRender_Images(t *testing.T) {
9495 title := "Train"
9596 href := "https://gitea.io"
9697 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
9799
98100 test (
99101 "" ,
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>` )
101103
102104 test (
103105 "[[" + title + "|" + url + "]]" ,
@@ -109,7 +111,7 @@ func TestRender_Images(t *testing.T) {
109111 url = "/../../.images/src/02/train.jpg"
110112 test (
111113 "" ,
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>` )
113115
114116 test (
115117 "[[" + title + "|" + url + "]]" ,
@@ -373,6 +375,7 @@ func TestMarkdownRenderRaw(t *testing.T) {
373375 }
374376
375377 for _ , testcase := range testcases {
378+ log .Info ("Test markdown render error with fuzzy data: %x, the following errors can be recovered" , testcase )
376379 _ , err := RenderRawString (& markup.RenderContext {}, string (testcase ))
377380 assert .NoError (t , err )
378381 }
@@ -382,8 +385,8 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
382385 testcase := `
383386
384387`
385- expected := `<p><a href="https://github.com/image1" rel="nofollow"><img src="https://github.com/image1" alt="image1"></a><br>
386- <a href="https://github.com/image2" rel="nofollow"><img src="https://github.com/image2" alt="image2"></a></p>
388+ expected := `<p><a href="https://github.com/image1" target="_blank" rel="nofollow noopener "><img src="https://github.com/image1" alt="image1"></a><br>
389+ <a href="https://github.com/image2" target="_blank" rel="nofollow noopener "><img src="https://github.com/image2" alt="image2"></a></p>
387390`
388391 res , err := RenderRawString (& markup.RenderContext {}, testcase )
389392 assert .NoError (t , err )
0 commit comments