hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1127390 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
Date Wed, 25 May 2011 05:52:29 GMT
Author: todd
Date: Wed May 25 05:52:29 2011
New Revision: 1127390

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

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1127390&r1=1127389&r2=1127390&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed May 25 05:52:29 2011
@@ -1052,6 +1052,9 @@ Release 0.22.0 - Unreleased
 
     HDFS-1978. All but first option in LIBHDFS_OPTS is ignored. (eli)
 
+    HDFS-1964. Fix incorrect HTML unescaping in DatanodeJspHelper
+    (Aaron T. Myers via todd)
+
 Release 0.21.1 - Unreleased
     HDFS-1466. TestFcHdfsSymlink relies on /tmp/test not existing. (eli)
 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java?rev=1127390&r1=1127389&r2=1127390&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
(original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java
Wed May 25 05:52:29 2011
@@ -84,8 +84,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;
@@ -621,7 +621,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/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java?rev=1127390&r1=1127389&r2=1127390&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java
Wed May 25 05:52:29 2011
@@ -38,27 +38,36 @@ 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 nnIpcAddress = cluster.getNameNode().getNameNodeAddress();
     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)
+
-        JspHelper.getUrlParam("namenodeInfoPort", nnHttpAddress.getPort() + 
-        JspHelper.getUrlParam("nnaddr", "localhost:" + nnIpcAddress.getPort())));
+    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()))
+ 
+        JspHelper.getUrlParam("nnaddr", "localhost:" + nnIpcAddress.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()) +
-            "?nnaddr=localhost:" + nnIpcAddress.getPort()));
+    
+    if (!doTail) {
+      assertTrue("page should show link to download file", viewFilePage
+          .contains("/streamFile" + URIUtil.encodePath(testPath.toString()) +
+              "?nnaddr=localhost:" + nnIpcAddress.getPort()));
+    }
   }
   
   @Test
@@ -69,9 +78,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