Skip to content

Commit 7e7b187

Browse files
committed
htmlize in breadcrumbs
1 parent aceabf2 commit 7e7b187

File tree

2 files changed

+10
-6
lines changed
  • opengrok-indexer/src

2 files changed

+10
-6
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,13 @@ public static String breadcrumbPath(String urlPrefix, String path,
442442
if (isDir || i < pnames.length - 1) {
443443
pwd.append(PATH_SEPARATOR);
444444
}
445-
markup.append(ANCHOR_LINK_START).append(prefix).append(pwd)
446-
.append(postfix).append(CLOSE_QUOTED_TAG).append(pnames[i])
447-
.append(ANCHOR_END);
445+
markup.append(ANCHOR_LINK_START).
446+
append(prefix).
447+
append(pwd).
448+
append(postfix).
449+
append(CLOSE_QUOTED_TAG).
450+
append(Util.htmlize(pnames[i])).
451+
append(ANCHOR_END);
448452
if (isDir || i < pnames.length - 1) {
449453
markup.append(sep);
450454
}

opengrok-indexer/src/test/java/org/opengrok/indexer/web/UtilTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ void breadcrumbPath() {
133133
+ "<a href=\"/r//a/c/\">c</a>/"
134134
+ "<a href=\"/r//a/c/d\">d</a>",
135135
Util.breadcrumbPath("/r/", "../a/b/../c//d", '/', "", true));
136-
// path components should be URI encoded
136+
// path components should be URI encoded and htmlized
137137
assertEquals("<a href=\"/root/foo/&project=y\">foo</a>/"
138-
+ "<a href=\"/root/foo/bar%20&project=y\">bar </a>",
139-
Util.breadcrumbPath("/root/", "foo/bar ", '/', "&project=y", true));
138+
+ "<a href=\"/root/foo/bar%3E&project=y\">bar&gt;</a>",
139+
Util.breadcrumbPath("/root/", "foo/bar>", '/', "&project=y", true));
140140
}
141141

142142
@Test

0 commit comments

Comments
 (0)