Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-08-30 15:25:50 +0000
committerThomas Watson2016-08-30 15:25:50 +0000
commitfef33690b9c5b85c608f5466aeede64a8c18b9b7 (patch)
tree02fca9afec587e2c797231c4fad93f7300e016a6 /bundles/org.eclipse.osgi.compatibility.state
parenteddd793e2f23907996725b67ed03025ea72a5821 (diff)
downloadrt.equinox.framework-fef33690b9c5b85c608f5466aeede64a8c18b9b7.tar.gz
rt.equinox.framework-fef33690b9c5b85c608f5466aeede64a8c18b9b7.tar.xz
rt.equinox.framework-fef33690b9c5b85c608f5466aeede64a8c18b9b7.zip
Bug 492890 - Must escape values in a Bundle-NativeCode header when theyY20160901-1000I20160906-0800
have special filter characters Change-Id: Ia10e30ac0090f92297196d1ace0ba19c5b454ee5 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.compatibility.state')
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java36
1 files changed, 34 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
index 7ef9beaab..56b59211c 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2013, 2016 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -144,7 +144,12 @@ class StateConverter {
}
private List<GenericSpecification> createRequireCapability(Requirement requirement) {
- String declaration = requirement.getNamespace() + toString(requirement.getAttributes(), "=", false) + toString(requirement.getDirectives(), ":=", true); //$NON-NLS-1$ //$NON-NLS-2$
+ Map<String, String> directives = new HashMap<String, String>(requirement.getDirectives());
+ String filter = directives.get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
+ if (filter != null) {
+ directives.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, escapeFilterInput(filter));
+ }
+ String declaration = requirement.getNamespace() + toString(requirement.getAttributes(), "=", false) + toString(directives, ":=", true); //$NON-NLS-1$ //$NON-NLS-2$
List<GenericSpecification> result = state.getFactory().createGenericSpecifications(declaration);
for (GenericSpecification genericSpecification : result) {
genericSpecification.setUserObject(requirement);
@@ -152,6 +157,33 @@ class StateConverter {
return result;
}
+ // We have to re-escape the escape characters in the filter string
+ private static String escapeFilterInput(final String filter) {
+ boolean escaped = false;
+ int inlen = filter.length();
+ int outlen = inlen << 1; /* inlen * 2 */
+
+ char[] output = new char[outlen];
+ filter.getChars(0, inlen, output, inlen);
+
+ int cursor = 0;
+ for (int i = inlen; i < outlen; i++) {
+ char c = output[i];
+ switch (c) {
+ case '\\' :
+ output[cursor] = '\\';
+ cursor++;
+ escaped = true;
+ break;
+ }
+
+ output[cursor] = c;
+ cursor++;
+ }
+
+ return escaped ? new String(output, 0, cursor) : filter;
+ }
+
private String createOSGiRequirement(Requirement requirement, String namespace, String... versions) {
Map<String, String> directives = new HashMap<String, String>(requirement.getDirectives());
String filter = directives.remove(Namespace.REQUIREMENT_FILTER_DIRECTIVE);

Back to the top