Strip unknown attributes from Fragment-Host header. (FELIX-2466)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@962541 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
index 8fc4a0c..59e72e1 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
@@ -1142,23 +1142,28 @@
                             + headerMap.get(Constants.FRAGMENT_HOST));
                 }
 
-                // If the bundle version matching attribute is specified, then
-                // convert it to the proper type.
-                for (int attrIdx = 0;
-                    attrIdx < clauses.get(0).m_attrs.size();
-                    attrIdx++)
+                // Strip all attributes other than bundle-version.
+                for (Iterator<Attribute> it = clauses.get(0).m_attrs.iterator(); it.hasNext(); )
                 {
-                    Attribute attr = clauses.get(0).m_attrs.get(attrIdx);
-                    if (attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
+                    Attribute attr = it.next();
+                    if (!attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     {
-                        clauses.get(0).m_attrs.set(attrIdx,
-                            new Attribute(
-                                Constants.BUNDLE_VERSION_ATTRIBUTE,
-                                VersionRange.parse(attr.getValue().toString()),
-                                attr.isMandatory()));
+                        it.remove();
                     }
                 }
 
+                // If the bundle-version attribute is specified, then convert
+                // it to the proper type.
+                if (clauses.get(0).m_attrs.size() == 1)
+                {
+                    Attribute attr = clauses.get(0).m_attrs.get(0);
+                    clauses.get(0).m_attrs.set(0,
+                        new Attribute(
+                            Constants.BUNDLE_VERSION_ATTRIBUTE,
+                            VersionRange.parse(attr.getValue().toString()),
+                            attr.isMandatory()));
+                }
+
                 // Prepend the host symbolic name to the array of attributes.
                 List<Attribute> attrs = clauses.get(0).m_attrs;
                 List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size() + 1);