Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HtmlSanitizer once more - see #9803 #10000

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/NuSpecs/UmbracoCms.Web.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency id="Microsoft.Owin.Security.Cookies" version="[4.0.1,4.999999)" />
<dependency id="Microsoft.Owin.Security.OAuth" version="[4.0.1,4.999999)" />
<dependency id="System.Threading.Tasks.Dataflow" version="[4.9.0,4.999999)" />
<dependency id="HtmlSanitizer" version="[5.0.376,5.999999)" />
<dependency id="System.Text.Encoding.CodePages" version="[4.7.1,4.999999)" />

</group>

Expand Down
23 changes: 0 additions & 23 deletions src/Umbraco.Core/Constants-SvgSanitizer.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Umbraco.Core/Umbraco.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@
<Compile Include="CompositionExtensions_Essentials.cs" />
<Compile Include="CompositionExtensions_FileSystems.cs" />
<Compile Include="CompositionExtensions_Uniques.cs" />
<Compile Include="Constants-SvgSanitizer.cs" />
<Compile Include="Exceptions\PanicException.cs" />
<Compile Include="FactoryExtensions.cs" />
<Compile Include="Composing\RegisterFactory.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" />
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
10 changes: 0 additions & 10 deletions src/Umbraco.Web/Runtime/WebInitialComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
using Umbraco.Web.PropertyEditors;
using Umbraco.Core.Models;
using Umbraco.Web.Models;
using Ganss.XSS;

namespace Umbraco.Web.Runtime
{
Expand Down Expand Up @@ -140,15 +139,6 @@ public override void Compose(Composition composition)
composition.RegisterUnique<ISectionService, SectionService>();
composition.RegisterUnique<IDashboardService, DashboardService>();
composition.RegisterUnique<IIconService, IconService>();
composition.Register<IHtmlSanitizer>(_ =>
{
var sanitizer = new HtmlSanitizer();
sanitizer.AllowedAttributes.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Attributes);
sanitizer.AllowedCssProperties.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Attributes);
sanitizer.AllowedTags.UnionWith(Umbraco.Core.Constants.SvgSanitizer.Tags);
return sanitizer;
},Lifetime.Singleton);

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

// configure the container for web
Expand Down
8 changes: 2 additions & 6 deletions src/Umbraco.Web/Services/IconService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ganss.XSS;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
Expand All @@ -15,13 +14,11 @@ namespace Umbraco.Web.Services
public class IconService : IIconService
{
private readonly IGlobalSettings _globalSettings;
private readonly IHtmlSanitizer _htmlSanitizer;
private readonly IAppPolicyCache _cache;

public IconService(IGlobalSettings globalSettings, IHtmlSanitizer htmlSanitizer, AppCaches appCaches)
public IconService(IGlobalSettings globalSettings, AppCaches appCaches)
{
_globalSettings = globalSettings;
_htmlSanitizer = htmlSanitizer;
_cache = appCaches.RuntimeCache;
}

Expand Down Expand Up @@ -78,12 +75,11 @@ private IconModel CreateIconModel(string iconName, string iconPath)
try
{
var svgContent = System.IO.File.ReadAllText(iconPath);
var sanitizedString = _htmlSanitizer.Sanitize(svgContent);

var svg = new IconModel
{
Name = iconName,
SvgString = sanitizedString
SvgString = svgContent
};

return svg;
Expand Down
5 changes: 1 addition & 4 deletions src/Umbraco.Web/Umbraco.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
<PackageReference Include="Examine" Version="1.1.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
<PackageReference Include="HtmlSanitizer">
<Version>5.0.376</Version>
</PackageReference>
<PackageReference Include="ImageProcessor">
<Version>2.7.0.100</Version>
</PackageReference>
Expand Down Expand Up @@ -1299,7 +1296,7 @@
</PropertyGroup>
<ItemGroup>
<!-- we want to exclude all facade references ?! -->
<FixedReferencePath Include="@(ReferencePath)" Condition="'%(ReferencePath.FileName)' != 'System.ValueTuple' and '%(ReferencePath.FileName)' != 'System.Net.Http' and '%(ReferencePath.FileName)' != 'System.Text.Encoding.CodePages'" />
<FixedReferencePath Include="@(ReferencePath)" Condition="'%(ReferencePath.FileName)' != 'System.ValueTuple' and '%(ReferencePath.FileName)' != 'System.Net.Http'" />
</ItemGroup>
<Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
<!--
Expand Down