Skip to content

Commit 1657344

Browse files
nzdevnul800sebastiaan
authored andcommitted
Fixes #9615 - Upgrade to Htmlsanitizer v5 (#9856)
1 parent cef1a73 commit 1657344

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

build/NuSpecs/UmbracoCms.Web.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency id="Microsoft.Owin.Security.Cookies" version="[4.0.1,4.999999)" />
4343
<dependency id="Microsoft.Owin.Security.OAuth" version="[4.0.1,4.999999)" />
4444
<dependency id="System.Threading.Tasks.Dataflow" version="[4.9.0,4.999999)" />
45-
<dependency id="HtmlSanitizer" version="[4.0.217,4.999999)" />
45+
<dependency id="HtmlSanitizer" version="[5.0.376,5.999999)" />
4646

4747
</group>
4848

src/Umbraco.Web/Runtime/WebInitialComposer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
using Umbraco.Web.PropertyEditors;
4141
using Umbraco.Core.Models;
4242
using Umbraco.Web.Models;
43+
using Ganss.XSS;
4344

4445
namespace Umbraco.Web.Runtime
4546
{
@@ -139,6 +140,14 @@ public override void Compose(Composition composition)
139140
composition.RegisterUnique<ISectionService, SectionService>();
140141
composition.RegisterUnique<IDashboardService, DashboardService>();
141142
composition.RegisterUnique<IIconService, IconService>();
143+
composition.Register<IHtmlSanitizer>(_ =>
144+
{
145+
var sanitizer = new HtmlSanitizer();
146+
sanitizer.AllowedAttributes.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Attributes);
147+
sanitizer.AllowedCssProperties.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Attributes);
148+
sanitizer.AllowedTags.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Tags);
149+
return sanitizer;
150+
},Lifetime.Singleton);
142151

143152
composition.RegisterUnique<IExamineManager>(factory => ExamineManager.Instance);
144153

src/Umbraco.Web/Umbraco.Web.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
6868
<PackageReference Include="HtmlSanitizer">
6969
<Version>4.0.217</Version>
70+
<Version>5.0.376</Version>
7071
</PackageReference>
7172
<PackageReference Include="ImageProcessor">
7273
<Version>2.7.0.100</Version>
@@ -1286,7 +1287,7 @@
12861287
</PropertyGroup>
12871288
<ItemGroup>
12881289
<!-- we want to exclude all facade references ?! -->
1289-
<FixedReferencePath Include="@(ReferencePath)" Condition="'%(ReferencePath.FileName)' != 'System.ValueTuple' and '%(ReferencePath.FileName)' != 'System.Net.Http'" />
1290+
<FixedReferencePath Include="@(ReferencePath)" Condition="'%(ReferencePath.FileName)' != 'System.ValueTuple' and '%(ReferencePath.FileName)' != 'System.Net.Http' and '%(ReferencePath.FileName)' != 'System.Text.Encoding.CodePages'" />
12901291
</ItemGroup>
12911292
<Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
12921293
<!--
@@ -1296,4 +1297,4 @@
12961297
<Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" />
12971298
</SGen>
12981299
</Target>
1299-
</Project>
1300+
</Project>

0 commit comments

Comments
 (0)