From 126744f36e0b5982445184a5811a0c3e41c95b44 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Oct 2018 19:53:34 +0900 Subject: [PATCH] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 40 +----------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 08abb41e..c436d9ff 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1027,45 +1027,7 @@ namespace WebSocketSharp.Net if (s == null) throw new ArgumentNullException ("s"); - if (s.Length == 0) - return s; - - var buff = new StringBuilder (); - - foreach (var c in s) { - if (c == '&') { - buff.Append ("&"); - continue; - } - - if (c == '"') { - buff.Append ("""); - continue; - } - - if (c == '<') { - buff.Append ("<"); - continue; - } - - if (c == '>') { - buff.Append (">"); - continue; - } - - if (c > 159) { - // MS .NET starts encoding with &# from 160 and stops at 255. - // We do not do that. One reason is the 65308/65310 unicode - // characters that look like '<' and '>'. - - buff.AppendFormat ("&#{0};", (int) c); - continue; - } - - buff.Append (c); - } - - return buff.ToString (); + return s.Length > 0 ? htmlEncode (s) : s; } public static void HtmlEncode (string s, TextWriter output)