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

Improve the ABP regex handling #150

Open
SpencerIsGiddy opened this issue Apr 3, 2023 · 0 comments
Open

Improve the ABP regex handling #150

SpencerIsGiddy opened this issue Apr 3, 2023 · 0 comments

Comments

@SpencerIsGiddy
Copy link
Contributor

SpencerIsGiddy commented Apr 3, 2023

Creating an issue while the pull request is closed as it would be easier to discuss in an issue.

So I found out where I would need to modify the ABP regex because where I currently modified it was the incorrect location.

Currently the code here is where I’am assuming the change needs to be.

it could possibly be changed to…

def extractDomains(txt, rgx, groupindex):
    domainlist = set()
    regexc = re.compile(rgx, re.M)

    for match in re.finditer(regexc, txt):
        g = match.groups()
        if g is None or len(g) <= groupindex:
            continue
        g2 = g[groupindex]
        g2 = g2.strip()

        if g2.startswith("||") and g2.endswith("^"):
            domain = g2[2:-1].replace("^", "*")
            domain = "*." + domain
            domainlist.add(domain)

        else:
            if g2 and g2[-1] != '.':
                domainlist.add(g2)

    if len(domainlist) <= 0:
        return ""

    return "\n".join(domainlist)

This replacement should replace || with *. and removes the ^ or at least that’s the point of it so it will be treated like a standard wildcard entry. While this doesn’t address situations where there is an ending like $thirdparty, it will address the standard dns abp cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant