Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@ public NotificationServlet(String authKey) throws RiskifiedError {
formatter = new NotificationHandler(authKey);
}

private static String escapeHtml(String input) {
if (input == null) {
return "";
}
return input
.replace("&", "&")
.replace("<", "&lt;")
.replace(">", "&gt;");
}

protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
PrintWriter out = resp.getWriter();
try {
NotificationOrder notification = formatter.parseServletPostRequest(req).getOrder();
System.out.println("got notification for id: '" + notification.getId() + "' with status: '" + notification.getStatus() +"' ");
out.println("<HTML><BODY>Merchant Received Notification For Order " + notification.getId()
+ " with status " + notification.getStatus() + " and description " + notification.getDescription()
+ " and app_dom_id " + notification.getCustom().getAppDomId()
+ " Old Status was " + notification.getOldStatus()
out.println("<HTML><BODY>Merchant Received Notification For Order " + escapeHtml(notification.getId())
+ " with status " + escapeHtml(notification.getStatus()) + " and description " + escapeHtml(notification.getDescription())
+ " and app_dom_id " + escapeHtml(notification.getCustom().getAppDomId())
+ " Old Status was " + escapeHtml(notification.getOldStatus())
+ "</BODY></HTML>");

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public void run() {
}
NotificationHandler formatter = new NotificationHandler("26faa0eb6eacf889e300944c297640b68789b11c");
NotificationOrder notification = formatter.toObject(body, hash).getOrder();
sendResponse(200, "<HTML><BODY>Merchant Received Notification For Order " + notification.getId()
+ " with status " + notification.getStatus() + " and description " + notification.getDescription()
+ " Old Status was " + notification.getOldStatus()
sendResponse(200, "<HTML><BODY>Merchant Received Notification For Order " + escapeHtml(notification.getId())
+ " with status " + escapeHtml(notification.getStatus()) + " and description " + escapeHtml(notification.getDescription())
+ " Old Status was " + escapeHtml(notification.getOldStatus())
+ "</BODY></HTML>");

}
Expand All @@ -77,6 +77,16 @@ public void run() {

}

private static String escapeHtml(String input) {
if (input == null) {
return "";
}
return input
.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;");
}

public void sendResponse(int statusCode, String responseString) {

String statusLine = null;
Expand Down
Loading