diff options
author | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-08-02 21:54:08 +0200 |
---|---|---|
committer | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-08-02 22:10:17 +0200 |
commit | 9667d5ee6116d5a5041bf53eeb6c8bc62327ee61 (patch) | |
tree | dbd86a8516f60e0afa81da69a766a08de464a17d | |
parent | f263d91a640d408e031bec0f6a51c3b6f970c4f2 (diff) | |
download | gitblit-9667d5ee6116d5a5041bf53eeb6c8bc62327ee61.tar.gz gitblit-9667d5ee6116d5a5041bf53eeb6c8bc62327ee61.zip |
Add more tests for tab expansion
These show more clearly what the code is supposed to do.
-rw-r--r-- | src/test/java/com/gitblit/tests/StringUtilsTest.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/test/java/com/gitblit/tests/StringUtilsTest.java b/src/test/java/com/gitblit/tests/StringUtilsTest.java index b836c71f..cc579888 100644 --- a/src/test/java/com/gitblit/tests/StringUtilsTest.java +++ b/src/test/java/com/gitblit/tests/StringUtilsTest.java @@ -61,9 +61,27 @@ public class StringUtilsTest extends GitblitUnitTest { @Test
public void testEscapeForHtml() throws Exception {
- String input = "& < > \"";
- String outputNoChange = "& < > "";
- String outputChange = "& < > "";
+ String input = "\t & < > \"";
+ String outputNoChange = "\t & < > "";
+ String outputChange = " & < > "";
+ assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
+ assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
+
+ input = "a\tb";
+ outputNoChange = "a\tb";
+ outputChange = "a b";
+ assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
+ assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
+
+ input = "\ta b\t";
+ outputNoChange = "\ta b\t";
+ outputChange = " a b ";
+ assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
+ assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
+
+ input = "\t <> \t";
+ outputNoChange = "\t <> \t";
+ outputChange = " <> ";
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
|