Skip to content

Commit 68bfe68

Browse files
author
patched.codes[bot]
committed
Patched /tmp/tmp51_wklwp/src/com/ibm/security/appscan/altoromutual/servlet/SurveyServlet.java
1 parent bc1c51c commit 68bfe68

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/com/ibm/security/appscan/altoromutual/servlet/SurveyServlet.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,18 @@ else if (step.equals("done")){
9898
request.getSession().setAttribute("surveyStep", step);
9999
}
100100
response.setContentType("text/html");
101-
response.getWriter().write(content);
102-
response.getWriter().flush();
101+
import org.apache.commons.text.StringEscapeUtils;
102+
103+
// Get user input
104+
String userInput = request.getParameter("userInput");
105+
// Encode the input using the Html4 encoder
106+
String htmlEncodedContent = StringEscapeUtils.escapeHtml4(userInput);
107+
// Force the HTTP response to be content type of text/plain so it is not interpreted as HTML
108+
response.setContentType("text/plain");
109+
// Ensure UTF-8
110+
response.setCharacterEncoding("UTF-8");
111+
// Write response
112+
response.getWriter().write(htmlEncodedContent); response.getWriter().flush();
103113

104114
}
105115
}

0 commit comments

Comments
 (0)