[Modify] Replace it
This commit is contained in:
parent
f8a70130e7
commit
126744f36e
@ -1027,45 +1027,7 @@ namespace WebSocketSharp.Net
|
|||||||
if (s == null)
|
if (s == null)
|
||||||
throw new ArgumentNullException ("s");
|
throw new ArgumentNullException ("s");
|
||||||
|
|
||||||
if (s.Length == 0)
|
return s.Length > 0 ? htmlEncode (s) : s;
|
||||||
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 ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HtmlEncode (string s, TextWriter output)
|
public static void HtmlEncode (string s, TextWriter output)
|
||||||
|
Loading…
Reference in New Issue
Block a user