felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1763772 - in /felix/trunk/utils/src: main/java/org/apache/felix/utils/manifest/Parser.java test/java/org/apache/felix/utils/manifest/ParserTest.java
Date Fri, 07 Oct 2016 14:52:36 GMT
Author: gnodet
Date: Fri Oct  7 14:52:36 2016
New Revision: 1763772

URL: http://svn.apache.org/viewvc?rev=1763772&view=rev
Log:
[FELIX-5370] Error parsing clauses with values containing ':='

Modified:
    felix/trunk/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java
    felix/trunk/utils/src/test/java/org/apache/felix/utils/manifest/ParserTest.java

Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java?rev=1763772&r1=1763771&r2=1763772&view=diff
==============================================================================
--- felix/trunk/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java (original)
+++ felix/trunk/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java Fri Oct  7
14:52:36 2016
@@ -81,20 +81,21 @@ public final class Parser
             String sep = null;
             for (int pieceIdx = pathCount; pieceIdx < pieces.length; pieceIdx++)
             {
-                // Check if it is a directive.
-                if ((idx = pieces[pieceIdx].indexOf(":=")) >= 0)
+                if ((idx = pieces[pieceIdx].indexOf("=")) <= 0)
                 {
-                    sep = ":=";
+                    // It is an error.
+                    throw new IllegalArgumentException("Not a directive/attribute: " + ss[ssIdx]);
                 }
-                // Check if it is an attribute.
-                else if ((idx = pieces[pieceIdx].indexOf("=")) >= 0)
+                // This a directive.
+                if (pieces[pieceIdx].charAt(idx - 1) == ':')
                 {
-                    sep = "=";
+                    idx--;
+                    sep = ":=";
                 }
-                // It is an error.
+                // This an attribute.
                 else
                 {
-                    throw new IllegalArgumentException("Not a directive/attribute: " + ss[ssIdx]);
+                    sep = "=";
                 }
 
                 String key = pieces[pieceIdx].substring(0, idx).trim();

Modified: felix/trunk/utils/src/test/java/org/apache/felix/utils/manifest/ParserTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/test/java/org/apache/felix/utils/manifest/ParserTest.java?rev=1763772&r1=1763771&r2=1763772&view=diff
==============================================================================
--- felix/trunk/utils/src/test/java/org/apache/felix/utils/manifest/ParserTest.java (original)
+++ felix/trunk/utils/src/test/java/org/apache/felix/utils/manifest/ParserTest.java Fri Oct
 7 14:52:36 2016
@@ -70,4 +70,11 @@ public class ParserTest extends TestCase
         assertEquals("2", paths[2].getDirective("1"));
     }
 
+    public void testQuotes() throws Exception {
+        Clause[] paths = Parser.parseHeader("geronimo-jms_2.0_spec;url=\"wrap:mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/1.0-alpha-2$overwrite=merge&amp;Export-Package=javax.jms;uses:=javax.transaction.xa;version=1.1,javax.jms;uses:=javax.transaction.xa;version=2.0\"");
+        assertEquals(1, paths.length);
+        assertEquals("geronimo-jms_2.0_spec", paths[0].getName());
+        assertEquals("wrap:mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/1.0-alpha-2$overwrite=merge&amp;Export-Package=javax.jms;uses:=javax.transaction.xa;version=1.1,javax.jms;uses:=javax.transaction.xa;version=2.0",
paths[0].getAttribute("url"));
+    }
+
 }



Mime
View raw message