Skip to content

Commit 7aa003e

Browse files
author
patched.codes[bot]
committed
Patched src/com/ibm/security/appscan/altoromutual/util/ServletUtil.java
1 parent 5cda855 commit 7aa003e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/com/ibm/security/appscan/altoromutual/util/ServletUtil.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public static String sanitizeWeb(String data) {
246246
return StringEscapeUtils.escapeHtml(data);
247247
}
248248

249+
/**
250+
* Sanitizes the input HTML string by checking for potential XSS (Cross-Site Scripting) threats using a regular expression.
251+
*
252+
* @param input The HTML string to be sanitized
253+
* @return The sanitized HTML string, or an empty string if a potential XSS threat is detected
254+
*/
249255
public static String sanitzieHtmlWithRegex(String input) {
250256
if (XSS_REGEXP.matcher(input).matches()) {
251257
return "";
@@ -337,6 +343,14 @@ public static void initializeLogFile(ServletContext servletContext) {
337343
}
338344
}
339345

346+
/**
347+
* Establishes a session for a given user and creates a cookie with account information.
348+
*
349+
* @param username The username of the user to establish a session for
350+
* @param session The HttpSession object to store user information
351+
* @return A Cookie object containing the user's account information, or null if an error occurs
352+
* @throws SQLException If there is an error retrieving user information from the database
353+
*/
340354
public static Cookie establishSession(String username, HttpSession session){
341355
try{
342356
User user = DBUtil.getUserInfo(username);
@@ -352,6 +366,12 @@ public static Cookie establishSession(String username, HttpSession session){
352366
}
353367
}
354368

369+
/**
370+
* Checks if a user is logged in based on the session attribute.
371+
*
372+
* @param request The HttpServletRequest object containing the session information
373+
* @return true if the user is logged in, false otherwise
374+
*/
355375
static public boolean isLoggedin(HttpServletRequest request){
356376
try {
357377
// Check user is logged in

0 commit comments

Comments
 (0)