diff --git a/adblock2privoxy-utils/adblock2privoxy-utils.cabal b/adblock2privoxy-utils/adblock2privoxy-utils.cabal index 5ad905935..4e4990365 100644 --- a/adblock2privoxy-utils/adblock2privoxy-utils.cabal +++ b/adblock2privoxy-utils/adblock2privoxy-utils.cabal @@ -1,5 +1,5 @@ name: adblock2privoxy-utils -version: 2.1.1 +version: 2.2.0 cabal-version: >= 1.10 build-type: Simple tested-with: GHC==8.10.7 @@ -45,4 +45,4 @@ source-repository this type: git location: https://github.com/essandess/adblock2privoxy.git subdir: adblock2privoxy-utils - tag: v2.1.1 + tag: v2.2.0 diff --git a/adblock2privoxy/adblock2privoxy.cabal b/adblock2privoxy/adblock2privoxy.cabal index d43188324..a23538cd1 100644 --- a/adblock2privoxy/adblock2privoxy.cabal +++ b/adblock2privoxy/adblock2privoxy.cabal @@ -1,5 +1,5 @@ name: adblock2privoxy -version: 2.1.1 +version: 2.2.0 cabal-version: >= 1.10 build-type: Simple tested-with: @@ -103,4 +103,4 @@ source-repository this type: git location: https://github.com/essandess/adblock2privoxy.git subdir: adblock2privoxy - tag: v2.1.1 + tag: v2.2.0 diff --git a/adblock2privoxy/changelog b/adblock2privoxy/changelog index eef3d3d88..3ab8a7757 100644 --- a/adblock2privoxy/changelog +++ b/adblock2privoxy/changelog @@ -1,3 +1,6 @@ +2.2.0 + * Remove unused debug code + 2.1.1 * Fix compilation issues for ghc 9.6.3 diff --git a/adblock2privoxy/src/ElementBlocker.hs b/adblock2privoxy/src/ElementBlocker.hs index ba549a971..0aaec6e80 100644 --- a/adblock2privoxy/src/ElementBlocker.hs +++ b/adblock2privoxy/src/ElementBlocker.hs @@ -25,15 +25,16 @@ elemBlock path info = writeElemBlock . elemBlockData writeElemBlock :: ElemBlockData -> IO () writeElemBlock (ElemBlockData flatPatterns rulesTree) = do - let debugPath = path "debug" - filteredInfo = filter ((||) <$> not . startswith "Url:" <*> startswith "Url: http") info + let filteredInfo = filter ((||) <$> not . startswith "Url:" <*> startswith "Url: http") info + -- debugPath = path "debug" createDirectoryIfMissing True path cont <- getDirectoryContents path _ <- sequence $ removeOld <$> cont - createDirectoryIfMissing True debugPath + -- createDirectoryIfMissing True debugPath -- writeBlockTree path debugPath rulesTree writeBlockTree path rulesTree - writePatterns_with_debug filteredInfo (path "ab2p.common.css") (debugPath "ab2p.common.css") flatPatterns + writePatterns_with_debug filteredInfo (path "ab2p.common.css") "" flatPatterns + -- writePatterns_with_debug filteredInfo (path "ab2p.common.css") (debugPath "ab2p.common.css") flatPatterns removeOld entry' = let entry = path entry' in do @@ -64,9 +65,10 @@ elemBlock path info = writeElemBlock . elemBlockData writePatterns_with_debug _ _ _ [] = return () writePatterns_with_debug info' normalFilename debugFilename patterns = do - writeCssFile debugFilename $ intercalate "\n" $ (++ Templates.blockCss) <$> patterns writeCssFile normalFilename $ intercalate "\n" ((++ Templates.blockCss) . intercalate "," <$> - splitEvery 4000 patterns) + splitEvery 4000 patterns) + when (debugFilename /= "") $ + writeCssFile debugFilename $ intercalate "\n" $ (++ Templates.blockCss) <$> patterns where splitEvery n = takeWhile (not . null) . unfoldr (Just . splitAt n) writeCssFile filename content = diff --git a/adblock2privoxy/src/Paths_adblock2privoxy.hs b/adblock2privoxy/src/Paths_adblock2privoxy.hs index 591d3e230..b9b1698fa 100644 --- a/adblock2privoxy/src/Paths_adblock2privoxy.hs +++ b/adblock2privoxy/src/Paths_adblock2privoxy.hs @@ -38,7 +38,7 @@ catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a catchIO = Exception.catch version :: Version -version = Version [2,1,0] [] +version = Version [2,2,0] [] bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath bindir = "/opt/local/bin" diff --git a/adblock2privoxy/src/Templates.hs b/adblock2privoxy/src/Templates.hs index c02b57b07..84d98a998 100644 --- a/adblock2privoxy/src/Templates.hs +++ b/adblock2privoxy/src/Templates.hs @@ -43,10 +43,12 @@ writeTemplateFiles outDir cssDomain useHTTP = do lns = lines content replace' line (from, to) = replace from to line filterLine line - | null cssDomain && (startswith "[?CSS_DOMAIN]" line || startswith "[?CSS_DOMAIN_DEBUG]" line) = "" - | otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[?CSS_DOMAIN_DEBUG]", "# "), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)] + | null cssDomain && (startswith "[?CSS_DOMAIN]" line) = "" + | otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)] + -- | null cssDomain && (startswith "[?CSS_DOMAIN]" line || startswith "[?CSS_DOMAIN_DEBUG]" line) = "" + -- | otherwise = foldl replace' line [("[?CSS_DOMAIN]", ""), ("[?CSS_DOMAIN_DEBUG]", "# "), ("[CSS_DOMAIN]", cssDomain), ("[CSS_PROTOCOL]", cssProtocol useHTTP)] copySystem file = do dataDir <- getDataDir - content <- readFile $ dataDir "templates" file + content <- readFile $ dataDir "templates" file writeFile (outDir file) $ filterDomain content diff --git a/adblock2privoxy/templates/ab2p.system.action b/adblock2privoxy/templates/ab2p.system.action index 8c1e97ffe..136283821 100644 --- a/adblock2privoxy/templates/ab2p.system.action +++ b/adblock2privoxy/templates/ab2p.system.action @@ -2,15 +2,10 @@ {+set-image-blocker{blank} \ [?CSS_DOMAIN] +filter{ab2p-elemhide-filter} \ - +client-header-tagger{ab2p-elemhide-check-debug} \ +client-header-tagger{ab2p-handle-as-image-c} \ +server-header-tagger{ab2p-handle-as-image-s}} / -[?CSS_DOMAIN]{-filter{ab2p-elemhide-filter} \ -[?CSS_DOMAIN] +filter{ab2p-elemhide-filter-debug}} -[?CSS_DOMAIN]TAG:^ab2p-elemhide-filter-debug$ - {+handle-as-image} TAG:^ab2p-handle-as-image$ diff --git a/adblock2privoxy/templates/ab2p.system.action.debug b/adblock2privoxy/templates/ab2p.system.action.debug new file mode 100644 index 000000000..8c1e97ffe --- /dev/null +++ b/adblock2privoxy/templates/ab2p.system.action.debug @@ -0,0 +1,33 @@ +#AbBlock system actions -- don't edit -- + +{+set-image-blocker{blank} \ +[?CSS_DOMAIN] +filter{ab2p-elemhide-filter} \ + +client-header-tagger{ab2p-elemhide-check-debug} \ + +client-header-tagger{ab2p-handle-as-image-c} \ + +server-header-tagger{ab2p-handle-as-image-s}} +/ + +[?CSS_DOMAIN]{-filter{ab2p-elemhide-filter} \ +[?CSS_DOMAIN] +filter{ab2p-elemhide-filter-debug}} +[?CSS_DOMAIN]TAG:^ab2p-elemhide-filter-debug$ + +{+handle-as-image} +TAG:^ab2p-handle-as-image$ + +{+block{ adblock rules }} +TAG:^ab2p-block-s$ + +{-block} +TAG:^ab2p-unblock-u$ + +{-block} +TAG:^ab2p-unblock-d$ + +{-block} +TAG:^ab2p-unblock-s$ + +# Omit per GitHub issue #7 +# workaround for gzip handling privoxy bugs +#{ +prevent-compression } +#.yahoo.com +#.amazon.com diff --git a/adblock2privoxy/templates/ab2p.system.filter b/adblock2privoxy/templates/ab2p.system.filter index c891823bc..61de808e5 100644 --- a/adblock2privoxy/templates/ab2p.system.filter +++ b/adblock2privoxy/templates/ab2p.system.filter @@ -24,14 +24,8 @@ s@^accept(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti SERVER-HEADER-FILTER: ab2p-xframe-filter s@.*\sHTTP\/1.*@$&\r\nX-Frame-Options: DENY@i -[?CSS_DOMAIN_DEBUG]CLIENT-HEADER-TAGGER: ab2p-elemhide-check-debug -[?CSS_DOMAIN_DEBUG]s@^cookie:.*ab2p-elemhide-filter-debug=true(?:;|$).*@ab2p-elemhide-filter-debug@Ti - [?CSS_DOMAIN]FILTER: ab2p-elemhide-filter [?CSS_DOMAIN]s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD -[?CSS_DOMAIN_DEBUG]FILTER: ab2p-elemhide-filter-debug -[?CSS_DOMAIN_DEBUG]s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD - FILTER: ab2p-popup-filter s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD diff --git a/adblock2privoxy/templates/ab2p.system.filter.debug b/adblock2privoxy/templates/ab2p.system.filter.debug new file mode 100644 index 000000000..c891823bc --- /dev/null +++ b/adblock2privoxy/templates/ab2p.system.filter.debug @@ -0,0 +1,37 @@ +#AbBlock system filters -- don't edit -- + + +SERVER-HEADER-TAGGER: ab2p-block-s +s@.*@ab2p-block-s@Ti + + +CLIENT-HEADER-TAGGER: ab2b-unblock-u +s@user-agent.*@ab2p-unblock-u@Ti + +SERVER-HEADER-TAGGER: ab2p-unblock-d +s@date.*@ab2p-unblock-d@Ti + +SERVER-HEADER-TAGGER: ab2p-unblock-s +s@server.*@ab2p-unblock-s@Ti + + +SERVER-HEADER-TAGGER: ab2p-handle-as-image-s +s@^content-type(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti + +CLIENT-HEADER-TAGGER: ab2p-handle-as-image-c +s@^accept(?=:[\s\w]*image\/):.*@ab2p-handle-as-image@Ti + +SERVER-HEADER-FILTER: ab2p-xframe-filter +s@.*\sHTTP\/1.*@$&\r\nX-Frame-Options: DENY@i + +[?CSS_DOMAIN_DEBUG]CLIENT-HEADER-TAGGER: ab2p-elemhide-check-debug +[?CSS_DOMAIN_DEBUG]s@^cookie:.*ab2p-elemhide-filter-debug=true(?:;|$).*@ab2p-elemhide-filter-debug@Ti + +[?CSS_DOMAIN]FILTER: ab2p-elemhide-filter +[?CSS_DOMAIN]s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD + +[?CSS_DOMAIN_DEBUG]FILTER: ab2p-elemhide-filter-debug +[?CSS_DOMAIN_DEBUG]s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD + +FILTER: ab2p-popup-filter +s@[^'"\s]\s*]*>(?=\s*[^'"\s])@$&@iUD