From c14d59a9ea70fbc4f05a31131a2cbfc233e18480 Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Sun, 5 Jun 2016 18:32:13 +0200 Subject: [PATCH] Remove AutoLink dependency --- HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj | 8 -------- HtmlSanitizer.Tests/Tests.cs | 6 ++---- HtmlSanitizer.Tests/packages.config | 2 -- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj b/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj index c7207af..23b7ecd 100644 --- a/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj +++ b/HtmlSanitizer.Tests/HtmlSanitizer.Tests.csproj @@ -37,18 +37,10 @@ 4 - - ..\packages\AhoCorasick.1.1.5577.36525\lib\portable-net40+sl50+win+wpa81+wp80\AhoCorasick.dll - True - ..\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.1\lib\net45\nunit.framework.dll True diff --git a/HtmlSanitizer.Tests/Tests.cs b/HtmlSanitizer.Tests/Tests.cs index 09ece97..8544f4d 100644 --- a/HtmlSanitizer.Tests/Tests.cs +++ b/HtmlSanitizer.Tests/Tests.cs @@ -1,7 +1,6 @@ using AngleSharp.Dom; using AngleSharp.Dom.Html; using AngleSharp.Parser.Html; -using Ganss.Text; using NUnit.Framework; using System; using System.Collections.Generic; @@ -2174,13 +2173,12 @@ rl(javascript:alert(""foo""))'>"; public void AutoLinkTest() { var sanitizer = new HtmlSanitizer(); - var autolink = new AutoLink(); sanitizer.PostProcessNode += (s, e) => { var text = e.Node as IText; if (text != null) { - var autolinked = autolink.Link(text.NodeValue); + var autolinked = Regex.Replace(text.NodeValue, @"https?://[^\s]+[^\s!?.:;,]+", m => $@"{m.Value}", RegexOptions.IgnoreCase); if (autolinked != text.NodeValue) { var f = new HtmlParser().Parse(autolinked); @@ -2191,7 +2189,7 @@ rl(javascript:alert(""foo""))'>"; }; var html = @"
Click here: http://example.com/.
"; Assert.That(sanitizer.Sanitize(html), Is.EqualTo(@"
Click here: http://example.com/.
").IgnoreCase); - Assert.That(sanitizer.Sanitize("Check out www.google.com."), Is.EqualTo(@"Check out www.google.com.").IgnoreCase); + Assert.That(sanitizer.Sanitize("Check out https://www.google.com."), Is.EqualTo(@"Check out https://www.google.com.").IgnoreCase); } [Test] diff --git a/HtmlSanitizer.Tests/packages.config b/HtmlSanitizer.Tests/packages.config index ad08135..ce8463e 100644 --- a/HtmlSanitizer.Tests/packages.config +++ b/HtmlSanitizer.Tests/packages.config @@ -1,7 +1,5 @@  - - \ No newline at end of file