瀏覽代碼

YARN-3589. RM and AH web UI display DOCTYPE wrongly. Contbituted by Rohith.

(cherry picked from commit f26700f2878f4374c68e97ee00205eda5a6d022c)
Tsuyoshi Ozawa 10 年之前
父節點
當前提交
b1f3590b22

+ 2 - 0
hadoop-yarn-project/CHANGES.txt

@@ -299,6 +299,8 @@ Release 2.8.0 - UNRELEASED
 
     YARN-3592. Fix typos in RMNodeLabelsManager. (Sunil G via devaraj)
 
+    YARN-3589. RM and AH web UI display DOCTYPE wrongly. (Rohith via ozawa)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/HtmlPage.java

@@ -78,7 +78,7 @@ public abstract class HtmlPage extends TextView {
 
   @Override
   public void render() {
-    puts(DOCTYPE);
+    putWithoutEscapeHtml(DOCTYPE);
     render(page().html().meta_http("X-UA-Compatible", "IE=8")
         .meta_http("Content-type", MimeType.HTML));
     if (page().nestLevel() != 0) {

+ 21 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/TextView.java

@@ -40,7 +40,7 @@ public abstract class TextView extends View {
   }
 
   /**
-   * Print strings as is (no newline, a la php echo).
+   * Print strings escaping html.
    * @param args the strings to print
    */
   public void echo(Object... args) {
@@ -52,6 +52,17 @@ public abstract class TextView extends View {
     }
   }
 
+  /**
+   * Print strings as is (no newline, a la php echo).
+   * @param args the strings to print
+   */
+  public void echoWithoutEscapeHtml(Object... args) {
+    PrintWriter out = writer();
+    for (Object s : args) {
+      out.print(s);
+    }
+  }
+
   /**
    * Print strings as a line (new line appended at the end, a la C/Tcl puts).
    * @param args the strings to print
@@ -60,4 +71,13 @@ public abstract class TextView extends View {
     echo(args);
     writer().println();
   }
+
+  /**
+   * Print string as a line. This does not escapes the string for html
+   * @param args the strings to print
+   */
+  public void putWithoutEscapeHtml(Object args) {
+    echoWithoutEscapeHtml(args);
+    writer().println();
+  }
 }