YARN-9036. Escape newlines in health report in YARN UI. Contributed by Keqiu Hu

This commit is contained in:
Jonathan Hung 2018-11-30 09:51:05 -08:00 committed by Jonathan Hung
parent e534be892c
commit 2cb9479bfc
1 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.webapp; package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.NodeState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
@ -203,8 +204,9 @@ class NodesPage extends RmView {
nodeTableData.length() - 1); nodeTableData.length() - 1);
} }
nodeTableData.append("]"); nodeTableData.append("]");
String nodeTableDataEscaped = StringEscapeUtils.escapeJava(nodeTableData.toString());
html.script().$type("text/javascript") html.script().$type("text/javascript")
.__("var nodeTableData=" + nodeTableData).__(); .__("var nodeTableData=" + nodeTableDataEscaped).__();
tbody.__().__(); tbody.__().__();
} }
} }