Skip to content

Commit

Permalink
escape tags
Browse files Browse the repository at this point in the history
  • Loading branch information
vboulaye authored and fhoeben committed Oct 23, 2024
1 parent 8558af4 commit f9b2912
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fitnesse/resources/templates/searchResults.vm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</td>
<td style="text-align: right;">
#set ( $tags = $result.getData().getAttribute("Suites") )
<label>#if ($tags && !$tags.equals("null"))$tags#end</label>
<label>#if ($tags && !$tags.equals("null"))#escape($tags)#end</label>
</td>
<td>$result.getData().getProperties().getLastModificationTime()
</td>
Expand Down Expand Up @@ -65,4 +65,4 @@
<script language="javascript">document.getElementById("feedback").innerHTML = 'Found $hits result for your search.'</script>
#else
<script language="javascript">document.getElementById("feedback").innerHTML = 'No pages matched your search criteria.'</script>
#end
#end
15 changes: 12 additions & 3 deletions test/fitnesse/responders/search/SearchResponderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import fitnesse.http.Request;
import fitnesse.http.Response;
import fitnesse.testutil.FitNesseUtil;
import fitnesse.wiki.PathParser;
import fitnesse.wiki.WikiPage;
import fitnesse.wiki.WikiPageUtil;
import fitnesse.wiki.*;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -27,6 +25,7 @@ public class SearchResponderTest {
public void setUp() throws Exception {
context = FitNesseUtil.makeTestContext();
WikiPage somePage = WikiPageUtil.addPage(context.getRootPage(), PathParser.parse("SomePage"), "has something in it");

WikiPageUtil.addPage(somePage, PathParser.parse("SomeTest"), "test page content");
WikiPageUtil.addPage(somePage, PathParser.parse("SomeSuite"), "suite page content");
request = new MockRequest();
Expand Down Expand Up @@ -218,4 +217,14 @@ public void suiteLinkShouldContainFullPagePath() throws Exception {

assertSubString("<a href=\"SomePage.SomeSuite?suite\">Suite</a>", searchPageContent);
}
@Test
public void tagsShouldBeEscaped() throws Exception {
WikiPage somePage = context.getRootPage().getChildPage("SomePage");
PageData data = somePage.getData();
data.setAttribute(WikiPageProperty.SUITES, " <script>TEST</script> ");
somePage.commit(data);
String searchPageContent = getResponseContentUsingSearchString("something");

assertSubString("&lt;script&gt;TEST&lt;/script&gt;", searchPageContent);
}
}

0 comments on commit f9b2912

Please sign in to comment.