Skip to content

Commit 9a31c42

Browse files
authored
Regression coverage for Issue 52402 (#2299)
1 parent e06107a commit 9a31c42

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<input id="firstName" type="text" value="<script>alert('XSS Input Success')</script><span>Loading XSS</span>" />
2+
<button class="btn btn-primary input-test" data-loading-text="<span>I'm Loading</span>" type="button">
3+
Attempt XSS injection
4+
</button>
5+
<script type="text/javascript" nonce="<%=scriptNonce%>">
6+
// Issue 52402: Verify the "loadingText" attribute for a bootstrap button() is properly encoded.
7+
// See ClientAPITest.testBootstrapButtonEncoding
8+
$(function () {
9+
$('.input-test').click(function () {
10+
let inputValue = $('#firstName').val();
11+
$(this).data('loadingText', inputValue);
12+
$(this).button('loading', inputValue);
13+
});
14+
});
15+
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<view xmlns="http://labkey.org/data/xml/view">
2+
<dependencies>
3+
<dependency path="internal/jQuery" />
4+
</dependencies>
5+
</view>

src/org/labkey/test/tests/ClientAPITest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,21 @@ public void suggestedColumnsInQueryDetailsTest() throws Exception
15461546
columns.stream().noneMatch(col -> col.getName().equalsIgnoreCase("Container")));
15471547
}
15481548

1549+
@Test
1550+
public void testBootstrapButtonEncoding()
1551+
{
1552+
assumeTestModules();
1553+
1554+
beginAt(WebTestHelper.buildURL("simpletest", getProjectName(), "encodeButton"));
1555+
var buttonLocator = Locator.tagWithClass("button", "input-test");
1556+
waitForElement(buttonLocator);
1557+
1558+
// Prior to the patch for Issue 52402 clicking the button would result in a XSS injection
1559+
// which would result in an UnhandledAlertException.
1560+
click(buttonLocator);
1561+
waitForElement(Locator.buttonContainingText("<script>alert('XSS Input Success')</script><span>Loading XSS</span>"));
1562+
}
1563+
15491564
@Override
15501565
public BrowserType bestBrowser()
15511566
{

0 commit comments

Comments
 (0)