forked from I2P_Developers/i2p.i2p
i2psnark: Convert '+' to ' ' in magnet dn param
This commit is contained in:
@ -175,18 +175,25 @@ public class MagnetURI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode %xx encoding, convert to UTF-8 if necessary
|
* Decode %xx encoding, convert to UTF-8 if necessary.
|
||||||
* Copied from i2ptunnel LocalHTTPServer
|
* Copied from i2ptunnel LocalHTTPServer.
|
||||||
|
* Also converts '+' to ' ' so the dn parameter comes out right
|
||||||
|
* These are coming in via a application/x-www-form-urlencoded form so
|
||||||
|
* the pluses are in there...
|
||||||
|
* hopefully any real + is encoded as %2B.
|
||||||
|
*
|
||||||
* @since 0.9.1
|
* @since 0.9.1
|
||||||
*/
|
*/
|
||||||
private static String decode(String s) {
|
private static String decode(String s) {
|
||||||
if (!s.contains("%"))
|
if (!(s.contains("%") || s.contains("+")))
|
||||||
return s;
|
return s;
|
||||||
StringBuilder buf = new StringBuilder(s.length());
|
StringBuilder buf = new StringBuilder(s.length());
|
||||||
boolean utf8 = false;
|
boolean utf8 = false;
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
if (c != '%') {
|
if (c == '+') {
|
||||||
|
buf.append(' ');
|
||||||
|
} else if (c != '%') {
|
||||||
buf.append(c);
|
buf.append(c);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user