Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-04-01 21:52:58 +0000
committerChris Goldthorpe2010-04-01 21:52:58 +0000
commit11b1b10eafc75f20d8ac6b57db4132a63daac2b2 (patch)
tree8e9f17a200b9f0ac4cc3d7148934a74fe2ab639d /org.eclipse.help
parent5ae5529c9109d830b1e0bd2d5287e66f42afe3e7 (diff)
downloadeclipse.platform.ua-11b1b10eafc75f20d8ac6b57db4132a63daac2b2.tar.gz
eclipse.platform.ua-11b1b10eafc75f20d8ac6b57db4132a63daac2b2.tar.xz
eclipse.platform.ua-11b1b10eafc75f20d8ac6b57db4132a63daac2b2.zip
compactEncode now also leaves '.' and '/' unencoded
Diffstat (limited to 'org.eclipse.help')
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java b/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java
index 35f9c8403..0a2ef05cf 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java
@@ -17,7 +17,7 @@ public class URLCoder {
public static String encode(String s) {
try {
- return urlEncode(s.getBytes("UTF8"), false); //$NON-NLS-1$
+ return urlEncode(s.getBytes("UTF8"), true); //$NON-NLS-1$
} catch (UnsupportedEncodingException uee) {
return null;
}
@@ -25,7 +25,7 @@ public class URLCoder {
public static String compactEncode(String s) {
try {
- return urlEncode(s.getBytes("UTF8"), true); //$NON-NLS-1$
+ return urlEncode(s.getBytes("UTF8"), false); //$NON-NLS-1$
} catch (UnsupportedEncodingException uee) {
return null;
}
@@ -39,11 +39,11 @@ public class URLCoder {
}
}
- private static String urlEncode(byte[] data, boolean encodeAlphanumeric) {
+ private static String urlEncode(byte[] data, boolean encodeAllCharacters) {
StringBuffer buf = new StringBuffer(data.length);
for (int i = 0; i < data.length; i++) {
byte nextByte = data[i];
- if (encodeAlphanumeric && isAlphaNumeric(nextByte)) {
+ if (!encodeAllCharacters && isAlphaNumericSlashOrDot(nextByte)) {
buf.append((char)nextByte);
} else {
buf.append('%');
@@ -54,8 +54,9 @@ public class URLCoder {
return buf.toString();
}
- private static boolean isAlphaNumeric(byte b) {
- return (b >= 0 && b <= 9) || (b >= 'a' && b < 'z') || ( b >= 'A' && b <= 'Z');
+ private static boolean isAlphaNumericSlashOrDot(byte b) {
+ return (b >= '0' && b <= '9') || (b >= 'a' && b < 'z') || ( b >= 'A' && b <= 'Z')
+ || b == '.' || b == '/';
}
private static byte[] urlDecode(String encodedURL) {

Back to the top