-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathBenchmarkTest02744.java
38 lines (34 loc) · 1.49 KB
/
BenchmarkTest02744.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.owasp.benchmark.testcode;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(value = "/xss-00/BenchmarkTest02744")
public class BenchmarkTest02744 extends SanitizingHttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
response.setHeader("X-XSS-Protection", "0");
String param = request.getParameter("email");
if (param == null) param = "";
Pattern p =
Pattern.compile(
"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(param);
boolean b = m.find();
String sanitizeParam = newSanitizedValue(param);
String htmlRespone = "<html><head></head><body><p>";
if (param != null && param.trim().length() != 0 && b) {
htmlRespone += "Our reply will be sent to your email: " + sanitizeParam;
} else {
htmlRespone += "the provided email is not correct: " + sanitizeParam;
}
htmlRespone += "</p></body></html>";
response.getWriter().println(htmlRespone);
}
}