fix multiline comments by not adding <br> tags in the servlet and using <pre> tag in the browser

This commit is contained in:
Zlatin Balevsky
2019-12-07 15:15:45 +00:00
parent 905f559aa9
commit de8684bafc
2 changed files with 4 additions and 4 deletions

View File

@ -77,7 +77,7 @@ public class SearchServlet extends HttpServlet {
sb.append("<Downloading>").append(downloadManager.isDownloading(result.getInfohash())).append("</Downloading>");
if (result.getComment() != null) {
sb.append("<Comment>")
.append(Util.escapeHTMLinXML(result.getComment()).replace("\r\n", "<br />").replace("\n", "<br />"))
.append(Util.escapeHTMLinXML(result.getComment()))
.append("</Comment>");
}
sb.append("</Result>");
@ -112,7 +112,7 @@ public class SearchServlet extends HttpServlet {
sb.append("<Sender>").append(Util.escapeHTMLinXML(result.getSender().getHumanReadableName())).append("</Sender>");
if (result.getComment() != null) {
sb.append("<Comment>")
.append(Util.escapeHTMLinXML(result.getComment()).replace("\r\n", "<br />").replace("\n", "<br />"))
.append(Util.escapeHTMLinXML(result.getComment()))
.append("</Comment>");
}
sb.append("</Result>");

View File

@ -93,7 +93,7 @@ var infoHash = null;
function showCommentBySender(divId, spanId) {
var split = divId.split("_");
var commentDiv = document.getElementById(divId);
var comment = "<p>"+ searches.get(split[1]).resultBatches.get(split[2]).results.get(split[3]).comment + "</p>";
var comment = "<pre>"+ searches.get(split[1]).resultBatches.get(split[2]).results.get(split[3]).comment + "</pre>";
commentDiv.innerHTML = comment
expandedComments.set(divId, comment);
var hideLink = "<a href='#' onclick='window.hideComment(\""+divId+"\",\""+spanId+"\",\"Sender\");return false;'>Hide Comment</a>";
@ -104,7 +104,7 @@ function showCommentBySender(divId, spanId) {
function showCommentByFile(divId, spanId) {
var split = divId.split("_");
var commentDiv = document.getElementById(divId);
var comment = "<p>"+searches.get(split[1]).resultBatches.get(split[2]).results.get(split[3]).comment + "</p>";
var comment = "<pre>"+searches.get(split[1]).resultBatches.get(split[2]).results.get(split[3]).comment + "</pre>";
commentDiv.innerHTML = comment
expandedComments.set(divId, comment);
var hideLink = "<a href='#' onclick='window.hideComment(\""+divId+"\",\""+spanId+"\",\"File\");return false;'>Hide Comment</a>";