[Modify] Replace it
This commit is contained in:
parent
59f51380a6
commit
c164b810ff
@ -954,43 +954,8 @@ namespace WebSocketSharp.Net
|
|||||||
if (encoding == null)
|
if (encoding == null)
|
||||||
encoding = Encoding.UTF8;
|
encoding = Encoding.UTF8;
|
||||||
|
|
||||||
var buff = new List<byte> ();
|
var bytes = Encoding.ASCII.GetBytes (s);
|
||||||
var len = s.Length;
|
return encoding.GetString (urlDecodeToBytes (bytes, 0, bytes.Length));
|
||||||
for (var i = 0; i < len; i++) {
|
|
||||||
var c = s[i];
|
|
||||||
if (c == '%' && i + 2 < len && s[i + 1] != '%') {
|
|
||||||
int xchar;
|
|
||||||
if (s[i + 1] == 'u' && i + 5 < len) {
|
|
||||||
// Unicode hex sequence.
|
|
||||||
xchar = getChar (s, i + 2, 4);
|
|
||||||
if (xchar != -1) {
|
|
||||||
writeCharBytes ((char) xchar, buff, encoding);
|
|
||||||
i += 5;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeCharBytes ('%', buff, encoding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((xchar = getChar (s, i + 1, 2)) != -1) {
|
|
||||||
writeCharBytes ((char) xchar, buff, encoding);
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeCharBytes ('%', buff, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '+') {
|
|
||||||
writeCharBytes (' ', buff, encoding);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeCharBytes (c, buff, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
return encoding.GetString (buff.ToArray ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string UrlDecode (byte[] bytes, Encoding encoding)
|
public static string UrlDecode (byte[] bytes, Encoding encoding)
|
||||||
|
Loading…
Reference in New Issue
Block a user