Remove AutoLink dependency
This commit is contained in:
@@ -37,18 +37,10 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AhoCorasick, Version=1.1.5577.36525, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AhoCorasick.1.1.5577.36525\lib\portable-net40+sl50+win+wpa81+wp80\AhoCorasick.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="AngleSharp, Version=0.9.6.41832, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AngleSharp.0.9.6\lib\net45\AngleSharp.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="AutoLink, Version=1.0.5595.30240, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoLink.1.0.5595.30240\lib\portable-net40+sl50+win+wpa81+wp80\AutoLink.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.2.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
@@ -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 => $@"<a href=""{m.Value}"">{m.Value}</a>", RegexOptions.IgnoreCase);
|
||||
if (autolinked != text.NodeValue)
|
||||
{
|
||||
var f = new HtmlParser().Parse(autolinked);
|
||||
@@ -2191,7 +2189,7 @@ rl(javascript:alert(""foo""))'>";
|
||||
};
|
||||
var html = @"<div>Click here: http://example.com/.</div>";
|
||||
Assert.That(sanitizer.Sanitize(html), Is.EqualTo(@"<div>Click here: <a href=""http://example.com/"">http://example.com/</a>.</div>").IgnoreCase);
|
||||
Assert.That(sanitizer.Sanitize("Check out www.google.com."), Is.EqualTo(@"Check out <a href=""http://www.google.com"">www.google.com</a>.").IgnoreCase);
|
||||
Assert.That(sanitizer.Sanitize("Check out https://www.google.com."), Is.EqualTo(@"Check out <a href=""https://www.google.com"">https://www.google.com</a>.").IgnoreCase);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AhoCorasick" version="1.1.5577.36525" targetFramework="net45" />
|
||||
<package id="AngleSharp" version="0.9.6" targetFramework="net45" />
|
||||
<package id="AutoLink" version="1.0.5595.30240" targetFramework="net45" />
|
||||
<package id="NUnit" version="3.2.1" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user