Skip to content

Commit

Permalink
Update to AngleSharp 0.9.8.1 (fixes #80)
Browse files Browse the repository at this point in the history
  • Loading branch information
mganss committed Sep 19, 2016
2 parents 553b8dd + 70066eb commit 21590d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/HtmlSanitizer/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"keyFile": "HtmlSanitizer.snk"
},
"dependencies": {
"AngleSharp": "[0.9.7]"
"AngleSharp": "[0.9.8.1]"
},
"frameworks": {
"net45": {
Expand Down
26 changes: 24 additions & 2 deletions test/HtmlSanitizer.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using AngleSharp;
using AngleSharp.Dom.Css;

// Tests based on tests from http://roadkill.codeplex.com/

Expand Down Expand Up @@ -876,7 +877,7 @@ public void ImageStyleExpressionXSSTest()
string actual = sanitizer.Sanitize(htmlFragment);

// Assert
string expected = "<IMG>";
string expected = "<IMG style=\"\">";
Assert.Equal(expected, actual, ignoreCase: true);
}

Expand All @@ -896,7 +897,7 @@ public void AnchorTagStyleExpressionXSSTest()
string actual = sanitizer.Sanitize(htmlFragment);

// Assert
string expected = "exp/*<a></a>";
string expected = "exp/*<a style=\"\"></a>";
Assert.Equal(expected, actual, ignoreCase: true);
}

Expand Down Expand Up @@ -2744,6 +2745,27 @@ public void EscapeEntityInAttributeValueTest()

Assert.Equal(@"<input type=""text"" name=""my_name"" value=""&lt;insert name&gt;"">", actual);
}

[Fact]
public void FontFaceTest()
{
// https://github.com/mganss/HtmlSanitizer/issues/80

var s = new HtmlSanitizer();

s.AllowDataAttributes = true;
s.AllowedAtRules.Add(CssRuleType.FontFace);

s.AllowedTags.Add("style");

s.AllowedCssProperties.Add("src");
s.AllowedCssProperties.Add("font-family");

var html = @"<html><head><style>@font-face { font-family: FrutigerLTStd; src: url(""https://example.com/FrutigerLTStd-Light.otf"") format(""opentype"") }</style></head><body></body></html>";
var actual = s.SanitizeDocument(html);

Assert.Equal(html, actual);
}
}
}

Expand Down

0 comments on commit 21590d7

Please sign in to comment.