privoxy-adblock icon indicating copy to clipboard operation
privoxy-adblock copied to clipboard

Syntax Error in Resulting .action

Open faxotherapy opened this issue 9 years ago • 3 comments

What I realised is that converting EasyList into Privoxy syntax is not that straightforward. Sure, privoxy-adblock deals correctly with the template format used by Privoxy for custom filters and blocking, but doesn't seem to use the proper syntax for most of the entries found in the resulting .action file.

Also, if my understanding is right, EasyList supposes that Adblock Plus does not make any difference between a domain or path; any string matched will be blocked. On the other hand, Privoxy does make a difference between domain and path.

One notable example: if it’s a path, Adblock Plus doesn’t care whether string matching targets the root folder of the site or any location further down the tree. Privoxy does care.

In Privoxy, if an entry does not start with a slash (/) then the entry is deemed as part of the domain name.

Privoxy doc dealing with the above is found at here.

Based on those considerations, I created an add-on to privoxy-adblock to make the resulting lists perfectly compatible with Privoxy. Because Privoxy has two different syntaxes for domain and path, I built the add-on so it deems a malformed entry as domain or path based on a « no non-sense » approach by simply modifying the syntax, so that the amended entry is understood by Privoxy.

Example:

\.com/ads/
.adserver\.com
&ad_id
\.pop-ads\.
/ads/

will become…

.com/ads/
.adserver.com
/.*&ad_id
/.*\.pop-ads\. 
/(.*/)?ads

The use of /(.*/)? gives a chance for the pattern to be matched further down the path.

The resulting files obtained from the add-on have been successfully integrated in Privoxy and no syntax error was detected, contrary to the situation where the add-on wouldn’t be applied afterwards. Currently the add-on is called from my « master » script, which consist of privoxy-adblock script and the add-on.

Also, I must mentioned that there is a certain number of syntax errors in the generated filters that relate to substitution, but it’s not important for the moment. I was more interesting in path blocking.

There seems to be an excellent alternative to the one you based your script: adblock2privoxy package

I’m active on the forum PrxBx; my member name is Faxopita.

faxotherapy avatar Dec 27 '15 13:12 faxotherapy

Never dead. Just send your pull requests and I'll check them

skroll avatar Mar 18 '16 04:03 skroll

I discussed this topic on this site under the name Faxopita and offered a script to rectify privoxy-adblock output.

faxotherapy avatar Mar 22 '16 16:03 faxotherapy