React to BufferedHtmlContent changes
This changes all TagHelperContent methods to assume that input has NOT YET been encoded.
This commit is contained in:
parent
4fd866f340
commit
fcadbc9095
|
|
@ -125,6 +125,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override TagHelperContent AppendEncoded(string value)
|
||||||
|
{
|
||||||
|
Buffer.AppendEncoded(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override TagHelperContent AppendFormat([NotNull] string format, object arg0)
|
public override TagHelperContent AppendFormat([NotNull] string format, object arg0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,14 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||||
public abstract TagHelperContent Append(string value);
|
public abstract TagHelperContent Append(string value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends <paramref name="value"/> to the existing content. <paramref name="value"/> is assumed
|
||||||
|
/// to be an HTML encoded <see cref="string"/> and no further encoding will be performed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The <see cref="string"/> to be appended.</param>
|
||||||
|
/// <returns>A reference to this instance after the append operation has completed.</returns>
|
||||||
|
public abstract TagHelperContent AppendEncoded(string value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Appends the specified <paramref name="format"/> to the existing content after
|
/// Appends the specified <paramref name="format"/> to the existing content after
|
||||||
/// replacing the format item with the <see cref="string"/> representation of the
|
/// replacing the format item with the <see cref="string"/> representation of the
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,39 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
tagHelperContent.WriteTo(writer, new CommonTestEncoder());
|
tagHelperContent.WriteTo(writer, new CommonTestEncoder());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("Hello World", writer.ToString());
|
Assert.Equal("HtmlEncode[[Hello ]]HtmlEncode[[World]]", writer.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Append_WrittenAsEncoded()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var tagHelperContent = new DefaultTagHelperContent();
|
||||||
|
tagHelperContent.Append("Hi");
|
||||||
|
|
||||||
|
var writer = new StringWriter();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
tagHelperContent.WriteTo(writer, new CommonTestEncoder());
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal("HtmlEncode[[Hi]]", writer.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AppendEncoded_DoesNotGetEncoded()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var tagHelperContent = new DefaultTagHelperContent();
|
||||||
|
tagHelperContent.AppendEncoded("Hi");
|
||||||
|
|
||||||
|
var writer = new StringWriter();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
tagHelperContent.WriteTo(writer, new CommonTestEncoder());
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal("Hi", writer.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue