[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [ernie/master 2/3] Make descriptor lookup case insensitive.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon, 7 Jun 2010 23:23:00 +0200
Subject: Make descriptor lookup case insensitive.
Commit: ee3e04f8c3a4851921bfe74399cf42cedf29718b

---
 .../ernie/web/ServerDescriptorServlet.java         |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/org/torproject/ernie/web/ServerDescriptorServlet.java b/src/org/torproject/ernie/web/ServerDescriptorServlet.java
index dcf9113..bb297b9 100644
--- a/src/org/torproject/ernie/web/ServerDescriptorServlet.java
+++ b/src/org/torproject/ernie/web/ServerDescriptorServlet.java
@@ -31,8 +31,9 @@ public class ServerDescriptorServlet extends HttpServlet {
       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
       return;
     }
+    String descId = descIdParameter.toLowerCase();
     Pattern descIdPattern = Pattern.compile("^[0-9a-f]+$");
-    Matcher descIdMatcher = descIdPattern.matcher(descIdParameter);
+    Matcher descIdMatcher = descIdPattern.matcher(descId);
     if (!descIdMatcher.matches()) {
       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
       return;
@@ -41,12 +42,10 @@ public class ServerDescriptorServlet extends HttpServlet {
     for (File yearFile : archiveDirectory.listFiles()) {
       for (File monthFile : yearFile.listFiles()) {
         File subDirectory = new File(monthFile.getAbsolutePath() + "/"
-            + descIdParameter.substring(0, 1) + "/"
-            + descIdParameter.substring(1, 2));
+            + descId.substring(0, 1) + "/" + descId.substring(1, 2));
         if (subDirectory.exists()) {
           for (File serverDescriptorFile : subDirectory.listFiles()) {
-            if (!serverDescriptorFile.getName().startsWith(
-                descIdParameter)) {
+            if (!serverDescriptorFile.getName().startsWith(descId)) {
               continue;
             }
 
-- 
1.6.5