diff --git a/src/test/scala/gitbucket/core/view/HelpersSpec.scala b/src/test/scala/gitbucket/core/view/HelpersSpec.scala index 41d0053..80d7eee 100644 --- a/src/test/scala/gitbucket/core/view/HelpersSpec.scala +++ b/src/test/scala/gitbucket/core/view/HelpersSpec.scala @@ -32,7 +32,28 @@ after mustEqual """Example Project. http://example.com. (See also https://github.com/)""" } + "properly escape html metacharacters" in { + val before = "<>&" + val after = detectAndRenderLinks(before).toString() + after mustEqual """<>&""" + } + + "escape html metacharacters adjacent to a link" in { + val before = "" + val after = detectAndRenderLinks(before).toString() + after mustEqual """<http://example.com>""" + } + + "stop link recognition at a metacharacter" in { + val before = "http://exahttp://exa<mple.com""" + } + + "make sure there are no double quotes in the href attribute" in { + val before = "http://exa\"mple.com" + val after = detectAndRenderLinks(before).toString() + after mustEqual """http://exa"mple.com""" + } } - } -