Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript injection using tags inside the search result page #1526

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading