AdvancedBlocking: fixed null ref bug caused when url entry is returned null for simple/regex blocked domains.

This commit is contained in:
Shreyas Zare
2023-12-05 21:03:57 +05:30
parent d5558397fa
commit 5db0abc4e7

View File

@@ -539,14 +539,14 @@ namespace AdvancedBlocking
if (blockedRegex is null)
{
if (blockListUrl is not null)
if (blockListUrl.Uri is not null)
blockingReport += "; blockListUrl=" + blockListUrl.Uri.AbsoluteUri + "; domain=" + blockedDomain;
else
blockingReport += "; domain=" + blockedDomain;
}
else
{
if (blockListUrl is not null)
if (blockListUrl.Uri is not null)
blockingReport += "; regexBlockListUrl=" + blockListUrl.Uri.AbsoluteUri + "; regex=" + blockedRegex;
else
blockingReport += "; regex=" + blockedRegex;
@@ -674,6 +674,14 @@ namespace AdvancedBlocking
#region constructor
public UrlEntry(Uri uri, Group group)
{
_uri = uri;
_blockAsNxDomain = group.BlockAsNxDomain;
_aRecords = group.ARecords;
_aaaaRecords = group.AAAARecords;
}
public UrlEntry(JsonElement jsonUrl, Group group)
{
switch (jsonUrl.ValueKind)
@@ -980,7 +988,7 @@ namespace AdvancedBlocking
//found zone blocked
blockedDomain = foundZone1;
blockedRegex = null;
listUrl = null;
listUrl = new UrlEntry(null, this);
return true;
}
@@ -1000,7 +1008,7 @@ namespace AdvancedBlocking
//found pattern blocked
blockedDomain = null;
blockedRegex = blockedPattern1;
listUrl = null;
listUrl = new UrlEntry(null, this);
return true;
}