Fix broken code path in antiforgery

This commit is contained in:
Ryan Nowak 2016-02-05 14:07:54 -08:00
parent 7d1d7bc19c
commit 44834debeb
1 changed files with 4 additions and 9 deletions

View File

@ -57,17 +57,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
// _fieldName containing almost any character. // _fieldName containing almost any character.
public void WriteTo(TextWriter writer, HtmlEncoder encoder) public void WriteTo(TextWriter writer, HtmlEncoder encoder)
{ {
var builder = writer as IHtmlContentBuilder; var htmlTextWriter = writer as HtmlTextWriter;
if (builder != null) if (htmlTextWriter != null)
{ {
// If possible, defer encoding until we're writing to the response. // If possible, defer encoding until we're writing to the response.
// But there's little reason to keep this IHtmlContent instance around. htmlTextWriter.Write(this);
builder return;
.AppendHtml("<input name=\"")
.Append(_fieldName)
.AppendHtml("\" type=\"hidden\" value=\"")
.Append(_requestToken)
.AppendHtml("\" />");
} }
writer.Write("<input name=\""); writer.Write("<input name=\"");