Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-09-07 10:40:21 -0400
committerThomas Watson2011-09-07 10:40:21 -0400
commitd53dcdd9966ba8c5365fbf22a85a18915c6c2931 (patch)
tree4cc49937cc1ad5affddcc3ace5af12d4205d9846
parent54e65990891df65de94e22946b805cfd1d177820 (diff)
downloadrt.equinox.framework-d53dcdd9966ba8c5365fbf22a85a18915c6c2931.tar.gz
rt.equinox.framework-d53dcdd9966ba8c5365fbf22a85a18915c6c2931.tar.xz
rt.equinox.framework-d53dcdd9966ba8c5365fbf22a85a18915c6c2931.zip
Bug 355498 - SignatureBlockProcessor does not support all types of line
continuations
-rw-r--r--bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
index e83da7719..c9863804c 100644
--- a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
+++ b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
@@ -448,22 +448,25 @@ public class SignatureBlockProcessor implements SignedContentConstants {
}
private static String stripContinuations(String entry) {
- if (entry.indexOf("\n ") < 0) //$NON-NLS-1$
+ if (entry.indexOf("\n ") < 0 && entry.indexOf("\r ") < 0) //$NON-NLS-1$//$NON-NLS-2$
return entry;
- StringBuffer buffer = new StringBuffer(entry.length());
- int cont = entry.indexOf("\n "); //$NON-NLS-1$
- int start = 0;
- while (cont >= 0) {
- buffer.append(entry.substring(start, cont - 1));
- start = cont + 2;
- cont = cont + 2 < entry.length() ? entry.indexOf("\n ", cont + 2) : -1; //$NON-NLS-1$
- }
- // get the last one continuation
- if (start < entry.length())
- buffer.append(entry.substring(start));
+ StringBuffer buffer = new StringBuffer(entry);
+ removeAll(buffer, "\r\n "); //$NON-NLS-1$
+ removeAll(buffer, "\n "); //$NON-NLS-1$
+ removeAll(buffer, "\r "); //$NON-NLS-1$
return buffer.toString();
}
+ private static StringBuffer removeAll(StringBuffer buffer, String toRemove) {
+ int index = buffer.indexOf(toRemove);
+ int length = toRemove.length();
+ while (index > 0) {
+ buffer.replace(index, index + length, ""); //$NON-NLS-1$
+ index = buffer.indexOf(toRemove, index);
+ }
+ return buffer;
+ }
+
private static byte[] readIntoArray(BundleEntry be) throws IOException {
int size = (int) be.getSize();
InputStream is = be.getInputStream();

Back to the top