From a1bacccc092054b3f0c3afc41b2e16c0becaf615 Mon Sep 17 00:00:00 2001 From: Herr Ritschwumm Date: Sat, 30 Jan 2016 15:47:21 +0100 Subject: [PATCH] add tests, failing right now --- .../gitbucket/core/view/HelpersSpec.scala | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/test/scala/gitbucket/core/view/HelpersSpec.scala b/src/test/scala/gitbucket/core/view/HelpersSpec.scala index 41d00537a..80d7eeeab 100644 --- a/src/test/scala/gitbucket/core/view/HelpersSpec.scala +++ b/src/test/scala/gitbucket/core/view/HelpersSpec.scala @@ -32,7 +32,28 @@ class HelpersSpec extends Specification { 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""" + } } - } -