CodePointFilter parameterless ctor should be empty, not Basic Latin
This commit is contained in:
parent
0ca24147a0
commit
eb42bc51fb
|
|
@ -15,12 +15,11 @@ namespace Microsoft.Framework.WebEncoders
|
||||||
private AllowedCharsBitmap _allowedCharsBitmap;
|
private AllowedCharsBitmap _allowedCharsBitmap;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Instantiates the filter allowing only the 'Basic Latin' block of characters through.
|
/// Instantiates an empty filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CodePointFilter()
|
public CodePointFilter()
|
||||||
{
|
{
|
||||||
_allowedCharsBitmap = new AllowedCharsBitmap();
|
_allowedCharsBitmap = new AllowedCharsBitmap();
|
||||||
AllowBlock(UnicodeBlocks.BasicLatin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ namespace Microsoft.Framework.WebEncoders
|
||||||
HtmlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
HtmlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
||||||
if (encoder == null)
|
if (encoder == null)
|
||||||
{
|
{
|
||||||
encoder = new HtmlUnicodeEncoder(new CodePointFilter());
|
encoder = new HtmlUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
|
||||||
Volatile.Write(ref _basicLatinSingleton, encoder);
|
Volatile.Write(ref _basicLatinSingleton, encoder);
|
||||||
}
|
}
|
||||||
return encoder;
|
return encoder;
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.Framework.WebEncoders
|
||||||
JavaScriptStringUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
JavaScriptStringUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
||||||
if (encoder == null)
|
if (encoder == null)
|
||||||
{
|
{
|
||||||
encoder = new JavaScriptStringUnicodeEncoder(new CodePointFilter());
|
encoder = new JavaScriptStringUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
|
||||||
Volatile.Write(ref _basicLatinSingleton, encoder);
|
Volatile.Write(ref _basicLatinSingleton, encoder);
|
||||||
}
|
}
|
||||||
return encoder;
|
return encoder;
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace Microsoft.Framework.WebEncoders
|
||||||
UrlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
UrlUnicodeEncoder encoder = Volatile.Read(ref _basicLatinSingleton);
|
||||||
if (encoder == null)
|
if (encoder == null)
|
||||||
{
|
{
|
||||||
encoder = new UrlUnicodeEncoder(new CodePointFilter());
|
encoder = new UrlUnicodeEncoder(new CodePointFilter(UnicodeBlocks.BasicLatin));
|
||||||
Volatile.Write(ref _basicLatinSingleton, encoder);
|
Volatile.Write(ref _basicLatinSingleton, encoder);
|
||||||
}
|
}
|
||||||
return encoder;
|
return encoder;
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,13 @@ namespace Microsoft.Framework.WebEncoders
|
||||||
public class CodePointFilterTests
|
public class CodePointFilterTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Ctor_Parameterless_DefaultsToBasicLatin()
|
public void Ctor_Parameterless_CreatesEmptyFilter()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var filter = new CodePointFilter();
|
var filter = new CodePointFilter();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
for (int i = 0; i <= 0x007F; i++)
|
for (int i = 0; i <= Char.MaxValue; i++)
|
||||||
{
|
|
||||||
Assert.True(filter.IsCharacterAllowed((char)i));
|
|
||||||
}
|
|
||||||
for (int i = 0x0080; i <= Char.MaxValue; i++)
|
|
||||||
{
|
{
|
||||||
Assert.False(filter.IsCharacterAllowed((char)i));
|
Assert.False(filter.IsCharacterAllowed((char)i));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue