Escape XML strings in the compiler output
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.compiler.messages;
|
package org.jetbrains.jet.compiler.messages;
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -37,18 +38,22 @@ public interface MessageRenderer {
|
|||||||
StringBuilder out = new StringBuilder();
|
StringBuilder out = new StringBuilder();
|
||||||
out.append("<").append(severity.toString());
|
out.append("<").append(severity.toString());
|
||||||
if (location.getPath() != null) {
|
if (location.getPath() != null) {
|
||||||
out.append(" path=\"").append(location.getPath()).append("\"");
|
out.append(" path=\"").append(e(location.getPath())).append("\"");
|
||||||
out.append(" line=\"").append(location.getLine()).append("\"");
|
out.append(" line=\"").append(location.getLine()).append("\"");
|
||||||
out.append(" column=\"").append(location.getColumn()).append("\"");
|
out.append(" column=\"").append(location.getColumn()).append("\"");
|
||||||
}
|
}
|
||||||
out.append(">\n");
|
out.append(">\n");
|
||||||
|
|
||||||
out.append(message);
|
out.append(e(message));
|
||||||
|
|
||||||
out.append("</").append(severity.toString()).append(">\n");
|
out.append("</").append(severity.toString()).append(">\n");
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String e(String str) {
|
||||||
|
return StringUtil.escapeXml(str);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String renderException(@NotNull Throwable e) {
|
public String renderException(@NotNull Throwable e) {
|
||||||
return render(CompilerMessageSeverity.EXCEPTION, PLAIN.renderException(e), CompilerMessageLocation.NO_LOCATION);
|
return render(CompilerMessageSeverity.EXCEPTION, PLAIN.renderException(e), CompilerMessageLocation.NO_LOCATION);
|
||||||
|
|||||||
Reference in New Issue
Block a user