kerryjiang / SuperWebSocket

SuperWebSocket is a .NET implementation of WebSocket server.
Apache License 2.0
504 stars 194 forks source link

System.UriFormatException: 无效的 URI: 字符串中有无效的序列 #12

Closed tupunco closed 9 years ago

tupunco commented 9 years ago
Failed to read cookie, key: key_name, value: v=2&v_id=3383628&v_name=%89%5b%b0e%0f%5c%03N.
System.UriFormatException: 无效的 URI: 字符串中有无效的序列。
   在 System.Uri.UnescapeString(Char* pStr, Int32 start, Int32 end, Char[] dest, Int32& destPosition, Char rsvd1, Char rsvd2, Char rsvd3, UnescapeMode unescapeMode, UriParser syntax, Boolean isQuery, Boolean readOnlyConfig)
   在 System.Uri.UnescapeDataString(String stringToUnescape)
   在 SuperWebSocket.WebSocketSession`1.SetCookie() 位置 f:\Work\Websockets\SuperWebSocket-master\SuperWebSocket\WebSocketSession.cs:行号 353

测试了下 "%89%5b%b0e%0f%5c%03N" 这个串Uri.UnescapeDataString()必然出错, 因为这个 Cookie 是多个子Cookie拼合而成的, 示范代码;

curCookie = current.Request.Cookies["key_name"];
curCookie["v_id"] = 1111;
curCookie["v_name"] = HttpUtility.UrlEncode("这里是中文", Encoding.Unicode);
current.Response.Cookies.Add(curCookie);
kerryjiang commented 9 years ago

Try this fix by yourself, I reverted it back because it is not compatible with .NET 3.5. I'll find a solution to merge this change! https://github.com/kerryjiang/SuperSocket/commit/7648a5023e1339429796371a146f34420f0e012f

tupunco commented 9 years ago

en. thx