Skip to content

"Best-effort" conversion of full-regex rules to content-blocking format #156

@antonok-edm

Description

@antonok-edm
Collaborator

Currently, full-regex rules are ignored when converting to content-blocking syntax because the content-blocking specification's support for regex features is much worse than what is allowed in ABP-syntax rules.

It should still be possible to convert some rules, by first verifying that the required regex featureset for each is still supported in content-blocking format. However, there will always be rules that cannot be converted.

Activity

self-assigned this
on Feb 23, 2021
antonok-edm

antonok-edm commented on Feb 23, 2021

@antonok-edm
CollaboratorAuthor

We'd likely want to use the regex-syntax crate for this purpose - that is what's used internally in the actual regex crate.

antonok-edm

antonok-edm commented on Apr 3, 2025

@antonok-edm
CollaboratorAuthor

Just took another look at this. May be possible in theory, but the supported regex syntax is so minimal that it's not going to have much benefit.

Out of all of the current EasyList and EasyPrivacy lists, there are a grand total of 7 regex rules (4 in EasyList, 3 in EasyList Adult) that don't use the {...} repetition operator (which iOS cannot support).

Out of those 7, 4 use (...|...) disjunctions which iOS also cannot support.

Out of the remaining 3, one uses \d (unsupported). Another one is a $popup rule (unsupported).

Which leaves a grand total of 1 rule that even has a chance of a successful conversion:

/^https?:\/\/.*\/.*sw[0-9._].*/$script,xmlhttprequest,domain=1vag.com|4tube.com|adult-channels.com|analdin.com|biguz.net|bogrodius.com|chikiporn.com|fantasti.cc|fuqer.com|fux.com|hclips.com|heavy-r.com|hog.tv|megapornx.com|milfzr.com|mypornhere.com|porn555.com|pornchimp.com|pornerbros.com|pornj.com|pornl.com|pornototale.com|porntube.com|sexu.com|sss.xxx|thisav.com|titkino.net|tubepornclassic.com|tuberel.com|tubev.sex|txxx.com|vidmo.org|vpornvideos.com|xozilla.com|youporn.lc|youpornhub.it|yourdailypornstars.com

If we take the extra step of converting \d to [0-9], then we unlock support for this additional one rule:

/\/uploads\/[a-z]+\/\d\.gif$/$image,~third-party,domain=mangagun.net|nicomanga.com|rawinu.com|weloma.art|welovemanga.one

...and that's about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @antonok-edm

      Issue actions

        "Best-effort" conversion of full-regex rules to content-blocking format · Issue #156 · brave/adblock-rust