Skip to content

Commit 551def2

Browse files
committed
adblock2privoxy: Update to version 2.2.0
* Remove unused debug code
1 parent c0e9100 commit 551def2

10 files changed

+91
-25
lines changed

adblock2privoxy-utils/adblock2privoxy-utils.cabal

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: adblock2privoxy-utils
2-
version: 2.1.1
2+
version: 2.2.0
33
cabal-version: >= 1.10
44
build-type: Simple
55
tested-with: GHC==8.10.7
@@ -45,4 +45,4 @@ source-repository this
4545
type: git
4646
location: https://github.com/essandess/adblock2privoxy.git
4747
subdir: adblock2privoxy-utils
48-
tag: v2.1.1
48+
tag: v2.2.0

adblock2privoxy/adblock2privoxy.cabal

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: adblock2privoxy
2-
version: 2.1.1
2+
version: 2.2.0
33
cabal-version: >= 1.10
44
build-type: Simple
55
tested-with:
@@ -103,4 +103,4 @@ source-repository this
103103
type: git
104104
location: https://github.com/essandess/adblock2privoxy.git
105105
subdir: adblock2privoxy
106-
tag: v2.1.1
106+
tag: v2.2.0

adblock2privoxy/changelog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.2.0
2+
* Remove unused debug code
3+
14
2.1.1
25
* Fix compilation issues for ghc 9.6.3
36

adblock2privoxy/src/ElementBlocker.hs

+8-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ elemBlock path info = writeElemBlock . elemBlockData
2525
writeElemBlock :: ElemBlockData -> IO ()
2626
writeElemBlock (ElemBlockData flatPatterns rulesTree) =
2727
do
28-
let debugPath = path </> "debug"
29-
filteredInfo = filter ((||) <$> not . startswith "Url:" <*> startswith "Url: http") info
28+
let filteredInfo = filter ((||) <$> not . startswith "Url:" <*> startswith "Url: http") info
29+
-- debugPath = path </> "debug"
3030
createDirectoryIfMissing True path
3131
cont <- getDirectoryContents path
3232
_ <- sequence $ removeOld <$> cont
33-
createDirectoryIfMissing True debugPath
33+
-- createDirectoryIfMissing True debugPath
3434
-- writeBlockTree path debugPath rulesTree
3535
writeBlockTree path rulesTree
36-
writePatterns_with_debug filteredInfo (path </> "ab2p.common.css") (debugPath </> "ab2p.common.css") flatPatterns
36+
writePatterns_with_debug filteredInfo (path </> "ab2p.common.css") "" flatPatterns
37+
-- writePatterns_with_debug filteredInfo (path </> "ab2p.common.css") (debugPath </> "ab2p.common.css") flatPatterns
3738
removeOld entry' =
3839
let entry = path </> entry'
3940
in do
@@ -64,9 +65,10 @@ elemBlock path info = writeElemBlock . elemBlockData
6465
writePatterns_with_debug _ _ _ [] = return ()
6566
writePatterns_with_debug info' normalFilename debugFilename patterns =
6667
do
67-
writeCssFile debugFilename $ intercalate "\n" $ (++ Templates.blockCss) <$> patterns
6868
writeCssFile normalFilename $ intercalate "\n" ((++ Templates.blockCss) . intercalate "," <$>
69-
splitEvery 4000 patterns)
69+
splitEvery 4000 patterns)
70+
when (debugFilename /= "") $
71+
writeCssFile debugFilename $ intercalate "\n" $ (++ Templates.blockCss) <$> patterns
7072
where
7173
splitEvery n = takeWhile (not . null) . unfoldr (Just . splitAt n)
7274
writeCssFile filename content =

adblock2privoxy/src/Paths_adblock2privoxy.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
3838
catchIO = Exception.catch
3939

4040
version :: Version
41-
version = Version [2,1,0] []
41+
version = Version [2,2,0] []
4242
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
4343

4444
bindir = "/opt/local/bin"

adblock2privoxy/src/Templates.hs

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ writeTemplateFiles outDir cssDomain useHTTP = do
4343
lns = lines content
4444
replace' line (from, to) = replace from to line
4545
filterLine line
46-
| null cssDomain && (startswith "[?CSS_DOMAIN]" line || startswith "[?CSS_DOMAIN_DEBUG]" line) = ""
47-
| otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[?CSS_DOMAIN_DEBUG]", "# "), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)]
46+
| null cssDomain && (startswith "[?CSS_DOMAIN]" line) = ""
47+
| otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)]
48+
-- | null cssDomain && (startswith "[?CSS_DOMAIN]" line || startswith "[?CSS_DOMAIN_DEBUG]" line) = ""
49+
-- | otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[?CSS_DOMAIN_DEBUG]", "# "), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)]
4850

4951
copySystem file = do
5052
dataDir <- getDataDir
51-
content <- readFile $ dataDir </> "templates" </> file
53+
content <- readFile $ dataDir </> "templates" </> file
5254
writeFile (outDir </> file) $ filterDomain content

adblock2privoxy/templates/ab2p.system.action

-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
{+set-image-blocker{blank} \
44
[?CSS_DOMAIN] +filter{ab2p-elemhide-filter} \
5-
+client-header-tagger{ab2p-elemhide-check-debug} \
65
+client-header-tagger{ab2p-handle-as-image-c} \
76
+server-header-tagger{ab2p-handle-as-image-s}}
87
/
98

