You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2013/01/31 17:49:03 UTC

svn commit: r1441056 - in /felix/trunk/framework/src: main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java

Author: rickhall
Date: Thu Jan 31 16:49:03 2013
New Revision: 1441056

URL: http://svn.apache.org/viewvc?rev=1441056&view=rev
Log:
Modify substring parsing to accept successive '*' characters. (FELIX-3344)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
    felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java?rev=1441056&r1=1441055&r2=1441056&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java Thu Jan 31 16:49:03 2013
@@ -403,24 +403,23 @@ loop:   for (;;)
             char c = value.charAt(idx++);
             if (!escaped && (c == '*'))
             {
-                if (wasStar)
+                // If we have successive '*' characters, then we can
+                // effectively collapse them by ignoring succeeding ones.
+                if (!wasStar)
                 {
-                    // encountered two successive stars;
-                    // I assume this is illegal
-                    throw new IllegalArgumentException("Invalid filter string: " + value);
-                }
-                if (ss.length() > 0)
-                {
-                    pieces.add(ss.toString()); // accumulate the pieces
-                    // between '*' occurrences
-                }
-                ss.setLength(0);
-                // if this is a leading star, then track it
-                if (pieces.isEmpty())
-                {
-                    leftstar = true;
+                    if (ss.length() > 0)
+                    {
+                        pieces.add(ss.toString()); // accumulate the pieces
+                        // between '*' occurrences
+                    }
+                    ss.setLength(0);
+                    // if this is a leading star, then track it
+                    if (pieces.isEmpty())
+                    {
+                        leftstar = true;
+                    }
+                    wasStar = true;
                 }
-                wasStar = true;
             }
             else if (!escaped && (c == '\\'))
             {

Modified: felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java?rev=1441056&r1=1441055&r2=1441056&view=diff
==============================================================================
--- felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java (original)
+++ felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java Thu Jan 31 16:49:03 2013
@@ -79,5 +79,8 @@ public class SimpleFilterTest extends Te
 
         pieces = SimpleFilter.parseSubstring("aaaa*aaaa");
         assertFalse("Should not match!", SimpleFilter.compareSubstring(pieces, "aaaaaaa"));
+
+        pieces = SimpleFilter.parseSubstring("aaa**aaa");
+        assertTrue("Should match!", SimpleFilter.compareSubstring(pieces, "aaaaaa"));
     }
 }