diff options
author | Thomas Watson | 2011-09-07 10:40:21 -0400 |
---|---|---|
committer | Thomas Watson | 2011-09-07 10:40:21 -0400 |
commit | d53dcdd9966ba8c5365fbf22a85a18915c6c2931 (patch) | |
tree | 4cc49937cc1ad5affddcc3ace5af12d4205d9846 | |
parent | 54e65990891df65de94e22946b805cfd1d177820 (diff) | |
download | rt.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.java | 27 |
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(); |