From 7456da99c1b68dbc413093480082cb6f43c1f46e Mon Sep 17 00:00:00 2001 From: Jonathan Hung Date: Fri, 30 Nov 2018 10:04:06 -0800 Subject: [PATCH] YARN-9036. Escape newlines in health report in YARN UI. Contributed by Keqiu Hu --- .../hadoop/yarn/server/resourcemanager/webapp/NodesPage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java index c03df63b27c..c3a4897ab91 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java @@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; import com.google.inject.Inject; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -200,8 +201,9 @@ class NodesPage extends RmView { nodeTableData.length() - 1); } nodeTableData.append("]"); + String nodeTableDataEscaped = StringEscapeUtils.escapeJava(nodeTableData.toString()); html.script().$type("text/javascript") - ._("var nodeTableData=" + nodeTableData)._(); + ._("var nodeTableData=" + nodeTableDataEscaped)._(); tbody._()._(); } }