You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by kg...@apache.org on 2011/12/15 14:14:07 UTC
svn commit: r1214740 -
/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Author: kgilmer
Date: Thu Dec 15 13:14:07 2011
New Revision: 1214740
URL: http://svn.apache.org/viewvc?rev=1214740&view=rev
Log:
httplite: fix FELIX-3253 when handling request paths with successive '/' characters.
Modified:
felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java?rev=1214740&r1=1214739&r2=1214740&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java (original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java Thu Dec 15 13:14:07 2011
@@ -214,6 +214,47 @@ public class HttpServletRequestImpl impl
throw new IOException("Unexpected end of file when reading request line.");
}
}
+
+ // If path contains multiple successive path separators (a//b/c a/b////c, etc.), strip them.
+ if (m_uri.indexOf( "//" ) > -1)
+ {
+ // separator
+
+ m_uri = stripRedundantSeparators(m_uri);
+ }
+ }
+
+ /**
+ * Remove successive '/' characters.
+ *
+ * @param in input string
+ * @return stripped string
+ */
+ private String stripRedundantSeparators( String in )
+ {
+ StringBuffer sb = new StringBuffer();
+ boolean lastIsSeparator = false;
+
+ for (int i = 0; i < in.length(); ++i)
+ {
+ char c = in.charAt( i );
+
+ if (lastIsSeparator && c == '/')
+ {
+ continue;
+ }
+
+ sb.append( c );
+
+ if (c == '/')
+ {
+ lastIsSeparator = true;
+ } else {
+ lastIsSeparator = false;
+ }
+ }
+
+ return sb.toString();
}
/**