Skip to content

Commit 5f49001

Browse files
committed
Fixes
Fixes #13 Fixes #12 Fixes #11 Fixes #10 Fixes #9
1 parent bc60381 commit 5f49001

13 files changed

Lines changed: 254 additions & 395 deletions

DistillNET/DistillNET.sln

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27004.2005
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DistillNET", "DistillNET\DistillNET.csproj", "{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}"
7-
EndProject
86
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{13CD8FD7-6903-4086-8BFB-504E41F3D12D}"
97
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DistillNET", "DistillNET\DistillNET.csproj", "{693840CA-EAF1-4718-BB1F-E2F9D6646E10}"
9+
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
1313
Release|Any CPU = Release|Any CPU
1414
EndGlobalSection
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}.Release|Any CPU.Build.0 = Release|Any CPU
2016
{13CD8FD7-6903-4086-8BFB-504E41F3D12D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2117
{13CD8FD7-6903-4086-8BFB-504E41F3D12D}.Debug|Any CPU.Build.0 = Debug|Any CPU
2218
{13CD8FD7-6903-4086-8BFB-504E41F3D12D}.Release|Any CPU.ActiveCfg = Release|Any CPU
2319
{13CD8FD7-6903-4086-8BFB-504E41F3D12D}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{693840CA-EAF1-4718-BB1F-E2F9D6646E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{693840CA-EAF1-4718-BB1F-E2F9D6646E10}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{693840CA-EAF1-4718-BB1F-E2F9D6646E10}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{693840CA-EAF1-4718-BB1F-E2F9D6646E10}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE
2727
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {ADAE59AE-F340-4AA4-AC19-A52D34052989}
30+
EndGlobalSection
2831
EndGlobal

DistillNET/DistillNET/App.config

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 19 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,23 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{66AEFE15-E2AC-4CE1-A83E-4E3E3CA2F9DE}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>DistillNET</RootNamespace>
11-
<AssemblyName>DistillNET</AssemblyName>
12-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15-
<NuGetPackageImportStamp>
16-
</NuGetPackageImportStamp>
17-
<TargetFrameworkProfile />
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
7+
<PackageLicenseUrl>https://www.mozilla.org/en-US/MPL/2.0/</PackageLicenseUrl>
8+
<PackageProjectUrl>https://github.com/TechnikEmpire/DistillNET</PackageProjectUrl>
9+
<RepositoryUrl>https://github.com/TechnikEmpire/DistillNET</RepositoryUrl>
10+
<Description>DistillNET is a library for matching and filtering HTTP requests and HTML response content using the Adblock Plus Filter format.</Description>
11+
<Copyright>Copyright © 2017 Jesse Nicholson</Copyright>
12+
<Version>1.4.4</Version>
13+
<Authors>Jesse Nicholson</Authors>
14+
<Company>Technik Empire</Company>
15+
<PackageTags>DistillNET Adblock AdblockPlus Adblock-Plus URL-Filter URL-Filtering Content-Filter Filter</PackageTags>
16+
<PackageReleaseNotes>Fixes several bugs affecting both performance and matching accuracy. We are back to pre-.NET Standard migration performance.</PackageReleaseNotes>
1817
</PropertyGroup>
19-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20-
<PlatformTarget>AnyCPU</PlatformTarget>
21-
<DebugSymbols>true</DebugSymbols>
22-
<DebugType>full</DebugType>
23-
<Optimize>false</Optimize>
24-
<OutputPath>bin\Debug\</OutputPath>
25-
<DefineConstants>TRACE;DEBUG;TE_FILTERING_VERIFY_RULE_DATA</DefineConstants>
26-
<ErrorReport>prompt</ErrorReport>
27-
<WarningLevel>4</WarningLevel>
28-
<Prefer32Bit>false</Prefer32Bit>
29-
</PropertyGroup>
30-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31-
<PlatformTarget>AnyCPU</PlatformTarget>
32-
<DebugType>pdbonly</DebugType>
33-
<Optimize>true</Optimize>
34-
<OutputPath>bin\Release\</OutputPath>
35-
<DefineConstants>TRACE;TE_FILTERING_VERIFY_RULE_DATA</DefineConstants>
36-
<ErrorReport>prompt</ErrorReport>
37-
<WarningLevel>4</WarningLevel>
38-
<Prefer32Bit>false</Prefer32Bit>
39-
</PropertyGroup>
40-
<PropertyGroup>
41-
<StartupObject />
42-
</PropertyGroup>
43-
<ItemGroup>
44-
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
45-
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
46-
<Private>True</Private>
47-
</Reference>
48-
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
49-
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
50-
<Private>True</Private>
51-
</Reference>
52-
<Reference Include="System" />
53-
<Reference Include="System.ComponentModel.DataAnnotations" />
54-
<Reference Include="System.Core" />
55-
<Reference Include="System.Data.SQLite, Version=1.0.105.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
56-
<HintPath>..\packages\System.Data.SQLite.Core.1.0.105.0\lib\net451\System.Data.SQLite.dll</HintPath>
57-
<Private>True</Private>
58-
</Reference>
59-
<Reference Include="System.Data.SQLite.EF6, Version=1.0.105.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
60-
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.105.0\lib\net451\System.Data.SQLite.EF6.dll</HintPath>
61-
<Private>True</Private>
62-
</Reference>
63-
<Reference Include="System.Data.SQLite.Linq, Version=1.0.105.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
64-
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.105.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath>
65-
<Private>True</Private>
66-
</Reference>
67-
<Reference Include="System.Runtime.Caching" />
68-
<Reference Include="System.Runtime.Serialization" />
69-
<Reference Include="System.Xml.Linq" />
70-
<Reference Include="System.Data.DataSetExtensions" />
71-
<Reference Include="Microsoft.CSharp" />
72-
<Reference Include="System.Data" />
73-
<Reference Include="System.Net.Http" />
74-
<Reference Include="System.Xml" />
75-
</ItemGroup>
76-
<ItemGroup>
77-
<Compile Include="Properties\AssemblyInfo.cs" />
78-
<Compile Include="DistillNET\Extensions\StringExtensions.cs" />
79-
<Compile Include="DistillNET\Filter.cs" />
80-
<Compile Include="DistillNET\FilterDbCollection.cs" />
81-
<Compile Include="DistillNET\HtmlFilter.cs" />
82-
<Compile Include="DistillNET\AbpFormatRuleParser.cs" />
83-
<Compile Include="DistillNET\UrlFilter.cs" />
84-
</ItemGroup>
18+
8519
<ItemGroup>
86-
<None Include="App.config" />
87-
<None Include="packages.config" />
20+
<PackageReference Include="Microsoft.Data.SQLite" Version="2.0.0" />
8821
</ItemGroup>
89-
<ItemGroup />
90-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
91-
<Import Project="..\packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets')" />
92-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
93-
<PropertyGroup>
94-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
95-
</PropertyGroup>
96-
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets'))" />
97-
</Target>
98-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
99-
Other similar extension points exist, see Microsoft.Common.targets.
100-
<Target Name="BeforeBuild">
101-
</Target>
102-
<Target Name="AfterBuild">
103-
</Target>
104-
-->
105-
</Project>
22+
23+
</Project>

DistillNET/DistillNET/DistillNET.nuspec

Lines changed: 0 additions & 27 deletions
This file was deleted.

DistillNET/DistillNET/DistillNET/AbpFormatRuleParser.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8+
#define USE_REFERER
9+
810
using DistillNET.Extensions;
911
using System;
1012
using System.Collections.Generic;
@@ -21,7 +23,7 @@ public class AbpFormatRuleParser
2123
private static char[] s_optionsDelim = new[] { ',' };
2224

2325
/// <summary>
24-
/// Delimiters used for splitting domains specified inthe URL filtering options "domains".
26+
/// Delimiters used for splitting domains specified in the URL filtering options "domains".
2527
/// </summary>
2628
private static char[] s_domainsDelim = new[] { '|' };
2729

@@ -227,11 +229,11 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
227229
string originalRuleCopy = rule;
228230

229231
string[] allOptions = null;
230-
HashSet<string> applicableReferers = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
231-
HashSet<string> exceptReferers = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
232+
List<string> applicableReferers = new List<string>();
233+
List<string> exceptReferers = new List<string>();
232234

233-
HashSet<string> applicableDomains = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
234-
HashSet<string> exceptionDomains = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
235+
List<string> applicableDomains = new List<string>();
236+
List<string> exceptionDomains = new List<string>();
235237

236238
// Trim off the leading "@@" chracters if it's an exception.
237239
if(isException)
@@ -261,17 +263,37 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
261263
var allOptLen = allOptions.Length;
262264
for(int i = 0; i < allOptLen; ++i)
263265
{
264-
if(allOptions[i].Length > 7 && allOptions[i][0] == 'd' && allOptions[i][7] == '=')
266+
if(allOptions[i].Length > 7 && allOptions[i][0] == 'd' && allOptions[i][6] == '=')
265267
{
266268
domainsOption = allOptions[i];
267269
allOptions[i] = string.Empty;
270+
271+
if(refererOption != null)
272+
{
273+
// No sense in scanning further when everything we could possibly need
274+
// has been captured out of this loop.
275+
break;
276+
}
277+
278+
continue;
268279
}
269280

281+
#if USE_REFERER
270282
if(allOptions[i].Length > 7 && allOptions[i][0] == 'r' && allOptions[i][7] == '=')
271283
{
272284
refererOption = allOptions[i];
273285
allOptions[i] = string.Empty;
286+
287+
if(domainsOption != null)
288+
{
289+
// No sense in scanning further when everything we could possibly need
290+
// has been captured out of this loop.
291+
break;
292+
}
293+
294+
continue;
274295
}
296+
#endif
275297
}
276298

277299
if(domainsOption != null)
@@ -283,7 +305,7 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
283305

284306
// Trim off the "domains=" part, then split by the domains delimiter, which is a
285307
// pipe.
286-
domainsOption = domainsOption.Substring(8);
308+
domainsOption = domainsOption.Substring(7);
287309
var rawDomains = domainsOption.Split(s_domainsDelim, StringSplitOptions.None);
288310

289311
// Get applicable and exception domains. Exception domains in the list start with tilde,
@@ -310,6 +332,7 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
310332
}
311333
}
312334

335+
#if USE_REFERER
313336
if(refererOption != null)
314337
{
315338
// If we got a referers option, split it out of the main options collection, as
@@ -345,6 +368,7 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
345368
}
346369
}
347370
}
371+
#endif
348372

349373
// Parse out the rest of the options.
350374
UrlFilter.UrlFilterOptions asOpt;

0 commit comments

Comments
 (0)