[Modify] Polish it
This commit is contained in:
parent
b8c12f93f7
commit
76ed2aede1
@ -761,12 +761,16 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
public static string HtmlAttributeEncode (string s)
|
public static string HtmlAttributeEncode (string s)
|
||||||
{
|
{
|
||||||
if (s == null || s.Length == 0 || !s.Contains ('&', '"', '<', '>'))
|
if (s == null)
|
||||||
return s;
|
return null;
|
||||||
|
|
||||||
var output = new StringBuilder ();
|
if (s.Length == 0)
|
||||||
foreach (var c in s)
|
return String.Empty;
|
||||||
output.Append (
|
|
||||||
|
var buff = new StringBuilder ();
|
||||||
|
|
||||||
|
foreach (var c in s) {
|
||||||
|
buff.Append (
|
||||||
c == '&'
|
c == '&'
|
||||||
? "&"
|
? "&"
|
||||||
: c == '"'
|
: c == '"'
|
||||||
@ -775,9 +779,11 @@ namespace WebSocketSharp.Net
|
|||||||
? "<"
|
? "<"
|
||||||
: c == '>'
|
: c == '>'
|
||||||
? ">"
|
? ">"
|
||||||
: c.ToString ());
|
: c.ToString ()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return output.ToString ();
|
return buff.ToString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HtmlAttributeEncode (string s, TextWriter output)
|
public static void HtmlAttributeEncode (string s, TextWriter output)
|
||||||
|
Loading…
Reference in New Issue
Block a user