10-
[?CSS_DOMAIN]{-filter{ab2p-elemhide-filter} \
11-
[?CSS_DOMAIN] +filter{ab2p-elemhide-filter-debug}}
12-
[?CSS_DOMAIN]TAG:^ab2p-elemhide-filter-debug$
13-
149
{+handle-as-image}
1510
TAG:^ab2p-handle-as-image$
1611

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#AbBlock system actions -- don't edit --
2+
3+
{+set-image-blocker{blank} \
4+
[?CSS_DOMAIN] +filter{ab2p-elemhide-filter} \
5+
+client-header-tagger{ab2p-elemhide-check-debug} \
6+
+client-header-tagger{ab2p-handle-as-image-c} \
7+
+server-header-tagger{ab2p-handle-as-image-s}}
8+
/
9+
10+
[?CSS_DOMAIN]{-filter{ab2p-elemhide-filter} \
11+
[?CSS_DOMAIN] +filter{ab2p-elemhide-filter-debug}}
12+
[?CSS_DOMAIN]TAG:^ab2p-elemhide-filter-debug$
13+
14+
{+handle-as-image}
15+
TAG:^ab2p-handle-as-image$
16+
17+
{+block{ adblock rules }}
18+
TAG:^ab2p-block-s$
19+
20+
{-block}
21+
TAG:^ab2p-unblock-u$
22+
23+
{-block}
24+
TAG:^ab2p-unblock-d$
25+
26+
{-block}
27+
TAG:^ab2p-unblock-s$
28+
29+
# Omit per GitHub issue #7
30+
# workaround for gzip handling privoxy bugs
31+
#{ +prevent-compression }
32+
#.yahoo.com
33+
#.amazon.com

adblock2privoxy/templates/ab2p.system.filter

-6
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ s@^accept(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti
2424
SERVER-HEADER-FILTER: ab2p-xframe-filter
2525
s@.*\sHTTP\/1.*@$&\r\nX-Frame-Options: DENY@i
2626

27-
[?CSS_DOMAIN_DEBUG]CLIENT-HEADER-TAGGER: ab2p-elemhide-check-debug
28-
[?CSS_DOMAIN_DEBUG]s@^cookie:.*ab2p-elemhide-filter-debug=true(?:;|$).*@ab2p-elemhide-filter-debug@Ti
29-
3027
[?CSS_DOMAIN]FILTER: ab2p-elemhide-filter
3128
[?CSS_DOMAIN]s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/ab2p.common.css"></link><link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/$host/ab2p.css"></link>@iUD
3229

33-
[?CSS_DOMAIN_DEBUG]FILTER: ab2p-elemhide-filter-debug
34-
[?CSS_DOMAIN_DEBUG]s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/debug/ab2p.common.css"></link><link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/$host.debug/ab2p.css"></link>@iUD
35-
3630
FILTER: ab2p-popup-filter
3731
s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<script type="text/javascript">parent==window&&opener&&close()</script>@iUD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#AbBlock system filters -- don't edit --
2+
3+
4+
SERVER-HEADER-TAGGER: ab2p-block-s
5+
s@.*@ab2p-block-s@Ti
6+
7+
8+
CLIENT-HEADER-TAGGER: ab2b-unblock-u
9+
s@user-agent.*@ab2p-unblock-u@Ti
10+
11+
SERVER-HEADER-TAGGER: ab2p-unblock-d
12+
s@date.*@ab2p-unblock-d@Ti
13+
14+
SERVER-HEADER-TAGGER: ab2p-unblock-s
15+
s@server.*@ab2p-unblock-s@Ti
16+
17+
18+
SERVER-HEADER-TAGGER: ab2p-handle-as-image-s
19+
s@^content-type(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti
20+
21+
CLIENT-HEADER-TAGGER: ab2p-handle-as-image-c
22+
s@^accept(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti
23+
24+
SERVER-HEADER-FILTER: ab2p-xframe-filter
25+
s@.*\sHTTP\/1.*@$&\r\nX-Frame-Options: DENY@i
26+
27+
[?CSS_DOMAIN_DEBUG]CLIENT-HEADER-TAGGER: ab2p-elemhide-check-debug
28+
[?CSS_DOMAIN_DEBUG]s@^cookie:.*ab2p-elemhide-filter-debug=true(?:;|$).*@ab2p-elemhide-filter-debug@Ti
29+
30+
[?CSS_DOMAIN]FILTER: ab2p-elemhide-filter
31+
[?CSS_DOMAIN]s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/ab2p.common.css"></link><link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/$host/ab2p.css"></link>@iUD
32+
33+
[?CSS_DOMAIN_DEBUG]FILTER: ab2p-elemhide-filter-debug
34+
[?CSS_DOMAIN_DEBUG]s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/debug/ab2p.common.css"></link><link rel="stylesheet" type="text/css" href="[CSS_PROTOCOL]://[CSS_DOMAIN]/$host.debug/ab2p.css"></link>@iUD
35+
36+
FILTER: ab2p-popup-filter
37+
s@[^'"\s]\s*<head[^>]*>(?=\s*[^'"\s])@$&<script type="text/javascript">parent==window&&opener&&close()</script>@iUD

0 commit comments

Comments
 (0)