Bug 2909: Added '+' to the list of chars that are being encoded

This commit is contained in:
Steffen Schaefer committed 2015-05-26 15:30:07 +02:00
1 parent d5fc40b70a
commit 526803ab78
1 file changed
+26 -26
@@ -1,26 +1,26 @@
package com.sap.sse.gwt.client;
import com.google.gwt.http.client.URL;
/**
* A very basic URL encoder that also works in a GWT environment where <code>java.net.URLEncoder</code> is not available.
* It is based on {@link URL#encode(String)} and adds encoding for the backslash (\) character.
*
* @author Axel Uhl (D043530)
*
*/
public class URLEncoder {
private URLEncoder() { }
private final static char[] charsToReplace = { '\'', '(', ')', '"', '[', ']', '{', '}', '<', '>', '|' };
public static String encode(String url) {
String nearlyEncoded = URL.encode(url);
for (char c : charsToReplace) {
nearlyEncoded = nearlyEncoded.replaceAll("\\" + Character.toString(c), "%" + Integer.toHexString(c));
}
return nearlyEncoded;
}
}
package com.sap.sse.gwt.client;
import com.google.gwt.http.client.URL;
/**
* A very basic URL encoder that also works in a GWT environment where <code>java.net.URLEncoder</code> is not available.
* It is based on {@link URL#encode(String)} and adds encoding for the backslash (\) character.
*
* @author Axel Uhl (D043530)
*
*/
public class URLEncoder {
private URLEncoder() { }
private final static char[] charsToReplace = { '\'', '(', ')', '"', '[', ']', '{', '}', '<', '>', '|', '+' };
public static String encode(String url) {
String nearlyEncoded = URL.encode(url);
for (char c : charsToReplace) {
nearlyEncoded = nearlyEncoded.replaceAll("\\" + Character.toString(c), "%" + Integer.toHexString(c));
}
return nearlyEncoded;
}
}