[Modify] Add it

This commit is contained in:
sta 2018-10-02 19:42:58 +09:00
parent b740ea771d
commit 0cd36dc615

View File

@ -178,6 +178,29 @@ namespace WebSocketSharp.Net
return buff.ToString (); return buff.ToString ();
} }
private static string htmlEncode (string s, bool attribute)
{
var buff = new StringBuilder ();
foreach (var c in s) {
buff.Append (
c == '"'
? """
: c == '&'
? "&"
: c == '<'
? "&lt;"
: c == '>'
? "&gt;"
: !attribute && c > 159
? String.Format ("&#{0};", (int) c)
: c.ToString ()
);
}
return buff.ToString ();
}
private static void initEntities () private static void initEntities ()
{ {
// Build the dictionary of HTML entity references. // Build the dictionary of HTML entity references.