hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1127805 - in /hadoop/hdfs/branches/branch-0.22: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
Date Thu, 26 May 2011 07:06:41 GMT
Author: todd
Date: Thu May 26 07:06:40 2011
New Revision: 1127805

URL: http://svn.apache.org/viewvc?rev=1127805&view=rev
Log:
HDFS-1964. Fix incorrect HTML unescaping in DatanodeJspHelper. Contributed by Aaron T. Myers.

Modified:
    hadoop/hdfs/branches/branch-0.22/CHANGES.txt
    hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
    hadoop/hdfs/branches/branch-0.22/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java

Modified: hadoop/hdfs/branches/branch-0.22/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.22/CHANGES.txt?rev=1127805&r1=1127804&r2=1127805&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.22/CHANGES.txt (original)
+++ hadoop/hdfs/branches/branch-0.22/CHANGES.txt Thu May 26 07:06:40 2011
@@ -537,6 +537,9 @@ Release 0.22.0 - Unreleased
     HDFS-1965. IPCs done using block token-based tickets can't reuse
     connections (todd)
 
+    HDFS-1964. Fix incorrect HTML unescaping in DatanodeJspHelper
+    (Aaron T. Myers via todd)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java?rev=1127805&r1=1127804&r2=1127805&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
(original)
+++ hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
Thu May 26 07:06:40 2011
@@ -81,8 +81,8 @@ public class DatanodeJspHelper {
                                          Configuration conf
                                          ) throws IOException,
                                                   InterruptedException {
-    final String dir = StringEscapeUtils.unescapeHtml(
-        JspHelper.validatePath(req.getParameter("dir")));
+    final String dir = JspHelper.validatePath(
+        StringEscapeUtils.unescapeHtml(req.getParameter("dir")));
     if (dir == null) {
       out.print("Invalid input");
       return;
@@ -586,7 +586,7 @@ public class DatanodeJspHelper {
     }
 
     final String filename = JspHelper
-        .validatePath(req.getParameter(StringEscapeUtils.unescapeHtml("filename")));
+        .validatePath(StringEscapeUtils.unescapeHtml(req.getParameter("filename")));
     if (filename == null) {
       out.print("Invalid input (file name absent)");
       return;

Modified: hadoop/hdfs/branches/branch-0.22/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.22/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java?rev=1127805&r1=1127804&r2=1127805&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.22/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
(original)
+++ hadoop/hdfs/branches/branch-0.22/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
Thu May 26 07:06:40 2011
@@ -38,24 +38,33 @@ public class TestDatanodeJsp {
 
   private static final String FILE_DATA = "foo bar baz biz buz";
 
-  private static void testViewingFile(MiniDFSCluster cluster, String filePath) throws IOException
{
+  private static void testViewingFile(MiniDFSCluster cluster, String filePath,
+      boolean doTail) throws IOException {
     FileSystem fs = cluster.getFileSystem();
 
     Path testPath = new Path(filePath);
-    DFSTestUtil.writeFile(fs, testPath, FILE_DATA);
+    if (!fs.exists(testPath)) {
+      DFSTestUtil.writeFile(fs, testPath, FILE_DATA);
+    }
 
     InetSocketAddress nnHttpAddress = cluster.getNameNode().getHttpAddress();
     int dnInfoPort = cluster.getDataNodes().get(0).getInfoPort();
 
-    URL url = new URL("http://localhost:" + dnInfoPort + "/browseDirectory.jsp" +
-        JspHelper.getUrlParam("dir", URLEncoder.encode(testPath.toString(), "UTF-8"), true)
+
+    String jspName = doTail ? "tail.jsp" : "browseDirectory.jsp";
+    String fileParamName = doTail ? "filename" : "dir";
+
+    URL url = new URL("http://localhost:" + dnInfoPort + "/" + jspName +
+        JspHelper.getUrlParam(fileParamName, URLEncoder.encode(testPath.toString(), "UTF-8"),
true) +
         JspHelper.getUrlParam("namenodeInfoPort", Integer.toString(nnHttpAddress.getPort())));
 
     String viewFilePage = DFSTestUtil.urlGet(url);
 
     assertTrue("page should show preview of file contents", viewFilePage.contains(FILE_DATA));
-    assertTrue("page should show link to download file", viewFilePage
-        .contains("/streamFile" + URIUtil.encodePath(testPath.toString())));
+
+    if (!doTail) {
+      assertTrue("page should show link to download file", viewFilePage
+          .contains("/streamFile" + URIUtil.encodePath(testPath.toString())));
+    }
   }
 
   @Test
@@ -66,9 +75,13 @@ public class TestDatanodeJsp {
       cluster = new MiniDFSCluster.Builder(conf).build();
       cluster.waitActive();
 
-      testViewingFile(cluster, "/test-file");
-      testViewingFile(cluster, "/tmp/test-file");
-      testViewingFile(cluster, "/tmp/test-file%with goofy&characters");
+      testViewingFile(cluster, "/test-file", false);
+      testViewingFile(cluster, "/tmp/test-file", false);
+      testViewingFile(cluster, "/tmp/test-file%with goofy&characters", false);
+
+      testViewingFile(cluster, "/test-file", true);
+      testViewingFile(cluster, "/tmp/test-file", true);
+      testViewingFile(cluster, "/tmp/test-file%with goofy&characters", true);
 
     } finally {
       if (cluster != null) {



Mime
View raw message