CodePointFilter parameterless ctor should be empty, not Basic Latin

This commit is contained in:
Levi B 2015-02-27 11:28:40 -08:00
parent 0ca24147a0
commit eb42bc51fb
5 changed files with 6 additions and 11 deletions

View File

@ -15,12 +15,11 @@ namespace Microsoft.Framework.WebEncoders
private AllowedCharsBitmap _allowedCharsBitmap;
/// <summary>
/// Instantiates the filter allowing only the 'Basic Latin' block of characters through.
/// Instantiates an empty filter.
/// </summary>
public CodePointFilter()
{
_allowedCharsBitmap = new AllowedCharsBitmap();
AllowBlock(UnicodeBlocks.BasicLatin);
}
/// <summary>

View File

@ -120,7 +120,7 @@ namespace Microsoft.Framework.WebEncoders
HtmlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
if (encoder == null)
{
encoder = new HtmlUnicodeEncoder(new CodePointFilter());
encoder = new HtmlUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
Volatile.Write(ref _basicLatinSingleton, encoder);
}
return encoder;

View File

@ -124,7 +124,7 @@ namespace Microsoft.Framework.WebEncoders
JavaScriptStringUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
if (encoder == null)
{
encoder = new JavaScriptStringUnicodeEncoder(new CodePointFilter());
encoder = new JavaScriptStringUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
Volatile.Write(ref _basicLatinSingleton, encoder);
}
return encoder;

View File

@ -163,7 +163,7 @@ namespace Microsoft.Framework.WebEncoders
UrlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
if (encoder == null)
{
encoder = new UrlUnicodeEncoder(new CodePointFilter());
encoder = new UrlUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
Volatile.Write(ref _basicLatinSingleton, encoder);
}
return encoder;

View File

@ -11,17 +11,13 @@ namespace Microsoft.Framework.WebEncoders
public class CodePointFilterTests
{
[Fact]
public void Ctor_Parameterless_DefaultsToBasicLatin()
public void Ctor_Parameterless_CreatesEmptyFilter()
{
// Act
var filter = new CodePointFilter();
// Assert
for (int i = 0; i <= 0x007F; i++)
{
Assert.True(filter.IsCharacterAllowed((char)i));
}
for (int i = 0x0080; i <= Char.MaxValue; i++)
for (int i = 0; i <= Char.MaxValue; i++)
{
Assert.False(filter.IsCharacterAllowed((char)i));
}