private static void HtmlAttributeEncodeInternal(string value, HttpWriter writer) { int pos = IndexOfHtmlAttributeEncodingChars(value, 0); if (pos == -1) { writer.Write(value); return; } int cch = value.Length; int startPos = 0; for (; ; ) { if (pos > startPos) { writer.WriteString(value, startPos, pos - startPos); } char ch = value[pos]; switch (ch) { case '"': writer.Write("""); break; case '\'': writer.Write("'"); break; case '&': writer.Write("&"); break; case '<': // Whidbey 32404: The character '<' is not valid in an XML attribute value. // (See the W3C XML rec). writer.Write("<"); break; } startPos = pos + 1; if (startPos >= cch) break; pos = IndexOfHtmlAttributeEncodingChars(value, startPos); if (pos == -1) { writer.WriteString(value, startPos, cch - startPos); break; } } }
private static void HtmlAttributeEncodeInternal(string value, HttpWriter writer) { int num = IndexOfHtmlAttributeEncodingChars(value, 0); if (num == -1) { writer.Write(value); return; } int length = value.Length; int index = 0; Label_001D: if (num > index) { writer.WriteString(value, index, num - index); } switch (value[num]) { case '&': writer.Write("&"); break; case '\'': writer.Write("'"); break; case '<': writer.Write("<"); break; case '"': writer.Write("""); break; } index = num + 1; if (index < length) { num = IndexOfHtmlAttributeEncodingChars(value, index); if (num != -1) { goto Label_001D; } writer.WriteString(value, index, length - index); } }