Skip to content

Commit

Permalink
Merge pull request from GHSA-h4jg-287w-hc7g
Browse files Browse the repository at this point in the history
- also update JSP README.md for running
- use the OWASP sanitizer library

For: XSS bug in util.unicode.org JSP utils #498
  • Loading branch information
srl295 authored Jun 30, 2023
1 parent 248ea94 commit 02f0fc4
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 17 deletions.
14 changes: 13 additions & 1 deletion UnicodeJsps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@
<artifactId>unicodetools-testutils</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-jsp</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
Expand Down
3 changes: 2 additions & 1 deletion UnicodeJsps/src/main/webapp/bidic.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>

<head>
Expand Down Expand Up @@ -258,7 +259,7 @@ function setUbaInput(str) {
</tr>
<tr>
<td>
<textarea id="idInputCharSeq" name="s" rows="2" cols="100" maxlength="200" oninput="setUbaInputFromEdit(event)"><%= valInputCharSeq %></textarea>
<textarea id="idInputCharSeq" name="s" rows="2" cols="100" maxlength="200" oninput="setUbaInputFromEdit(event)"><%= Encode.forHtmlContent(valInputCharSeq) %></textarea>
</td>
</tr>
<tr style="display:none">
Expand Down
9 changes: 5 additions & 4 deletions UnicodeJsps/src/main/webapp/bnf.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>
<head>
<%@ include file="header.jsp" %>
Expand Down Expand Up @@ -50,23 +51,23 @@
<th style="width: 50%">Input</th>
</tr>
<tr>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=bnf%></textarea></td>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(bnf)%></textarea></td>
</tr>
<tr>
<th style="width: 50%">TestText</th>
</tr>
<tr>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=test%></textarea></td>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(test)%></textarea></td>
</tr>
</table>
<input id='main' type="submit" value="Show Modified BNF Pattern" onClick="window.location.href='bnf.jsp?a='+document.getElementById('main').value"/>
</form>
<hr>
<h2>Modified BNF Pattern</h2>
<p><%=fixedbnf%></p>
<p><%=Encode.forHtmlContent(fixedbnf)%></p>
<hr>
<h2>Underlined Find Values</h2>
<p><%=testPattern%></p>
<p><%=Encode.forHtmlContent(testPattern)%></p>
<hr>
<h2>Random Generation</h2>
<%=random%>
Expand Down
3 changes: 2 additions & 1 deletion UnicodeJsps/src/main/webapp/breaks.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>

<head>
Expand Down Expand Up @@ -38,7 +39,7 @@ span.break { border-right: 1px solid red;}
<input type="submit" value="Test" /></td>
</tr>
<tr>
<td><textarea name="a" rows="30" cols="30" style="width:100%; height:100%"><%=text%></textarea></td>
<td><textarea name="a" rows="30" cols="30" style="width:100%; height:100%"><%=Encode.forHtmlContent(text)%></textarea></td>
<td>
<%=UnicodeJsp.showBreaks(text, choice)%>&nbsp;</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion UnicodeJsps/src/main/webapp/idna.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>
<head>
<%@ include file="header.jsp" %>
Expand Down Expand Up @@ -29,7 +30,7 @@
<th class='r'>For special characters, you can use <a target="picker" href="http://macchiato.com/picker/MyApplication.html">Picker</a></th>
</tr>
<tr>
<td colSpan='2'><textarea name="a" rows="12" cols="10" style="width: 100%"><%=IDNA2008%></textarea></td>
<td colSpan='2'><textarea name="a" rows="12" cols="10" style="width: 100%"><%=Encode.forHtmlContent(IDNA2008)%></textarea></td>
</tr>
</table>
<input id='main' type="submit" value="Show IDNA Status" onClick="window.location.href='idna.jsp?a='+document.getElementById('main').value"/>
Expand Down
3 changes: 2 additions & 1 deletion UnicodeJsps/src/main/webapp/languageid.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>
<head>
<%@ include file="header.jsp" %>
Expand Down Expand Up @@ -45,7 +46,7 @@
<th style="width: 50%">Input</th>
</tr>
<tr>
<td><input type="text" name="a" rows="8" cols="10" style="width: 100%" value="<%=languageCode%>"/></td>
<td><input type="text" name="a" rows="8" cols="10" style="width: 100%" value="<%=Encode.forHtmlAttribute(languageCode)%>"/></td>
</tr>
</table>

Expand Down
7 changes: 4 additions & 3 deletions UnicodeJsps/src/main/webapp/list-unicodeset.jsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ include file="header.jsp" %>
<title>Unicode Utilities: UnicodeSet</title>
</head>
Expand Down Expand Up @@ -36,7 +37,7 @@
<th style="width: 50%">Input</th>
</tr>
<tr>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=setA%></textarea></td>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(setA)%></textarea></td>
</tr>
<tr>
<td>
Expand All @@ -46,9 +47,9 @@
<input type="checkbox" <%=ucdFormat ? "checked" : ""%> name="ucd"><label for="ucd">UCD format</label>&nbsp;&nbsp;
<input type="checkbox" <%=escape ? "checked" : ""%> name="esc"><label for="esc">Escape</label>&nbsp;&nbsp;
<label for="g">Group by:</label>
<input type="text" <%=escape ? "checked" : ""%> name="g" size="25" value="<%=group%>">
<input type="text" <%=escape ? "checked" : ""%> name="g" size="25" value="<%=Encode.forHtmlAttribute(group)%>">
<label for="i">Info:</label>
<input type="text" <%=escape ? "checked" : ""%> name="i" size="25" value="<%=info%>">
<input type="text" <%=escape ? "checked" : ""%> name="i" size="25" value="<%=Encode.forHtmlAttribute(info)%>">
</td>
</tr>
</table>
Expand Down
7 changes: 4 additions & 3 deletions UnicodeJsps/src/main/webapp/regex.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>
<head>
<%@ include file="header.jsp" %>
Expand Down Expand Up @@ -41,20 +42,20 @@
<th style="width: 50%">Input</th>
</tr>
<tr>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=regex%></textarea></td>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(regex)%></textarea></td>
</tr>
<tr>
<th style="width: 50%">TestText</th>
</tr>
<tr>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=test%></textarea></td>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(test)%></textarea></td>
</tr>
</table>
<input id='main' type="submit" value="Show Modified Regex Pattern" onClick="window.location.href='regex.jsp?a='+document.getElementById('main').value"/>
</form>
<hr>
<h2>Modified Regex Pattern</h2>
<p><%=fixedRegex%></p>
<p><%=Encode.forHtmlContent(fixedRegex)%></p>
<hr>
<h2>Underlined Find Values</h2>
<p><%=testPattern%></p>
Expand Down
5 changes: 3 additions & 2 deletions UnicodeJsps/src/main/webapp/transform.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ page import="org.owasp.encoder.Encode" %>
<html>
<head>
<%@ include file="header.jsp" %>
Expand All @@ -24,13 +25,13 @@
<th style="width: 50%">Transform Rules</th>
</tr>
<tr>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=transform%></textarea></td>
<td><textarea name="a" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(transform)%></textarea></td>
</tr>
<tr>
<th style="width: 50%">Sample</th>
</tr>
<tr>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=sample%></textarea></td>
<td><textarea name="b" rows="8" cols="10" style="width: 100%"><%=Encode.forHtmlContent(sample)%></textarea></td>
</tr>
</table>
<input id='main' type="submit" value="Show Transform" onClick="window.location.href='transform.jsp?a='+document.getElementById('main').value"/>
Expand Down

0 comments on commit 02f0fc4

Please sign in to comment.