Skip to content
Merged
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 @@ -28,6 +28,7 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.util.HtmlUtils;

/**
* A servlet which will publish dummy market data prices
Expand Down Expand Up @@ -75,8 +76,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
out.println("</body></html>");

} catch (JMSException e) {
out.println("<html><body>Failed sending price messages due to <b>" + e + "</b></body></html>");
log("Failed to send message: " + e, e);
String errorMessage = e.getMessage();
out.println("<html><body>Failed sending price messages due to <b>" + escape(errorMessage) + "</b></body></html>");
log("Failed to send message: " + errorMessage, e);
}
}
}
Expand Down Expand Up @@ -132,6 +134,6 @@ protected int getNumberOfMessages(HttpServletRequest request) {
}

protected String escape(String text) throws IOException {
return java.net.URLEncoder.encode(text, "UTF-8");
return text != null ? HtmlUtils.htmlEscape(text, "UTF-8") : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine using Spring HtmlUtils here for now.

}
}