You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

html_test.go 13 kB

Check commit message hashes before making links (#7713) * Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
5 years ago
Check commit message hashes before making links (#7713) * Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
5 years ago
Check commit message hashes before making links (#7713) * Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
5 years ago
Check commit message hashes before making links (#7713) * Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package markup_test
  5. import (
  6. "strings"
  7. "testing"
  8. . "code.gitea.io/gitea/modules/markup"
  9. "code.gitea.io/gitea/modules/markup/markdown"
  10. "code.gitea.io/gitea/modules/setting"
  11. "code.gitea.io/gitea/modules/util"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. var localMetas = map[string]string{
  15. "user": "gogits",
  16. "repo": "gogs",
  17. "repoPath": "../../integrations/gitea-repositories-meta/user13/repo11.git/",
  18. }
  19. func TestRender_Commits(t *testing.T) {
  20. setting.AppURL = AppURL
  21. setting.AppSubURL = AppSubURL
  22. test := func(input, expected string) {
  23. buffer := RenderString(".md", input, setting.AppSubURL, localMetas)
  24. assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
  25. }
  26. var sha = "65f1bf27bc3bf70f64657658635e66094edbcb4d"
  27. var commit = util.URLJoin(AppSubURL, "commit", sha)
  28. var subtree = util.URLJoin(commit, "src")
  29. var tree = strings.Replace(subtree, "/commit/", "/tree/", -1)
  30. test(sha, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
  31. test(sha[:7], `<p><a href="`+commit[:len(commit)-(40-7)]+`" rel="nofollow"><code>65f1bf2</code></a></p>`)
  32. test(sha[:39], `<p><a href="`+commit[:len(commit)-(40-39)]+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
  33. test(commit, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
  34. test(tree, `<p><a href="`+tree+`" rel="nofollow"><code>65f1bf27bc/src</code></a></p>`)
  35. test("commit "+sha, `<p>commit <a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
  36. test("/home/gitea/"+sha, "<p>/home/gitea/"+sha+"</p>")
  37. test("deadbeef", `<p>deadbeef</p>`)
  38. test("d27ace93", `<p>d27ace93</p>`)
  39. }
  40. func TestRender_CrossReferences(t *testing.T) {
  41. setting.AppURL = AppURL
  42. setting.AppSubURL = AppSubURL
  43. test := func(input, expected string) {
  44. buffer := RenderString("a.md", input, setting.AppSubURL, localMetas)
  45. assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
  46. }
  47. test(
  48. "gogits/gogs#12345",
  49. `<p><a href="`+util.URLJoin(AppURL, "gogits", "gogs", "issues", "12345")+`" rel="nofollow">gogits/gogs#12345</a></p>`)
  50. test(
  51. "go-gitea/gitea#12345",
  52. `<p><a href="`+util.URLJoin(AppURL, "go-gitea", "gitea", "issues", "12345")+`" rel="nofollow">go-gitea/gitea#12345</a></p>`)
  53. test(
  54. "/home/gitea/go-gitea/gitea#12345",
  55. `<p>/home/gitea/go-gitea/gitea#12345</p>`)
  56. }
  57. func TestMisc_IsSameDomain(t *testing.T) {
  58. setting.AppURL = AppURL
  59. setting.AppSubURL = AppSubURL
  60. var sha = "b6dd6210eaebc915fd5be5579c58cce4da2e2579"
  61. var commit = util.URLJoin(AppSubURL, "commit", sha)
  62. assert.True(t, IsSameDomain(commit))
  63. assert.False(t, IsSameDomain("http://google.com/ncr"))
  64. assert.False(t, IsSameDomain("favicon.ico"))
  65. }
  66. func TestRender_links(t *testing.T) {
  67. setting.AppURL = AppURL
  68. setting.AppSubURL = AppSubURL
  69. test := func(input, expected string) {
  70. buffer := RenderString("a.md", input, setting.AppSubURL, nil)
  71. assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
  72. }
  73. // Text that should be turned into URL
  74. test(
  75. "https://www.example.com",
  76. `<p><a href="https://www.example.com" rel="nofollow">https://www.example.com</a></p>`)
  77. test(
  78. "http://www.example.com",
  79. `<p><a href="http://www.example.com" rel="nofollow">http://www.example.com</a></p>`)
  80. test(
  81. "https://example.com",
  82. `<p><a href="https://example.com" rel="nofollow">https://example.com</a></p>`)
  83. test(
  84. "http://example.com",
  85. `<p><a href="http://example.com" rel="nofollow">http://example.com</a></p>`)
  86. test(
  87. "http://foo.com/blah_blah",
  88. `<p><a href="http://foo.com/blah_blah" rel="nofollow">http://foo.com/blah_blah</a></p>`)
  89. test(
  90. "http://foo.com/blah_blah/",
  91. `<p><a href="http://foo.com/blah_blah/" rel="nofollow">http://foo.com/blah_blah/</a></p>`)
  92. test(
  93. "http://www.example.com/wpstyle/?p=364",
  94. `<p><a href="http://www.example.com/wpstyle/?p=364" rel="nofollow">http://www.example.com/wpstyle/?p=364</a></p>`)
  95. test(
  96. "https://www.example.com/foo/?bar=baz&inga=42&quux",
  97. `<p><a href="https://www.example.com/foo/?bar=baz&amp;inga=42&amp;quux" rel="nofollow">https://www.example.com/foo/?bar=baz&amp;inga=42&amp;quux</a></p>`)
  98. test(
  99. "http://142.42.1.1/",
  100. `<p><a href="http://142.42.1.1/" rel="nofollow">http://142.42.1.1/</a></p>`)
  101. test(
  102. "https://github.com/go-gitea/gitea/?p=aaa/bbb.html#ccc-ddd",
  103. `<p><a href="https://github.com/go-gitea/gitea/?p=aaa/bbb.html#ccc-ddd" rel="nofollow">https://github.com/go-gitea/gitea/?p=aaa/bbb.html#ccc-ddd</a></p>`)
  104. test(
  105. "https://en.wikipedia.org/wiki/URL_(disambiguation)",
  106. `<p><a href="https://en.wikipedia.org/wiki/URL_(disambiguation)" rel="nofollow">https://en.wikipedia.org/wiki/URL_(disambiguation)</a></p>`)
  107. test(
  108. "https://foo_bar.example.com/",
  109. `<p><a href="https://foo_bar.example.com/" rel="nofollow">https://foo_bar.example.com/</a></p>`)
  110. test(
  111. "https://stackoverflow.com/questions/2896191/what-is-go-used-fore",
  112. `<p><a href="https://stackoverflow.com/questions/2896191/what-is-go-used-fore" rel="nofollow">https://stackoverflow.com/questions/2896191/what-is-go-used-fore</a></p>`)
  113. test(
  114. "https://username:password@gitea.com",
  115. `<p><a href="https://username:password@gitea.com" rel="nofollow">https://username:password@gitea.com</a></p>`)
  116. // Test that should *not* be turned into URL
  117. test(
  118. "www.example.com",
  119. `<p>www.example.com</p>`)
  120. test(
  121. "example.com",
  122. `<p>example.com</p>`)
  123. test(
  124. "test.example.com",
  125. `<p>test.example.com</p>`)
  126. test(
  127. "http://",
  128. `<p>http://</p>`)
  129. test(
  130. "https://",
  131. `<p>https://</p>`)
  132. test(
  133. "://",
  134. `<p>://</p>`)
  135. test(
  136. "www",
  137. `<p>www</p>`)
  138. }
  139. func TestRender_email(t *testing.T) {
  140. setting.AppURL = AppURL
  141. setting.AppSubURL = AppSubURL
  142. test := func(input, expected string) {
  143. buffer := RenderString("a.md", input, setting.AppSubURL, nil)
  144. assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
  145. }
  146. // Text that should be turned into email link
  147. test(
  148. "info@gitea.com",
  149. `<p><a href="mailto:info@gitea.com" rel="nofollow">info@gitea.com</a></p>`)
  150. test(
  151. "(info@gitea.com)",
  152. `<p>(<a href="mailto:info@gitea.com" rel="nofollow">info@gitea.com</a>)</p>`)
  153. test(
  154. "[info@gitea.com]",
  155. `<p>[<a href="mailto:info@gitea.com" rel="nofollow">info@gitea.com</a>]</p>`)
  156. test(
  157. "info@gitea.com.",
  158. `<p><a href="mailto:info@gitea.com" rel="nofollow">info@gitea.com</a>.</p>`)
  159. test(
  160. "firstname+lastname@gitea.com",
  161. `<p><a href="mailto:firstname+lastname@gitea.com" rel="nofollow">firstname+lastname@gitea.com</a></p>`)
  162. test(
  163. "send email to info@gitea.co.uk.",
  164. `<p>send email to <a href="mailto:info@gitea.co.uk" rel="nofollow">info@gitea.co.uk</a>.</p>`)
  165. // Test that should *not* be turned into email links
  166. test(
  167. "\"info@gitea.com\"",
  168. `<p>“info@gitea.com”</p>`)
  169. test(
  170. "/home/gitea/mailstore/info@gitea/com",
  171. `<p>/home/gitea/mailstore/info@gitea/com</p>`)
  172. test(
  173. "git@try.gitea.io:go-gitea/gitea.git",
  174. `<p>git@try.gitea.io:go-gitea/gitea.git</p>`)
  175. test(
  176. "gitea@3",
  177. `<p>gitea@3</p>`)
  178. test(
  179. "gitea@gmail.c",
  180. `<p>gitea@gmail.c</p>`)
  181. test(
  182. "email@domain@domain.com",
  183. `<p>email@domain@domain.com</p>`)
  184. test(
  185. "email@domain..com",
  186. `<p>email@domain..com</p>`)
  187. }
  188. func TestRender_ShortLinks(t *testing.T) {
  189. setting.AppURL = AppURL
  190. setting.AppSubURL = AppSubURL
  191. tree := util.URLJoin(AppSubURL, "src", "master")
  192. test := func(input, expected, expectedWiki string) {
  193. buffer := markdown.RenderString(input, tree, nil)
  194. assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
  195. buffer = markdown.RenderWiki([]byte(input), setting.AppSubURL, localMetas)
  196. assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer))
  197. }
  198. rawtree := util.URLJoin(AppSubURL, "raw", "master")
  199. url := util.URLJoin(tree, "Link")
  200. otherURL := util.URLJoin(tree, "Other-Link")
  201. encodedURL := util.URLJoin(tree, "Link%3F")
  202. imgurl := util.URLJoin(rawtree, "Link.jpg")
  203. otherImgurl := util.URLJoin(rawtree, "Link+Other.jpg")
  204. encodedImgurl := util.URLJoin(rawtree, "Link+%23.jpg")
  205. notencodedImgurl := util.URLJoin(rawtree, "some", "path", "Link+#.jpg")
  206. urlWiki := util.URLJoin(AppSubURL, "wiki", "Link")
  207. otherURLWiki := util.URLJoin(AppSubURL, "wiki", "Other-Link")
  208. encodedURLWiki := util.URLJoin(AppSubURL, "wiki", "Link%3F")
  209. imgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "Link.jpg")
  210. otherImgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "Link+Other.jpg")
  211. encodedImgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "Link+%23.jpg")
  212. notencodedImgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "some", "path", "Link+#.jpg")
  213. favicon := "http://google.com/favicon.ico"
  214. test(
  215. "[[Link]]",
  216. `<p><a href="`+url+`" rel="nofollow">Link</a></p>`,
  217. `<p><a href="`+urlWiki+`" rel="nofollow">Link</a></p>`)
  218. test(
  219. "[[Link.jpg]]",
  220. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Link.jpg" alt="Link.jpg"/></a></p>`,
  221. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="Link.jpg" alt="Link.jpg"/></a></p>`)
  222. test(
  223. "[["+favicon+"]]",
  224. `<p><a href="`+favicon+`" rel="nofollow"><img src="`+favicon+`" title="favicon.ico"/></a></p>`,
  225. `<p><a href="`+favicon+`" rel="nofollow"><img src="`+favicon+`" title="favicon.ico"/></a></p>`)
  226. test(
  227. "[[Name|Link]]",
  228. `<p><a href="`+url+`" rel="nofollow">Name</a></p>`,
  229. `<p><a href="`+urlWiki+`" rel="nofollow">Name</a></p>`)
  230. test(
  231. "[[Name|Link.jpg]]",
  232. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Name" alt="Name"/></a></p>`,
  233. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="Name" alt="Name"/></a></p>`)
  234. test(
  235. "[[Name|Link.jpg|alt=AltName]]",
  236. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="AltName" alt="AltName"/></a></p>`,
  237. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="AltName" alt="AltName"/></a></p>`)
  238. test(
  239. "[[Name|Link.jpg|title=Title]]",
  240. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Title" alt="Title"/></a></p>`,
  241. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="Title" alt="Title"/></a></p>`)
  242. test(
  243. "[[Name|Link.jpg|alt=AltName|title=Title]]",
  244. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Title" alt="AltName"/></a></p>`,
  245. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="Title" alt="AltName"/></a></p>`)
  246. test(
  247. "[[Name|Link.jpg|alt=\"AltName\"|title='Title']]",
  248. `<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Title" alt="AltName"/></a></p>`,
  249. `<p><a href="`+imgurlWiki+`" rel="nofollow"><img src="`+imgurlWiki+`" title="Title" alt="AltName"/></a></p>`)
  250. test(
  251. "[[Name|Link Other.jpg|alt=\"AltName\"|title='Title']]",
  252. `<p><a href="`+otherImgurl+`" rel="nofollow"><img src="`+otherImgurl+`" title="Title" alt="AltName"/></a></p>`,
  253. `<p><a href="`+otherImgurlWiki+`" rel="nofollow"><img src="`+otherImgurlWiki+`" title="Title" alt="AltName"/></a></p>`)
  254. test(
  255. "[[Link]] [[Other Link]]",
  256. `<p><a href="`+url+`" rel="nofollow">Link</a> <a href="`+otherURL+`" rel="nofollow">Other Link</a></p>`,
  257. `<p><a href="`+urlWiki+`" rel="nofollow">Link</a> <a href="`+otherURLWiki+`" rel="nofollow">Other Link</a></p>`)
  258. test(
  259. "[[Link?]]",
  260. `<p><a href="`+encodedURL+`" rel="nofollow">Link?</a></p>`,
  261. `<p><a href="`+encodedURLWiki+`" rel="nofollow">Link?</a></p>`)
  262. test(
  263. "[[Link]] [[Other Link]] [[Link?]]",
  264. `<p><a href="`+url+`" rel="nofollow">Link</a> <a href="`+otherURL+`" rel="nofollow">Other Link</a> <a href="`+encodedURL+`" rel="nofollow">Link?</a></p>`,
  265. `<p><a href="`+urlWiki+`" rel="nofollow">Link</a> <a href="`+otherURLWiki+`" rel="nofollow">Other Link</a> <a href="`+encodedURLWiki+`" rel="nofollow">Link?</a></p>`)
  266. test(
  267. "[[Link #.jpg]]",
  268. `<p><a href="`+encodedImgurl+`" rel="nofollow"><img src="`+encodedImgurl+`"/></a></p>`,
  269. `<p><a href="`+encodedImgurlWiki+`" rel="nofollow"><img src="`+encodedImgurlWiki+`"/></a></p>`)
  270. test(
  271. "[[Name|Link #.jpg|alt=\"AltName\"|title='Title']]",
  272. `<p><a href="`+encodedImgurl+`" rel="nofollow"><img src="`+encodedImgurl+`" title="Title" alt="AltName"/></a></p>`,
  273. `<p><a href="`+encodedImgurlWiki+`" rel="nofollow"><img src="`+encodedImgurlWiki+`" title="Title" alt="AltName"/></a></p>`)
  274. test(
  275. "[[some/path/Link #.jpg]]",
  276. `<p><a href="`+notencodedImgurl+`" rel="nofollow"><img src="`+notencodedImgurl+`"/></a></p>`,
  277. `<p><a href="`+notencodedImgurlWiki+`" rel="nofollow"><img src="`+notencodedImgurlWiki+`"/></a></p>`)
  278. test(
  279. "<p><a href=\"https://example.org\">[[foobar]]</a></p>",
  280. `<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`,
  281. `<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`)
  282. }