From 9e627cb7d863e116fe30896782d54f01a5bda2d4 Mon Sep 17 00:00:00 2001 From: michael-mason Date: Tue, 11 May 2021 10:53:27 +1000 Subject: [PATCH 1/4] upgrade google apis --- .../CollectionsOnline.Import.csproj | 28 ++++++++--------- src/CollectionsOnline.Import/packages.config | 10 +++---- .../Web.config | 20 ------------- .../CollectionsOnline.Tests.csproj | 30 +++++++++---------- src/CollectionsOnline.Tests/app.config | 2 +- src/CollectionsOnline.Tests/packages.config | 10 +++---- 6 files changed, 40 insertions(+), 60 deletions(-) delete mode 100644 src/CollectionsOnline.RedirectWebSite/Web.config diff --git a/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj b/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj index de2d5f16..2d7faa46 100644 --- a/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj +++ b/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj @@ -46,28 +46,28 @@ ..\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll True - - ..\packages\Google.Apis.1.9.3\lib\net40\Google.Apis.dll + + ..\packages\Google.Apis.1.51.0\lib\net45\Google.Apis.dll True - - ..\packages\Google.Apis.Auth.1.9.3\lib\net40\Google.Apis.Auth.dll + + ..\packages\Google.Apis.Auth.1.51.0\lib\net45\Google.Apis.Auth.dll True - - ..\packages\Google.Apis.Auth.1.9.3\lib\net40\Google.Apis.Auth.PlatformServices.dll + + ..\packages\Google.Apis.Auth.1.51.0\lib\net45\Google.Apis.Auth.PlatformServices.dll True - - ..\packages\Google.Apis.Core.1.9.3\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll + + ..\packages\Google.Apis.Core.1.51.0\lib\net45\Google.Apis.Core.dll True - - ..\packages\Google.Apis.1.9.3\lib\net40\Google.Apis.PlatformServices.dll + + ..\packages\Google.Apis.1.51.0\lib\net45\Google.Apis.PlatformServices.dll True - - ..\packages\Google.Apis.YouTube.v3.1.9.2.1540\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.YouTube.v3.dll + + ..\packages\Google.Apis.YouTube.v3.1.51.0.2294\lib\net45\Google.Apis.YouTube.v3.dll True @@ -93,8 +93,8 @@ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll True - - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll True diff --git a/src/CollectionsOnline.Import/packages.config b/src/CollectionsOnline.Import/packages.config index ea9d3a4d..3f3b2682 100644 --- a/src/CollectionsOnline.Import/packages.config +++ b/src/CollectionsOnline.Import/packages.config @@ -2,17 +2,17 @@ - - - - + + + + - + diff --git a/src/CollectionsOnline.RedirectWebSite/Web.config b/src/CollectionsOnline.RedirectWebSite/Web.config deleted file mode 100644 index 0098c7e9..00000000 --- a/src/CollectionsOnline.RedirectWebSite/Web.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj b/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj index 4e2f1c00..88ad4f25 100644 --- a/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj +++ b/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj @@ -53,28 +53,28 @@ False ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll - - ..\packages\Google.Apis.1.9.3\lib\net40\Google.Apis.dll + + ..\packages\Google.Apis.1.51.0\lib\net45\Google.Apis.dll True - - ..\packages\Google.Apis.Auth.1.9.3\lib\net40\Google.Apis.Auth.dll + + ..\packages\Google.Apis.Auth.1.51.0\lib\net45\Google.Apis.Auth.dll True - - ..\packages\Google.Apis.Auth.1.9.3\lib\net40\Google.Apis.Auth.PlatformServices.dll + + ..\packages\Google.Apis.Auth.1.51.0\lib\net45\Google.Apis.Auth.PlatformServices.dll True - - ..\packages\Google.Apis.Core.1.9.3\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll + + ..\packages\Google.Apis.Core.1.51.0\lib\net45\Google.Apis.Core.dll True - - ..\packages\Google.Apis.1.9.3\lib\net40\Google.Apis.PlatformServices.dll + + ..\packages\Google.Apis.1.51.0\lib\net45\Google.Apis.PlatformServices.dll True - - ..\packages\Google.Apis.YouTube.v3.1.9.2.1540\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.YouTube.v3.dll + + ..\packages\Google.Apis.YouTube.v3.1.51.0.2294\lib\net45\Google.Apis.YouTube.v3.dll True @@ -115,9 +115,9 @@ ..\packages\Nancy.Viewengines.Razor.1.4.1\lib\net40\Nancy.ViewEngines.Razor.dll True - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + True ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll diff --git a/src/CollectionsOnline.Tests/app.config b/src/CollectionsOnline.Tests/app.config index d8410b16..acbd8bc3 100644 --- a/src/CollectionsOnline.Tests/app.config +++ b/src/CollectionsOnline.Tests/app.config @@ -23,7 +23,7 @@ - + diff --git a/src/CollectionsOnline.Tests/packages.config b/src/CollectionsOnline.Tests/packages.config index 7de2eaed..8cd690a6 100644 --- a/src/CollectionsOnline.Tests/packages.config +++ b/src/CollectionsOnline.Tests/packages.config @@ -3,10 +3,10 @@ - - - - + + + + @@ -19,7 +19,7 @@ - + From ac8d033020159942fbabfadcda6f3d43d51d531d Mon Sep 17 00:00:00 2001 From: michael-mason Date: Tue, 11 May 2021 11:06:13 +1000 Subject: [PATCH 2/4] upgrade newtonsoft --- .../CollectionsOnline.WebSite.csproj | 6 +++--- src/CollectionsOnline.WebSite/Web.config | 2 +- src/CollectionsOnline.WebSite/packages.config | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj b/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj index 8a616929..72a25570 100644 --- a/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj +++ b/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj @@ -81,9 +81,9 @@ ..\packages\Nancy.Viewengines.Razor.1.4.1\lib\net40\Nancy.ViewEngines.Razor.dll True - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + True False diff --git a/src/CollectionsOnline.WebSite/Web.config b/src/CollectionsOnline.WebSite/Web.config index 195deb08..866f9314 100644 --- a/src/CollectionsOnline.WebSite/Web.config +++ b/src/CollectionsOnline.WebSite/Web.config @@ -55,7 +55,7 @@ - + diff --git a/src/CollectionsOnline.WebSite/packages.config b/src/CollectionsOnline.WebSite/packages.config index 29552bac..73277e31 100644 --- a/src/CollectionsOnline.WebSite/packages.config +++ b/src/CollectionsOnline.WebSite/packages.config @@ -10,7 +10,7 @@ - + From 70947bb83fb0f11c8324c3b385e944f7531914fc Mon Sep 17 00:00:00 2001 From: michael-mason Date: Tue, 11 May 2021 15:02:13 +1000 Subject: [PATCH 3/4] upgrade to .net framework 4.7.2 --- .../CollectionsOnline.Core.csproj | 2 +- src/CollectionsOnline.Import/App.config | 68 +++++++------- .../CollectionsOnline.Import.csproj | 2 +- .../CollectionsOnline.Tests.csproj | 2 +- src/CollectionsOnline.Tests/app.config | 72 +++++++-------- .../CollectionsOnline.WebSite.csproj | 2 +- src/CollectionsOnline.WebSite/Web.config | 92 +++++++++---------- 7 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj b/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj index d50dff96..6c43d175 100644 --- a/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj +++ b/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj @@ -9,7 +9,7 @@ Properties CollectionsOnline.Core CollectionsOnline.Core - v4.5.1 + v4.7.2 512 ..\ true diff --git a/src/CollectionsOnline.Import/App.config b/src/CollectionsOnline.Import/App.config index 945cc6c7..6391566c 100644 --- a/src/CollectionsOnline.Import/App.config +++ b/src/CollectionsOnline.Import/App.config @@ -1,59 +1,59 @@ - + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj b/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj index 2d7faa46..1a493ec4 100644 --- a/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj +++ b/src/CollectionsOnline.Import/CollectionsOnline.Import.csproj @@ -9,7 +9,7 @@ Properties CollectionsOnline.Import CollectionsOnline.Import - v4.5.1 + v4.7.2 512 ..\ true diff --git a/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj b/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj index 88ad4f25..92c49956 100644 --- a/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj +++ b/src/CollectionsOnline.Tests/CollectionsOnline.Tests.csproj @@ -11,7 +11,7 @@ Properties CollectionsOnline.Tests CollectionsOnline.Tests - v4.5.1 + v4.7.2 512 ..\ true diff --git a/src/CollectionsOnline.Tests/app.config b/src/CollectionsOnline.Tests/app.config index acbd8bc3..fb7d4b81 100644 --- a/src/CollectionsOnline.Tests/app.config +++ b/src/CollectionsOnline.Tests/app.config @@ -1,77 +1,77 @@ - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj b/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj index 72a25570..da296e28 100644 --- a/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj +++ b/src/CollectionsOnline.WebSite/CollectionsOnline.WebSite.csproj @@ -13,7 +13,7 @@ Properties CollectionsOnline.WebSite CollectionsOnline.WebSite - v4.5.1 + v4.7.2 true diff --git a/src/CollectionsOnline.WebSite/Web.config b/src/CollectionsOnline.WebSite/Web.config index 866f9314..a2244002 100644 --- a/src/CollectionsOnline.WebSite/Web.config +++ b/src/CollectionsOnline.WebSite/Web.config @@ -1,97 +1,97 @@ - + -
+
-
+
- - - - - - - - - + + + + + + + + + - - + + - - + + - + - + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + \ No newline at end of file From 4a2b233c923fa7200e704e147ebab53405528983 Mon Sep 17 00:00:00 2001 From: michael-mason Date: Tue, 11 May 2021 15:21:23 +1000 Subject: [PATCH 4/4] upgraded and modified htmlsanitizer - html sanitizer now keeps child nodes to avoid removing potentially relevant markup - added new test for html converter --- .../CollectionsOnline.Core.csproj | 22 +++++++++++++++++-- .../Utilities/HtmlConverter.cs | 8 ++++--- src/CollectionsOnline.Core/packages.config | 6 ++++- .../Core/Utilities/HtmlConverterTests.cs | 13 +++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj b/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj index 6c43d175..2e79c428 100644 --- a/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj +++ b/src/CollectionsOnline.Core/CollectionsOnline.Core.csproj @@ -33,16 +33,26 @@ 4 + + ..\packages\AngleSharp.0.15.0\lib\net472\AngleSharp.dll + True + + + ..\packages\AngleSharp.Css.0.15.0\lib\net472\AngleSharp.Css.dll + True + ..\packages\CsQuery.1.3.4\lib\net40\CsQuery.dll ..\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll - - ..\packages\HtmlSanitizer.2.0.5735.24296\lib\net40\HtmlSanitizer.dll + + ..\packages\HtmlSanitizer.5.0.404\lib\net46\HtmlSanitizer.dll True + + False ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll @@ -75,6 +85,14 @@ + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + True + + + ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll + True + diff --git a/src/CollectionsOnline.Core/Utilities/HtmlConverter.cs b/src/CollectionsOnline.Core/Utilities/HtmlConverter.cs index 7fa41ac6..7cb148b4 100644 --- a/src/CollectionsOnline.Core/Utilities/HtmlConverter.cs +++ b/src/CollectionsOnline.Core/Utilities/HtmlConverter.cs @@ -29,11 +29,13 @@ public static HtmlSanitizerResult HtmlSanitizer(string html) { var sanitizer = new HtmlSanitizer(DefaultAllowedTags, allowedAttributes:DefaultAllowedAttributes); + sanitizer.KeepChildNodes = true; + var result = new HtmlSanitizerResult(); - sanitizer.RemovingTag += ((s, e) => { result.HasRemovedTag = true; }); - sanitizer.RemovingStyle += ((s, e) => { result.HasRemovedStyle = true; }); - sanitizer.RemovingAttribute += ((s, e) => { result.HasRemovedAttribute = true; }); + sanitizer.RemovingTag += (s, e) => { result.HasRemovedTag = true; }; + sanitizer.RemovingStyle += (s, e) => { result.HasRemovedStyle = true; }; + sanitizer.RemovingAttribute += (s, e) => { result.HasRemovedAttribute = true; }; result.Html = sanitizer.Sanitize(html); diff --git a/src/CollectionsOnline.Core/packages.config b/src/CollectionsOnline.Core/packages.config index 21e9538a..540e30a3 100644 --- a/src/CollectionsOnline.Core/packages.config +++ b/src/CollectionsOnline.Core/packages.config @@ -1,11 +1,15 @@  + + + - + + \ No newline at end of file diff --git a/src/CollectionsOnline.Tests/Core/Utilities/HtmlConverterTests.cs b/src/CollectionsOnline.Tests/Core/Utilities/HtmlConverterTests.cs index 6edc1784..fef80255 100644 --- a/src/CollectionsOnline.Tests/Core/Utilities/HtmlConverterTests.cs +++ b/src/CollectionsOnline.Tests/Core/Utilities/HtmlConverterTests.cs @@ -19,5 +19,18 @@ public void HtmlToText_WithScientificName_ReturnsOnlyText() // Then result.ShouldBe("df Austriella corrugata (Deshayes, 1843)"); } + + [Fact] + public void HtmlSanitizer_WithMalformedHTML_ReturnsSanitizedHTML() + { + // Given + string result; + var html = @"

Peter Hunter OAM, Kodak Australasia Pty Ltd: Public Relations, 1961 - 1995

Early career in England

"; + + // When + result = HtmlConverter.HtmlSanitizer(html).Html; + + result.ShouldBe("

Peter Hunter OAM, Kodak Australasia Pty Ltd: Public Relations, 1961 - 1995

Early career in England

"); + } } } \ No newline at end of file