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.
public void WriteTo(TextWriter writer, HtmlEncoder encoder)
{
var builder = writer as IHtmlContentBuilder;
if (builder != null)
var htmlTextWriter = writer as HtmlTextWriter;
if (htmlTextWriter != null)
{
// If possible, defer encoding until we're writing to the response.
// But there's little reason to keep this IHtmlContent instance around.
builder
.AppendHtml("<input name=\"")
.Append(_fieldName)
.AppendHtml("\" type=\"hidden\" value=\"")
.Append(_requestToken)
.AppendHtml("\" />");
htmlTextWriter.Write(this);
return;
}
writer.Write("<input name=\"");