default.filter 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. #################################################################################
  2. #
  3. # File : default.filter
  4. #
  5. # Purpose : Rules to process the content of web pages
  6. #
  7. # Copyright : Written by and Copyright (C) 2001-2020 the
  8. # Privoxy team. https://www.privoxy.org/
  9. #
  10. # This program is free software; you can redistribute it
  11. # and/or modify it under the terms of the GNU General
  12. # Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at
  14. # your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will
  17. # be useful, but WITHOUT ANY WARRANTY; without even the
  18. # implied warranty of MERCHANTABILITY or FITNESS FOR A
  19. # PARTICULAR PURPOSE. See the GNU General Public
  20. # License for more details.
  21. #
  22. # The GNU General Public License should be included with
  23. # this file. If not, you can view it at
  24. # http://www.gnu.org/copyleft/gpl.html
  25. # or write to the Free Software Foundation, Inc., 59
  26. # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. #
  28. #################################################################################
  29. #
  30. # Syntax:
  31. #
  32. # Generally filters start with a line like "FILTER: name description".
  33. # They are then referrable from the actionsfile with +filter{name}
  34. #
  35. # FILTER marks a filter as content filter, other filter
  36. # types are CLIENT-HEADER-FILTER, CLIENT-HEADER-TAGGER,
  37. # SERVER-HEADER-FILTER and SERVER-HEADER-TAGGER.
  38. #
  39. # Inside the filters, write one Perl-Style substitution (job) per line.
  40. # Jobs that precede the first FILTER: line are ignored.
  41. #
  42. # For Details see the pcrs manpage contained in this distribution.
  43. # (and the perlre, perlop and pcre manpages)
  44. #
  45. # Note that you are free to choose the delimiter as you see fit.
  46. #
  47. # Note2: In addition to the Perl options gimsx, the following nonstandard
  48. # options are supported:
  49. #
  50. # 'U' turns the default to ungreedy matching. Add ? to quantifiers to
  51. # switch back to greedy.
  52. #
  53. # 'T' (trivial) prevents parsing for backreferences in the substitute.
  54. # Use if you want to include text like '$&' in your substitute without
  55. # quoting.
  56. #
  57. # 'D' (Dynamic) allows the use of variables. Supported variables are:
  58. # $host, $listen-address, $origin (the IP address the request came
  59. # from), $path and $url.
  60. #
  61. # Note that '$' is a bad choice as delimiter for dynamic filters as you
  62. # might end up with unintended variables if you use a variable name
  63. # directly after the delimiter. Variables will be resolved without
  64. # escaping anything, therefore you also have to be careful not to chose
  65. # delimiters that appear in the replacement text. For example '<' should
  66. # be save, while '?' will sooner or later cause conflicts with $url.
  67. #
  68. #################################################################################
  69. #################################################################################
  70. #
  71. # js-annoyances: Get rid of particularly annoying JavaScript abuse.
  72. #
  73. #################################################################################
  74. FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse.
  75. # Note: Most of these jobs would be safer if restricted to a
  76. # <script> context as in:
  77. #
  78. # s/(<script.*)nasty-item(?=.*<\/script>)/$1replacement/sigU
  79. #
  80. # but that would make them match only the first occurrence of
  81. # nasty-item in each <script>. We need nestable jobs!
  82. # Get rid of Javascript referrer tracking.
  83. # Test page: http://www.javascript-page.com/referrer.html
  84. #
  85. s|(?:\w+\.)+referrer|false.toString()|gisU
  86. # The status bar is for displaying link targets, not pointless blahblah
  87. #
  88. s@([\W]\s*)((?:this|window)\.(?:default)?status)\s*=\s*((['"]).*?\4)@$1$2 =\
  89. (typeof(this.href) != 'undefined')?($3 + ' URL: ' + this.href):($2)@ig
  90. s/(?:(?:this|window)\.(?:default)?status)\s*=\s*\w*\s*;//ig
  91. # Kill OnUnload popups. Yummy.
  92. # Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
  93. #
  94. s/(<body\s+[^>]*)onunload/$1never/siU
  95. s|(<script.*)window\.onunload(?=.*</script>)|$1never|sigU
  96. # If we allow window.open, we want normal window features:
  97. # Test: http://www.htmlgoodies.com/beyond/notitle.html
  98. #
  99. s/(open\s*\([^\)]+resizable=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  100. s/(open\s*\([^\)]+location=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  101. s/(open\s*\([^\)]+status=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  102. s/(open\s*\([^\)]+scroll(?:ing|bars)=)(["']?)(?:no|0)\2/$1$2auto$2/sigU
  103. s/(open\s*\([^\)]+menubar=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  104. s/(open\s*\([^\)]+toolbar=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  105. s/(open\s*\([^\)]+directories=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  106. s/(open\s*\([^\)]+fullscreen=)(["']?)(?:yes|1)\2/$1$2no$2/sigU
  107. s/(open\s*\([^\)]+always(?:raised|lowered)=)(["']?)(?:yes|1)\2/$1$2no$2/sigU
  108. s/(open\s*\([^\)]+z-?lock=)(["']?)(?:yes|1)\2/$1$2no$2/sigU
  109. s/(open\s*\([^\)]+hotkeys=)(["']?)(?:yes|1)\2/$1$2no$2/sigU
  110. s/(open\s*\([^\)]+titlebar=)(["']?)(?:no|0)\2/$1$2yes$2/sigU
  111. s/(open\s*\([^\)]+always(?:raised|lowered)=)(["']?)(?:yes|1)\2/$1$2no$2/sigU
  112. #################################################################################
  113. #
  114. # js-events: Kill JavaScript event bindings and timers (Radically destructive! Only for extra nasty sites).
  115. #
  116. #################################################################################
  117. FILTER: js-events Kill JavaScript event bindings and timers (Radically destructive! Only for extra nasty sites).
  118. s/(on|event\.)((mouse(over|out|down|up|move))|(un)?load|contextmenu|selectstart)/never/ig
  119. # Not events, but abused on the same type of sites:
  120. s/(alert|confirm)\s*\(/concat(/ig
  121. s/set(timeout|interval)\(/concat(/ig
  122. #################################################################################
  123. #
  124. # html-annoyances: Get rid of particularly annoying HTML abuse.
  125. #
  126. #################################################################################
  127. FILTER: html-annoyances Get rid of particularly annoying HTML abuse.
  128. # New browser windows (if allowed -- see no-popups filter below) should be
  129. # resizeable and have a location and status bar
  130. #
  131. s/(<a\s+href[^>]+resizable=)(['"]?)(?:no|0)\2/$1$2yes$2/igU
  132. s/(<a\s+href[^>]+location=)(['"]?)(?:no|0)\2/$1$2yes$2/igU
  133. s/(<a\s+href[^>]+status=)(['"]?)(?:no|0)\2/$1$2yes$2/igU
  134. s/(<a\s+href[^>]+scrolling=)(['"]?)(?:no|0)\2/$1$2auto$2/igU
  135. s/(<a\s+href[^>]+menubar=)(['"]?)(?:no|0)\2/$1$2yes$2/igU
  136. # The <BLINK> and <MARQUEE> tags were crimes!
  137. #
  138. s-</?(blink|marquee).*>--sigU
  139. #################################################################################
  140. #
  141. # content-cookies: Kill cookies that come in the HTML or JS content.
  142. #
  143. #################################################################################
  144. FILTER: content-cookies Kill cookies that come in the HTML or JS content.
  145. # JS cookies, except those used by antiadbuster.com to detect us:
  146. #
  147. s|(\w+\.)+cookie(?=[ \t\r\n]*=)(?!='aab)|ZappedCookie|ig
  148. # HTML cookies:
  149. #
  150. s|<meta\s+http-equiv=['"]?set-cookie.*>|<!-- ZappedCookie -->|igU
  151. #################################################################################
  152. #
  153. # refresh-tags: Kill automatic refresh tags if refresh time is larger than 9 seconds.
  154. #
  155. #################################################################################
  156. FILTER: refresh-tags Kill automatic refresh tags if refresh time is larger than 9 seconds.
  157. # Note: Only deactivates refreshes with more than 9 seconds delay to
  158. # preserve monster-stupid but common redirections via meta tags.
  159. #
  160. s@<meta\s+http-equiv\s*=\s*(['"]?)refresh\1\s+content\s*=\s*(['"]?)\d{2,}\s*(;(?:\s*url\s*=\s*)?([^>\2]*))?\2@<link rev="x-refresh" href="$4"@ig
  161. #################################################################################
  162. #
  163. # unsolicited-popups: Disable unsolicited pop-up windows.
  164. #
  165. #################################################################################
  166. FILTER: unsolicited-popups Disable only unsolicited pop-up windows.
  167. s+([^'"]\s*<head.*>)(?=\s*[^'"])+$1<script>function PrivoxyWindowOpen(){return(null);}</script>+isU
  168. s@([^\w\s.]\s*)((?:map)?(window|this|parent)\.?)?open\s*\(@$1PrivoxyWindowOpen(@ig
  169. s+([^'"]\s*</html>)(?!\s*(\\n|'|"))+$1<script>function PrivoxyWindowOpen(a, b, c){return(window.open(a, b, c));}</script>+iU
  170. ##################################################################################
  171. #
  172. # all-popups: Kill all popups in JavaScript and HTML.
  173. #
  174. #################################################################################
  175. FILTER: all-popups Kill all popups in JavaScript and HTML.
  176. s@((\W\s*)(?:map)?(window|this|parent)\.?)open\s*\\?\(@$1concat(@ig # JavaScript
  177. #s/\starget\s*=\s*(['"]?)_?(blank|new)\1?/ notarget/ig # HTML
  178. s/\starget\s*=\s*(['"]?)_?(blank|new)\1?/ /ig # (X)HTML
  179. ##################################################################################
  180. #
  181. # img-reorder: Reorder attributes in <img> tags to make the banners-by-* filters more effective.
  182. #
  183. #################################################################################
  184. FILTER: img-reorder Reorder attributes in <img> tags to make the banners-by-* filters more effective.
  185. # In the first step src is moved to the start, then width is moved to the second
  186. # place to guarantee an order of src, width, height. Also does some white-space
  187. # normalization.
  188. #
  189. # This makes banners-by-size more effective and allows both banners-by-size
  190. # and banners-by-link to preserve the original image URL in the title attribute.
  191. s|<img\s+?([^>]*)\ssrc\s*=\s*(['"])([^>'" ]+)\2|<img src=$2$3$2 $1|siUg
  192. s|<img\s+?([^>]*)\ssrc\s*=\s*([^'">\\\s]+)|<img src=$2 $1|siUg
  193. s|(<img[^>]+height)\s*=\s*|$1=|siUg
  194. s|<img (src=(?:(['"])[^>'" ]*\2\|[^'">\\\s]+?))([^>]*)\s+width\s*=\s*((["']?)\d+?\5)(?=[\s>])|<img $1 width=$4$3|siUg
  195. #################################################################################
  196. #
  197. # banners-by-size: Kill banners by size.
  198. #
  199. #################################################################################
  200. #
  201. # Standard banner sizes taken from http://www.iab.net/iab_banner_standards/bannersizes.html
  202. #
  203. # Note: Use http://config.privoxy.org/send-banner?type=trans for a transparent 1x1 image
  204. # Use http://config.privoxy.org/send-banner?type=pattern for a grey/white pattern image
  205. # Use http://config.privoxy.org/send-banner?type=auto to auto-select.
  206. #
  207. # Note2: Use img-reorder before this filter to ensure maximum matching success
  208. #
  209. #################################################################################
  210. FILTER: banners-by-size Kill banners by size.
  211. # 88*31
  212. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)88\4)[^>]*?(height=(['"]?)31\6)[^>]*?(?=/?>)@\
  213. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  214. # 120*60, 120*90, 120*240, 120*600
  215. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)120\4)[^>]*?(height=(['"]?)(?:600?|90|240)\6)[^>]*?(?=/?>)@\
  216. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  217. # 125*125
  218. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)125\4)[^>]*?(height=(['"]?)125\6)[^>]*?(?=/?>)@\
  219. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  220. # 160*600
  221. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)160\4)[^>]*?(height=(['"]?)600\6)[^>]*?(?=/?>)@\
  222. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  223. # 180*150
  224. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)180\4)[^>]*?(height=(['"]?)150\6)[^>]*?(?=/?>)@\
  225. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  226. # 234*60, 468*60 (Most Banners!)
  227. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)(?:234|468)\4)[^>]*?(height=(['"]?)60\6)[^>]*?(?=/?>)@\
  228. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  229. # 240*400
  230. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)240\4)[^>]*?(height=(['"]?)400\6)[^>]*?(?=/?>)@\
  231. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  232. # 250*250, 300*250
  233. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)(?:250|300)\4)[^>]*?(height=(['"]?)250\6)[^>]*?(?=/?>)@\
  234. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  235. # 336*280
  236. s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)336\4)[^>]*?(height=(['"]?)280\6)[^>]*?(?=/?>)@\
  237. <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  238. # Note: 200*50 was also proposed, but it probably causes too much collateral damage:
  239. #
  240. #s@<img\s+(?:src\s*=\s*(['"]?)([^>\\\1\s]+)\1)?[^>]*?(width=(['"]?)200\4)[^>]*?(height=(['"]?)50\6)[^>]*?(?=/?>)@\
  241. # <img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed-$2-by-size" $3 $5@sig
  242. #################################################################################
  243. #
  244. # banners-by-link: Kill banners by their links to known clicktrackers (Experimental).
  245. #
  246. #################################################################################
  247. FILTER: banners-by-link Kill banners by their links to known clicktrackers.
  248. # Common case with width and height attributes:
  249. #
  250. s@<a\s+href\s*=\s*(['"]?)([^>\1\s]*?(?:\
  251. adclick # See www.dn.se \
  252. | advert # see dict.leo.org \
  253. | atwola\.com/(?:link|redir) # see www.cnn.com \
  254. | doubleclick\.net/jump/ # redirs for doublecklick.net ads \
  255. | counter # common \
  256. | (?<!&type=)tracker # (&type=tracker is used in sf's project statistics) \
  257. | adlog\.pl # see sf.net \
  258. )[^>\1\s]*)\1[^>]*>\s*<img\s+(?:src\s*=\s*(['"]?)([^>\\\3\s]+)\3)?[^>]*((?:width|height)\s*=\s*(['"]?)\d+?\6)[^>]*((?:width|height)\s*=\s*(['"]?)\d+?\8)[^>]*?(?=/?>)\
  259. @<img $5 $7 src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed $4 by link to $2"@sigx
  260. # Rare case w/o explicit dimensions:
  261. #
  262. s@<a\s+href\s*=\s*(['"]?)([^>\1\s]*?(?:ad(?:click|vert)|atwola\.com/(?:link|redir)|doubleclick\.net/jump/|(?<!&type=)tracker|counter|adlog\.pl)[^>\1\s]*)\1[^>]*>\s*<img\s+(?:src\s*=\s*(['"]?)([^>\\\3\s]+)\3)?[^>]*?(?=/?>)@<img src="http://config.privoxy.org/send-banner?type=auto" border="0" title="Killed $4 by link to $2"@sig
  263. ################################################################################
  264. #
  265. # webbugs: Squish WebBugs (1x1 invisible GIFs used for user tracking).
  266. #
  267. #################################################################################
  268. FILTER: webbugs Squish WebBugs (1x1 invisible GIFs used for user tracking).
  269. s@<img[^>]*\s(?:width|height)\s*=\s*['"]?[01](?=\D)[^>]*\s(?:width|height)\s*=\s*['"]?[01](?=\D)[^>]*?>@@siUg
  270. #################################################################################
  271. #
  272. # tiny-textforms: Extend those tiny textareas up to 40x80 and kill the hard wrap.
  273. #
  274. #################################################################################
  275. FILTER: tiny-textforms Extend those tiny textareas up to 40x80 and kill the hard wrap.
  276. s/(<textarea[^>]*?)(?:\s*(?:rows|cols)=(['"]?)\d+\2)+/$1 rows=$2\40$2 cols=$2\80$2/ig
  277. s/(<textarea[^>]*?)wrap=(['"]?)hard\2/$1/ig
  278. #################################################################################
  279. #
  280. # jumping-windows: Prevent windows from resizing and moving themselves.
  281. #
  282. #################################################################################
  283. FILTER: jumping-windows Prevent windows from resizing and moving themselves.
  284. s/(?<=[\W])(?:window|this|self)\.(?:move|resize)(?:to|by)\(/''.concat(/ig
  285. #################################################################################
  286. #
  287. # frameset-borders: Give frames a border, make them resizable and scrollable.
  288. #
  289. #################################################################################
  290. FILTER: frameset-borders Give frames a border and make them resizable.
  291. s/(<frameset\s+[^>]*)framespacing=(['"]?)(no|0)\2/$1/igU
  292. s/(<frameset\s+[^>]*)frameborder=(['"]?)(no|0)\2/$1/igU
  293. s/(<frameset\s+[^>]*)border=(['"]?)(no|0)\2/$1/igU
  294. s/(<frame\s+[^>]*)noresize/$1/igU
  295. s/(<frame\s+[^>]*)frameborder=(['"]?)(no|0)\2/$1/igU
  296. s/(<frame\s+[^>]*)scrolling=(['"]?)(no|0)\2/$1/igU
  297. #################################################################################
  298. #
  299. # iframes: Remove all detected iframes. Should only be enabled for
  300. # individual sites after testing that the iframes are optional.
  301. #
  302. #################################################################################
  303. FILTER: iframes Removes all detected iframes. Should only be enabled for individual sites.
  304. s@<iframe.*</iframe>@<!-- iframe removed by Privoxy's iframe filter -->@Uisg
  305. #################################################################################
  306. #
  307. # demoronizer: Correct Microsoft's abuse of standardized character sets, which
  308. # leave the browser to (mis)-interpret unknown characters, with
  309. # sometimes bizarre results on non-MS platforms.
  310. #
  311. # credit: ripped from the demoroniser.pl script by:
  312. # John Walker -- January 1998, http://www.fourmilab.ch/webtools/demoroniser
  313. #
  314. #################################################################################
  315. FILTER: demoronizer Fix MS's non-standard use of standard charsets.
  316. s/(&\#[0-2]\d\d)\s/$1; /g
  317. # per Robert Lynch: http://slate.msn.com//?id=2067547, just a guess.
  318. # Must come before x94 below.
  319. s/\xE2\x80\x94/ -- /g
  320. s/\x82/,/g
  321. #s-\x83-<em>f</em>-g
  322. s/\x84/,,/g
  323. s/\x85/.../g
  324. #s/\x88/^/g
  325. #s-\x89- °/°°-g
  326. s/\x8B/</g
  327. s/\x8C/Oe/g
  328. s/\x91/`/g
  329. s/\x92/'/g
  330. s/(\x93|\x94)/"/g
  331. # Bullet type character.
  332. s/\x95/&middot;/g
  333. s/\x96/-/g
  334. s/\x97/--/g
  335. #s-\x98-<sup>~</sup>-g
  336. #s-\x99-<sup>TM</sup>-g
  337. # per Robert Lynch.
  338. s/\x9B/>/g # 155
  339. #################################################################################
  340. #
  341. # shockwave-flash: Kill embedded Shockwave Flash objects.
  342. # Note: Better just block "/.*\.swf$"!
  343. #
  344. #################################################################################
  345. FILTER: shockwave-flash Kill embedded Shockwave Flash objects.
  346. s|<object [^>]*macromedia.*</object>|<!-- Squished Shockwave Object -->|sigU
  347. s|<embed [^>]*(application/x-shockwave-flash\|\.swf).*>(.*</embed>)?|<!-- Squished Shockwave Flash Embed -->|sigU
  348. #################################################################################
  349. #
  350. # quicktime-kioskmode: Make Quicktime movies saveable.
  351. #
  352. #################################################################################
  353. FILTER: quicktime-kioskmode Make Quicktime movies saveable.
  354. s/(<embed\s+[^>]*)kioskmode\s*=\s*(["']?)true\2/$1/ig
  355. #################################################################################
  356. #
  357. # fun: Text replacements for subversive browsing fun!
  358. #
  359. #################################################################################
  360. FILTER: fun Text replacements for subversive browsing fun!
  361. # SCNR
  362. #
  363. s/microsoft(?!\.[^\s])/MicroSuck/ig
  364. # Buzzword Bingo (example for extended regex syntax)
  365. #
  366. s* (?:industry|world)[ -]leading \
  367. | cutting[ -]edge \
  368. | customer[ -]focused \
  369. | market[ -]driven \
  370. | award[ -]winning # Comments are OK, too! \
  371. | high[ -]performance \
  372. | solutions[ -]based \
  373. | unmatched \
  374. | unparalleled \
  375. | unrivalled \
  376. *$0<sup><font color="red"><b>Bingo!</b></font></sup> \
  377. *igx
  378. # For Germans only
  379. #
  380. s/(M|m)edien(?![^<]*>)/$1&auml;dchen/Ug
  381. #################################################################################
  382. #
  383. # crude-parental: Crude parental filtering. Use with a suitable blocklist.
  384. # Pages are "blocked" based on keyword matching.
  385. #
  386. #################################################################################
  387. FILTER: crude-parental Crude parental filtering. Note that this filter doesn't work reliably.
  388. # (Note: Middlesex, Sussex and Essex are counties in the UK, not rude words)
  389. # (Note #2: Is 'sex' a rude word?!)
  390. s%^.*(?<!middle)(?<!sus)(?<!es)sex.*$%<html><head><title>Blocked</title></head><body>\
  391. <h3>Blocked by Privoxy's crude-parental filter due to possible adult content.</h3></body></html>%is
  392. s+^.*warez.*$+<html><head><title>No Warez</title></head><body><h3>You're not searching for illegal stuff, are you?</h3></body></html>+is
  393. # Remove by description
  394. s/^.*\
  395. (?:(suck|lick|tongue|rub|fuck|fingering|finger|chicks?)\s*)?\
  396. (?:(her|your|my|hard|with|big|wet|tight|pink|hot|moist|young|teen)\s*)+\
  397. (dicks?|penis|cocks?|balls?|tits?|pussy|cunt|clit|ass|mouth).*$\
  398. /This page has been blocked by Privoxy's crude-parental content filter\
  399. /is
  400. #Remove by link text
  401. s/^.*\
  402. (download|broadband|view|watch|free|get|extreem)?\s*\
  403. (sex|xxx|porn|cumshot|fuck(ing|s)?|anal|ass|asian|adult|Amateur|org(y|ies)|close ups?|hand?job|nail(ed)?)+\s*\
  404. (movies?|pics?|videos?|dvds?|dvd's|links?).*$\
  405. /This page has been blocked by Privoxy's crude-parental content filter\
  406. /is
  407. #Remove by age disclaimer
  408. s/^.*\
  409. (models?|chicks?|girls?|women|persons)\s*\
  410. (who|are|were)+ (over|at least) (16|18|21) years (old|of age).*$\
  411. /This page has been blocked by Privoxy's crude-parental content filter\
  412. /is
  413. #Remove by regulations
  414. s/^.*(Section 2257|18 U.?S.?C.? 2257).*$\
  415. /This page has been blocked by Privoxy's crude-parental content filter\
  416. /is
  417. #################################################################################
  418. #
  419. # IE-Exploits: Disable some known Internet Explorer bug exploits.
  420. #
  421. #################################################################################
  422. FILTER: ie-exploits Disable some known Internet Explorer bug exploits.
  423. # Note: This is basically a demo and waits for someone more interested in IE
  424. # security (sic!) to take over.
  425. # Cross-site-scripting:
  426. #
  427. s%f\("javascript:location.replace\('mk:@MSITStore:C:'\)"\);%alert\("This page looks like it tries to use a vulnerability described here:\n http://online.securityfocus.com/archive/1/298748/2002-11-02/2002-11-08/2"\);%siU
  428. # Address bar spoofing (http://www.secunia.com/advisories/10395/):
  429. #
  430. s/(<a[^>]*href[^>]*)(?:\x01|\x02|\x03|%0[012])@/$1MALICIOUS-LINK@/ig
  431. # Nimda:
  432. #
  433. s%<script language="JavaScript">(window\.open|1;''\.concat)\("readme\.eml", null, "resizable=no,top=6000,left=6000"\)</script>%<br><font size="7"> WARNING: This Server is infected with <a href="http://www.cert.org/advisories/CA-2001-26.html">Nimda</a>!</font>%g
  434. #################################################################################
  435. #
  436. #
  437. # site-specifics: Cure for site-specific problems. Don't apply generally!
  438. #
  439. # Note: The fixes contained here are so specific to the problems of the
  440. # particular web sites they are designed for that they would be a
  441. # waste of CPU cycles (or even destructive!) on 99.9% of the web
  442. # sites where they don't apply.
  443. #
  444. #################################################################################
  445. FILTER: site-specifics Cure for site-specific problems. Don't apply generally!
  446. # www.spiegel.de excludes X11 users from viewing Flash5 objects - shame.
  447. # Apply to: www.spiegel.de/static/js/flash-plugin.js
  448. #
  449. s/indexOf\("x11"\)/indexOf("x13")/
  450. # www.quelle-bausparkasse.de uses a very stupid redirect mechanism that
  451. # relies on a webbug being present. Can we tolerate that? No!
  452. # Apply to: www.quelle-bausparkasse.de/$
  453. #
  454. s/mylogfunc()//g
  455. # groups.yahoo.com has splash pages that one needs to click through in
  456. # order to access the actual messages. Let the browser do that. Thanks
  457. # to Paul Jobson for this one:
  458. #
  459. s|<a href="(.+?)">(?:Continue to message\|Weiter zu Nachricht)</a>|<meta http-equiv="refresh" content="0; URL=$1">|ig
  460. # monster.com has two very similar gimmicks:
  461. #
  462. s|<input type="hidden" name="REDIRECT" value="(.+?)">|<meta http-equiv="refresh" content="0; URL=$1">|i
  463. s|<IMG SRC="http://media.monster.com/mm/usen/my/no_thanks_211x40.gif".+?>|<meta http-equiv="refresh" content="0; URL=http://my.monster.com/resume.asp">|i
  464. # nytimes.com triggers popups through the onload handler of dummy images
  465. # to fool popup-blockers.
  466. #
  467. s|(<img [^>]*)onload|$1never|sig
  468. # Pre-check all the "Discard" buttons in GNU Mailman's web interface.
  469. # (This saves a lot of mouse aiming practice when flushing spamtraps)
  470. #
  471. s|(<INPUT name="\d{2,4}" type="RADIO" value="0") CHECKED |$1|g
  472. s|<INPUT name="\d{2,4}" type="RADIO" value="3" |$0 checked|g
  473. #################################################################################
  474. #
  475. # no-ping: Removes non-standard ping attributes in <a> and <area> tags.
  476. #
  477. #################################################################################
  478. FILTER: no-ping Removes non-standard ping attributes in <a> and <area> tags.
  479. s@(<a(?:rea)?[^>]*?)\sping=(['"]?)([^"'>]+)\2([>\s]?)@\
  480. <strong style="color:white; background-color:red;" title="Privoxy removed ping target '$3'">PING!</strong>\n$1$4@ig
  481. #################################################################################
  482. #
  483. # google: CSS-based block for Google text ads. Also removes
  484. # a width limitation and the toolbar advertisement.
  485. #
  486. #################################################################################
  487. FILTER: google CSS-based block for Google text ads. Also removes a width limitation and the toolbar advertisement.
  488. s@</head>[^\\]@<style type="text/css">\n\
  489. /* Style sheet inserted by Privoxy's google filter. */\n\
  490. \#fbc, \#fbl, \#ra, .rhh {visibility: hidden !important;}\n\
  491. \#tpa1,\#tpa2,\#tpa3,\#tpa4,\#tpa5,\#tpa5, \#spl, .ch, \#ads,\
  492. \#toolbar, \#google_ads_frame, \#mbEnd {display: none !important;}\n\
  493. .main_body, .j, \#res, .med, .hd, .g, .s\n\
  494. {width: 99%; max-width: 100%; margin-left: 0; margin-right: 0;}\n\
  495. </style>\n$0@
  496. s@<div style=\"padding-top:11px;min-width:500px\">@<div id="main_body">@
  497. s@(<table cellspacing=0 cellpadding=0 width=25% align=right bgcolor=\#ffffff border=0\
  498. |</font></td></tr></tbody></table><table align=\"right\" bgcolor=\"\#ffffff\"\
  499. |<table cellspacing=0 cellpadding=0 align=right bgcolor=\#ffffff border=0\
  500. |<table style=\"clear:both\" align=right width=25% cellspacing=\"0\" cellpadding=\"0\"\
  501. border=\"0\" bgcolor=\"\#ffffff\")@$0 id="ads"@
  502. s@(<br clear=all><table)( border=0 cellpadding=9><tr><td)@$1 id="toolbar"$2@
  503. #################################################################################
  504. #
  505. # yahoo: CSS-based block for Yahoo text ads. Also removes a width limitation.
  506. #
  507. #################################################################################
  508. FILTER: yahoo CSS-based block for Yahoo text ads. Also removes a width limitation.
  509. s@</head>@\n<style type="text/css">\n\
  510. /* Style sheet inserted by Privoxy's yahoo filter. */\n\
  511. \#symadbn, \#ymadbn, .yschbox, .yschhd, .bbox, \#yschsec, \#sec,\
  512. \#yschanswr, .yschftad, .yschspn, .yschspns, \#ygrp-sponsored-links,\
  513. \#nwad, \#MWA2, \#MSCM, \#yregad, \#sponsored-links,\
  514. \#ks-ypn-ads, .ad, \#east, \#ygrp-vital, .ads {display: none !important;}\n\
  515. \#yschpri, \#yschweb, \#pri, \#web, \#main, .yschttl, .abstr, .res \n\
  516. {width: 99% !important; max-width: 100% !important;}\n\
  517. .yschttl, .res, .res.indent, \#web {padding: 0px; margin: 0px !important;}\n\
  518. \#web {padding-left: 0.5em}\n\
  519. \#yschqcon, \#yschtg {width: auto !important; /* No useless horizontal scrollbar please */}\n\
  520. \#composebox \#compose_editorArea {width: 70% !important; /* reasonably sized reply textarea please */\n\
  521. </style>\n$0\n@
  522. s@(<textarea\s+id="composeArea"[^>]*)width:545px;@$1width:70%;@isU
  523. #################################################################################
  524. #
  525. # msn: CSS-based block for MSN text ads. Also removes tracking URLs
  526. # and a width limitation.
  527. #
  528. #################################################################################
  529. FILTER: msn CSS-based block for MSN text ads. Also removes tracking URLs and a width limitation.
  530. s@</head>@<style type="text/css">\n\
  531. /* Style sheet inserted by Privoxy's msn filter. */\n\
  532. .msn_ads, \#at, \#ar, .mktmsg {display: none !important;}\n\
  533. \#results, \#b_results, .flank, .results_area_flank, .results_area_stroke,\n\
  534. \#results_area, \#content, .sb_tlst, .sa_cc, .sb_ph, \#sw_main,\n\
  535. .content, .b_content, \#sw_foot, \#bf, \#sw_content, \#sidebar, \#pag\n\
  536. {width: 99% !important; min-width: 99% !important;\n\
  537. max-width: 100% !important; /* width:100% sometimes causes horizontal scrollbars */}\n\
  538. /* Remove 'related' ads */\n\
  539. .b_ad, .b_adlabel {clear: both; display:none;}\n\
  540. /* Remove "suggestions". They are next to worthless but partly overlap with the search results */\n\
  541. .suggestion, \#nys_right, \#nys {clear: both; display:none;}\n\
  542. /* Remove "Related searches" at the left side of the main results.\n\
  543. They are next to worthless, too, and also are still present below the main search results */\n\
  544. \#b_results > .b_ans {clear: both; display:none;}\n\
  545. \#s_notf_div,\n \
  546. /* Overlay ads to enable Facebook 'likes' in search results. */\n\
  547. .sn_container {display:none !important;}\n\
  548. \#content, \#b_content {padding: 0px 0px 0px 0px}\n\
  549. </style>\n$0@
  550. # Are these ids still in use?
  551. s@(<div[^>]*) id=(["']?)ads_[^\2]*\2@$1 class="msn_ads"@Uig
  552. s@(<div[^>]*) class=(["']?)sb_ads[^\2]*\2@$1 class="msn_ads"@Uig
  553. s@(<a[^>]*href=\")http://g.msn.com/.*\?(http://.*)(&amp;&amp;DI=.*)(\")@$1$2$4@Ug
  554. s@(<a[^>]*)gping=\".*\"@$1 title="URL cleaned up by Privoxy's msn filter"@Ug
  555. #################################################################################
  556. #
  557. # blogspot: Cleans up some Blogspot blogs. Read the fine print before using this.
  558. #
  559. # This filter also intentionally removes some navigation stuff and
  560. # sets the page width to 100%. As a result, some rounded "corners" would
  561. # appear to early or not at all and as fixing this would require a browser
  562. # that understands background-size (CSS3), they are removed instead.
  563. #
  564. # When applied to feeds, it removes comment titles that
  565. # only contain the beginning of the actual comment.
  566. #
  567. #################################################################################
  568. FILTER: blogspot Cleans up some Blogspot blogs. Read the fine print before using this.
  569. s@</head>@<style type="text/css">\n\
  570. /* Style sheet inserted by Privoxy's blogspot filter. */\n\
  571. \#powered-by {display: none !important;}\n\
  572. \#wrap4, \#wrapper {margin-top: 0px }\n\
  573. \#blogheader, \#header {margin-top: 0.5em !important}\n\
  574. \#content {width: 98% }\n\
  575. \#main {width: 70% }\n\
  576. \#sidebar {width: 29% }\n\
  577. .post-body {overflow: auto;}\n\
  578. .blogComments {width: 100%; overflow: auto;}\n</style>\n$0@
  579. s@<body.*(?:<div id="space-for-ie"></div>|(<div id="(?:content|wrap4|wrapper)))@<body>\
  580. <!-- Privoxy's blogspot filter ditched some garbage here -->$1@Us
  581. s@(<div style=\"[^\"]*width:)30em@$1 100%@
  582. s@background:url\(\"http://www.blogblog.com/rounders[^\"]*\"\).*;@/*$0*/@Ug
  583. s@(background:\#[a-f\d]{3})( url\(\"http://www.blogblog.com/rounders[^\"]*\"\).*;)@$1 ;/*$2*/@Ug
  584. # Do the feed filtering magic as described above.
  585. s@<title(?:\s+type=\'text\')?>([^<]*)(?:\.\.\.)?\s*</title>\s*\
  586. (<content(?:\s+type=\'(?:html|text)\')?>\s*\1)@<title></title>$2@ig
  587. #################################################################################
  588. #
  589. # x-httpd-php-to-html: Changes the Content-Type header from
  590. # x-httpd-php to html. "Content-Type: x-httpd-php"
  591. # is set by clueless PHP users and causes many
  592. # browsers do open a download menu instead of
  593. # rendering the page.
  594. #
  595. #################################################################################
  596. SERVER-HEADER-FILTER: x-httpd-php-to-html Changes the Content-Type header from x-httpd-php to html.
  597. s@^(Content-Type:)\s*application/x-httpd-php@$1 text/html@i
  598. #################################################################################
  599. #
  600. # html-to-xml: Changes the Content-Type header from html to xml.
  601. #
  602. #################################################################################
  603. SERVER-HEADER-FILTER: html-to-xml Changes the Content-Type header from html to xml.
  604. s@^(Content-Type:)\s*text/html(;.*)?$@$1 application/xhtml+xml$2@i
  605. #################################################################################
  606. #
  607. # xml-to-html: Changes the Content-Type header from xml to html.
  608. #
  609. #################################################################################
  610. SERVER-HEADER-FILTER: xml-to-html Changes the Content-Type header from xml to html.
  611. s@^(Content-Type:)\s*(?:application|text)/(?:xhtml\+)?xml(;.*)?$@$1 text/html$2@i
  612. #################################################################################
  613. #
  614. # hide-tor-exit-notation: Remove the Tor exit node notation in Host and Referer headers.
  615. #
  616. # Note: If Privoxy and Tor are chained and Privoxy is configured to
  617. # use socks4a, one can use http://www.example.org.foobar.exit/
  618. # to access the host www.example.org through Tor exit node foobar.
  619. #
  620. # As the HTTP client isn't aware of this notation, it treats the
  621. # whole string "www.example.org.foobar.exit" as host and uses it
  622. # for the "Host" and "Referer" headers. From the server's point of
  623. # view the resulting headers are invalid and can cause problems.
  624. #
  625. # An invalid "Referer" header can trigger "hot-linking" protections,
  626. # an invalid "Host" header will make it impossible for the server to
  627. # find the right vhost (several domains hosted on the same IP address).
  628. #
  629. # This filter removes the "foo.exit" part in those headers
  630. # to prevent the mentioned problems. Note that it only modifies
  631. # the HTTP headers, it doesn't make it impossible for the server
  632. # to detect your Tor exit node based on the IP address the request is
  633. # coming from.
  634. #
  635. #################################################################################
  636. CLIENT-HEADER-FILTER: hide-tor-exit-notation Removes the Tor exit node notation in Host and Referer headers.
  637. s@^((?:Referer|Host):\s*(?:https?://)?[^/]*)\.[^\./]*?\.exit@$1@i
  638. #################################################################################
  639. #
  640. # no-brotli-accepted: Strips "br" from the Accept-Encoding header as Privoxy
  641. # currently doesn't support Brotli.
  642. #
  643. #################################################################################
  644. CLIENT-HEADER-FILTER: no-brotli-accepted Strip "br" from Accept-Encoding header
  645. s@(^Accept-Encoding:.*?)(?:br, |, br|br)@$1@i
  646. #################################################################################
  647. #
  648. # less-download-windows: Prevents annoying download windows for content types
  649. # the browser can handle itself.
  650. #
  651. #################################################################################
  652. SERVER-HEADER-FILTER: less-download-windows Prevent annoying download windows for content types the browser can handle itself.
  653. s@^Content-Disposition:.*filename=(["']?).*\.(png|gif|jpe?g|diff?|d?patch|c|h|pl|shar)\1.*$@@i
  654. s@^(Content-Type:)\s*(?:message/(?:news|rfc822)|text/x-.*|application/x-sh(?:\s|$))\s*@$1 text/plain@i
  655. #################################################################################
  656. #
  657. # image-requests: Tags detected image requests as "IMAGE-REQUEST". Whether
  658. # or not the detection actually works depends on the browser.
  659. #
  660. #################################################################################
  661. CLIENT-HEADER-TAGGER: image-requests Tags detected image requests as "IMAGE-REQUEST".
  662. s@^Accept:\s*image/.*@IMAGE-REQUEST@i
  663. #################################################################################
  664. #
  665. # css-requests: Tags detected CSS requests as "CSS-REQUEST". Whether
  666. # or not the detection actually works depends on the browser.
  667. #
  668. #################################################################################
  669. CLIENT-HEADER-TAGGER: css-requests Tags detected CSS requests as "CSS-REQUEST".
  670. s@^Accept:\s*text/css.*@CSS-REQUEST@i
  671. #################################################################################
  672. #
  673. # range-requests: Tags range requests as "RANGE-REQUEST".
  674. #
  675. # By default Privoxy removes Range headers for requests to
  676. # ressources that will be filtered to make sure the filters
  677. # get the whole picture. Otherwise Range requests could be
  678. # intentionally used to circumvent filters or, less likely,
  679. # filtering a partial response may damage it because it matched
  680. # a pattern that the ressource as a whole wouldn't.
  681. #
  682. # Range requests can be useful and save bandwidth so instead
  683. # of removing Range headers for requests to ressources that
  684. # will be filtered, you may prefer to simply disable filtering
  685. # for those requests.
  686. #
  687. # That's what this tagger is all about. After enabling it,
  688. # you can disable filtering for range requests using the following
  689. # action section:
  690. #
  691. # {-filter -deanimate-gifs}
  692. # TAG:^RANGE-REQUEST
  693. #
  694. #################################################################################
  695. CLIENT-HEADER-TAGGER: range-requests Tags range requests as "RANGE-REQUEST".
  696. s@^Range:.*@RANGE-REQUEST@i
  697. #################################################################################
  698. #
  699. # client-ip-address: Tags the request with the client's IP address.
  700. #
  701. #################################################################################
  702. CLIENT-HEADER-TAGGER: client-ip-address Tags the request with the client's IP address.
  703. s@^\w*\s+.*\s+HTTP/\d\.\d\s*@IP-ADDRESS: $origin@D
  704. #################################################################################
  705. #
  706. # listen-address: Tags the request with the listen-address on which the request
  707. # came in.
  708. #
  709. #################################################################################
  710. CLIENT-HEADER-TAGGER: listen-address Tags the request with the listen-address on which the request came in.
  711. s@^\w*\s+.*\s+HTTP/\d\.\d\s*@LISTEN-ADDRESS: $listen-address@D
  712. #################################################################################
  713. #
  714. # http-method: Tags the request with its HTTP method.
  715. #
  716. #################################################################################
  717. CLIENT-HEADER-TAGGER: http-method Tags the request with its HTTP method.
  718. s@^(\w*).*HTTP/\d\.\d\s*$@$1@i
  719. #################################################################################
  720. #
  721. # allow-post: Tags POST requests as "ALLOWED-POST".
  722. #
  723. #################################################################################
  724. CLIENT-HEADER-TAGGER: allow-post Tags POST requests as "ALLOWED-POST".
  725. s@^(?:POST)\s+.*\s+HTTP/\d\.\d\s*@ALLOWED-POST@i
  726. #################################################################################
  727. #
  728. # complete-url: Tags the request with the whole request URL.
  729. #
  730. #################################################################################
  731. CLIENT-HEADER-TAGGER: complete-url Tags the request with the whole request URL.
  732. s@^\w*\s+(.*)\s+HTTP/\d\.\d\s*$@$1@i
  733. #################################################################################
  734. #
  735. # user-agent: Tags the request with the complete User-Agent header.
  736. #
  737. #################################################################################
  738. CLIENT-HEADER-TAGGER: user-agent Tags the request with the complete User-Agent header.
  739. s@^User-Agent:.*@$0@i
  740. #################################################################################
  741. #
  742. # referer: Tags the request with the complete Referer header.
  743. #
  744. #################################################################################
  745. CLIENT-HEADER-TAGGER: referer Tags the request with the complete Referer header.
  746. s@^Referer:.*@$0@i
  747. #################################################################################
  748. #
  749. # content-type: Tags the request with the content type declared by the server.
  750. #
  751. #################################################################################
  752. SERVER-HEADER-TAGGER: content-type Tags the request with the content type declared by the server.
  753. s@^Content-Type:\s*([^;]+).*@$1@i
  754. #################################################################################
  755. #
  756. # privoxy-control: The taggers create tags with the content of X-Privoxy-Control
  757. # headers, the filters remove said headers.
  758. #
  759. #################################################################################
  760. CLIENT-HEADER-TAGGER: privoxy-control Creates tags with the content of X-Privoxy-Control headers.
  761. s@^X-Privoxy-Control:\s*@@i
  762. CLIENT-HEADER-FILTER: privoxy-control Removes X-Privoxy-Control headers.
  763. s@^X-Privoxy-Control:.*@@i
  764. SERVER-HEADER-TAGGER: privoxy-control Creates tags with the content of X-Privoxy-Control headers.
  765. s@^X-Privoxy-Control:\s*@@i
  766. SERVER-HEADER-FILTER: privoxy-control Removes X-Privoxy-Control headers.
  767. s@^X-Privoxy-Control:.*@@i