Skip to content

Commit c066b4f

Browse files
committed
Target net462 (fixes #573)
Implement VS suggestions
1 parent a438eaa commit c066b4f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ HtmlSanitizer
77
[![Sonarcloud Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=mganss_HtmlSanitizer&metric=alert_status)](https://sonarcloud.io/dashboard?id=mganss_HtmlSanitizer)
88

99
[![netstandard2.0](https://img.shields.io/badge/netstandard-2.0-brightgreen.svg)](https://img.shields.io/badge/netstandard-2.0-brightgreen.svg)
10-
[![net46](https://img.shields.io/badge/net-461-brightgreen.svg)](https://img.shields.io/badge/net-461-brightgreen.svg)
10+
[![net46](https://img.shields.io/badge/net-462-brightgreen.svg)](https://img.shields.io/badge/net-462-brightgreen.svg)
1111
[![net8.0](https://img.shields.io/badge/net-8.0-brightgreen.svg)](https://img.shields.io/badge/net-461-brightgreen.svg)
1212

1313
HtmlSanitizer is a .NET library for cleaning HTML fragments and documents from constructs that can lead to [XSS attacks](https://en.wikipedia.org/wiki/Cross-site_scripting).

src/HtmlSanitizer/HtmlSanitizer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ private void DoSanitize(IHtmlDocument dom, IParentNode context, string baseUrl =
559559
foreach (var removedClass in removedClasses)
560560
RemoveCssClass(tag, removedClass, RemoveReason.NotAllowedCssClass);
561561

562-
if (!tag.ClassList.Any())
562+
if (tag.ClassList.Length == 0)
563563
RemoveAttribute(tag, attribute, RemoveReason.ClassAttributeEmpty);
564564
}
565565
else if (!oldStyleEmpty && attribute.Name == StyleAttributeName && string.IsNullOrEmpty(attribute.Value))
@@ -658,7 +658,7 @@ private void DoPostProcess(IHtmlDocument dom, INode? context)
658658
{
659659
var e = new PostProcessNodeEventArgs(dom, node);
660660
OnPostProcessNode(e);
661-
if (e.ReplacementNodes.Any())
661+
if (e.ReplacementNodes.Count != 0)
662662
{
663663
((IChildNode)node).Replace([.. e.ReplacementNodes]);
664664
}

src/HtmlSanitizer/HtmlSanitizer.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<FileVersion>$(AppVeyor_Build_Version).0</FileVersion>
1111
<PackageVersion>$(AppVeyor_Build_Version)</PackageVersion>
1212
<Authors>Michael Ganss</Authors>
13-
<TargetFrameworks>net461;netstandard2.0;net8.0</TargetFrameworks>
13+
<TargetFrameworks>net462;netstandard2.0;net8.0</TargetFrameworks>
1414
<AssemblyName>HtmlSanitizer</AssemblyName>
1515
<AssemblyOriginatorKeyFile>HtmlSanitizer.snk</AssemblyOriginatorKeyFile>
1616
<SignAssembly>true</SignAssembly>
@@ -19,8 +19,8 @@
1919
<PackageTags>xss;anti;antixss;html;security</PackageTags>
2020
<PackageProjectUrl>https://github.com/mganss/HtmlSanitizer</PackageProjectUrl>
2121
<PackageLicenseExpression>MIT</PackageLicenseExpression>
22-
<PackageReadmeFile>README.md</PackageReadmeFile>
23-
<RepositoryType>git</RepositoryType>
22+
<PackageReadmeFile>README.md</PackageReadmeFile>
23+
<RepositoryType>git</RepositoryType>
2424
<RepositoryUrl>git://github.com/mganss/HtmlSanitizer</RepositoryUrl>
2525
<RootNamespace>Ganss.Xss</RootNamespace>
2626
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -32,6 +32,7 @@
3232
<LangVersion>preview</LangVersion>
3333
<Nullable>enable</Nullable>
3434
<WarningsAsErrors>nullable</WarningsAsErrors>
35+
<NoWarn>$(NoWarn);IDE0130;SYSLIB1045</NoWarn>
3536
</PropertyGroup>
3637

3738
<PropertyGroup Condition="'$(CI)' == 'True'">
@@ -42,9 +43,10 @@
4243
<PackageReference Include="AngleSharp" Version="[0.17.1]" />
4344
<PackageReference Include="AngleSharp.Css" Version="[0.17.0]" />
4445
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
46+
<PackageReference Include="System.ValueTuple" Version="4.6.1" />
4547
</ItemGroup>
4648

47-
<ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
49+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462'">
4850
<PackageReference Include="System.Collections.Immutable" Version="9.0.1" />
4951
</ItemGroup>
5052
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">

0 commit comments

Comments
 (0)