hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1470789 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/HServerInfo.java test/java/org/apache/hadoop/hbase/TestHServerInfo.java
Date Tue, 23 Apr 2013 02:49:26 GMT
Author: liyin
Date: Tue Apr 23 02:49:25 2013
New Revision: 1470789

URL: http://svn.apache.org/r1470789
Log:
[HBASE-8328] Making the regex for the hostname in HServerInfo more strict

Author: gauravm

Summary: The regex for the servername in HServerInfo was very liberal. Making it more strict
by ensuring that the hostname follows the Letters-Digits-Hyphen (LDH) rule.

Test Plan:
1. Ran the unit tests
2. Checked that the regex accepts hostnames like {"123.223.444.111", "hbaseproxy001.prn1.fb.com"
}, and does not accept hostnames like { "", " ", "  ", "#123$!!"}

Reviewers: shaneh, liyintang

Reviewed By: shaneh

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D771905

Task ID: 2277059

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java?rev=1470789&r1=1470788&r2=1470789&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java Tue Apr
23 02:49:25 2013
@@ -60,7 +60,7 @@ public class HServerInfo implements Writ
   static final String SERVERNAME_SEPARATOR = ",";
 
   private static final Pattern SERVER_NAME_RE = Pattern.compile(
-      "^[^,]+" + SERVERNAME_SEPARATOR + 
+      "^[0-9a-zA-Z.-]+" + SERVERNAME_SEPARATOR +
       "[0-9]{1," + String.valueOf(0xffff).length() + "}" + SERVERNAME_SEPARATOR +
       "-?[0-9]{1," + String.valueOf(Long.MAX_VALUE).length() + "}");
 

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java?rev=1470789&r1=1470788&r2=1470789&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java Tue
Apr 23 02:49:25 2013
@@ -160,6 +160,11 @@ public class TestHServerInfo {
     assertFalse(HServerInfo.isValidServerName(",www.acme.com,80,0"));
     assertTrue(HServerInfo.isValidServerName("foo.bar,60020," + Long.MAX_VALUE));
     assertFalse(HServerInfo.isValidServerName("foo.bar,60020," + Long.MAX_VALUE + "a"));
+    assertFalse(HServerInfo.isValidServerName(",60020," + Long.MAX_VALUE));
+    assertFalse(HServerInfo.isValidServerName(" ,60020," + Long.MAX_VALUE));
+    assertFalse(HServerInfo.isValidServerName("  ,60020," + Long.MAX_VALUE));
+    assertFalse(HServerInfo.isValidServerName("!>;@#@#localhost,60020," +
+                                              Long.MAX_VALUE));
   }
 
 }



Mime
View raw message