From 0ec9e0557641a98c30c00259947140e40166aff3 Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Tue, 10 May 2016 13:23:30 +0200 Subject: [PATCH] Update AngleSharp Add tests --- .../HtmlSanitizer.Tests.csproj | 8 +- HtmlSanitizer.Tests/Tests.cs | 95 +++++++++++++++++++ HtmlSanitizer.Tests/packages.config | 4 +- HtmlSanitizer/HtmlSanitizer.csproj | 4 +- HtmlSanitizer/packages.config | 2 +- 5 files changed, 104 insertions(+), 9 deletions(-) diff --git a/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj b/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj index 7b23f85..c7207af 100644 --- a/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj +++ b/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj @@ -41,16 +41,16 @@ ..\packages\AhoCorasick.1.1.5577.36525\lib\portable-net40+sl50+win+wpa81+wp80\AhoCorasick.dll True - - ..\packages\AngleSharp.0.9.5\lib\net45\AngleSharp.dll + + ..\packages\AngleSharp.0.9.6\lib\net45\AngleSharp.dll True ..\packages\AutoLink.1.0.5595.30240\lib\portable-net40+sl50+win+wpa81+wp80\AutoLink.dll True - - ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll True diff --git a/HtmlSanitizer.Tests/Tests.cs b/HtmlSanitizer.Tests/Tests.cs index 3efbb2a..09ece97 100644 --- a/HtmlSanitizer.Tests/Tests.cs +++ b/HtmlSanitizer.Tests/Tests.cs @@ -2605,6 +2605,101 @@ @keyframes identifier { @page * { margin: 2cm } @keyframes identifier { 0% { top: 0 } 50% { top: 30px; left: 20px } 50% { top: 10px } 100% { top: 0 } }".Replace("\r\n", "\n"))); } + + [Test] + public void DataTest() + { + // https://github.com/mganss/HtmlSanitizer/issues/66 + + var sanitizer = new HtmlSanitizer(); + sanitizer.AllowDataAttributes = true; + sanitizer.AllowedSchemes.Add("data"); + sanitizer.RemovingAttribute += (s, e) => e.Cancel = e.Reason == RemoveReason.NotAllowedUrlValue && e.Attribute.Value.Length >= 0xfff0 && e.Attribute.Value.StartsWith("data:", StringComparison.OrdinalIgnoreCase); + var html = @"

+ +

+".Replace("\r\n", "\n"); + + var actual = sanitizer.Sanitize(html); + + Assert.That(actual, Is.EqualTo(html)); + } + + [Test] + public void UriHashTest() + { + var s = new HtmlSanitizer(); + var html = @"test"; + + var actual = s.Sanitize(html); + + Assert.That(actual, Is.EqualTo(html)); + } } } diff --git a/HtmlSanitizer.Tests/packages.config b/HtmlSanitizer.Tests/packages.config index eeaf108..ad08135 100644 --- a/HtmlSanitizer.Tests/packages.config +++ b/HtmlSanitizer.Tests/packages.config @@ -1,7 +1,7 @@  - + - + \ No newline at end of file diff --git a/HtmlSanitizer/HtmlSanitizer.csproj b/HtmlSanitizer/HtmlSanitizer.csproj index c4653fc..0932882 100644 --- a/HtmlSanitizer/HtmlSanitizer.csproj +++ b/HtmlSanitizer/HtmlSanitizer.csproj @@ -49,8 +49,8 @@ HtmlSanitizer.snk - - ..\packages\AngleSharp.0.9.5\lib\net45\AngleSharp.dll + + ..\packages\AngleSharp.0.9.6\lib\net45\AngleSharp.dll True diff --git a/HtmlSanitizer/packages.config b/HtmlSanitizer/packages.config index 0c1745a..63bd0ad 100644 --- a/HtmlSanitizer/packages.config +++ b/HtmlSanitizer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file