Fix issue #1291 - PullRequest / Commit UI: HTML renders escaped special characters instead of showing the escaped character

This commit is contained in:
Robin Shen 2023-04-12 08:52:22 +08:00
parent 7fe44bda02
commit 9dfb37ed42

View File

@ -360,10 +360,9 @@ public class BlobTextDiffPanel extends Panel {
StringBuilder builder = new StringBuilder();
appendEquals(builder, index, lastContextSize, contextSize);
String expanded = StringUtils.replace(builder.toString(), "\"", "\\\"");
expanded = StringUtils.replace(expanded, "\n", "");
String expanded = StringUtils.replace(builder.toString(), "\n", "");
String script = String.format("onedev.server.blobTextDiff.expand('%s', %d, \"%s\");",
getMarkupId(), index, expanded);
getMarkupId(), index, JavaScriptEscape.escapeJavaScript(expanded));
target.appendJavaScript(script);
break;
case "openSelectionPopover":