Add Roland Rosenfeld to contributors.
[privoxy.git] / default.filter
1 # ********************************************************************
2
3 #  File        :  $Source: /cvsroot/ijbswa/current/default.filter,v $
4
5 #  $Id: default.filter,v 1.10 2002/04/18 10:14:19 oes Exp $
6 #
7 #  Purpose     :  Rules to process the content of web pages
8
9 #  Copyright   :  Written by and Copyright
10 #                 Privoxy team. http://www.privoxy.org/
11 #
12 # We value your feedback. However, to provide you with the best support,
13 # please note:
14 #  
15 #  * Use the support forum to get help:
16 #    http://sourceforge.net/tracker/?group_id=11118&atid=211118
17 #  * Submit bugs only thru our bug forum:
18 #    http://sourceforge.net/tracker/?group_id=11118&atid=111118 
19 #    Make sure that the bug has not already been submitted. Please try
20 #    to verify that it is a Privoxy bug, and not a browser or site
21 #    bug first. If you are using your own custom configuration, please
22 #    try the stock configs to see if the problem is a configuration
23 #    related bug. And if not using the latest development snapshot,
24 #    please try the latest one. Or even better, CVS sources.
25 #  * Submit feature requests only thru our feature request forum:
26 #    http://sourceforge.net/tracker/?atid=361118&group_id=11118&func=browse
27 #      
28 # For any other issues, feel free to use the mailing lists:
29 # http://sourceforge.net/mail/?group_id=11118
30 #    
31 # Anyone interested in actively participating in development and related
32 # discussions can join the appropriate mailing list here:
33 # http://sourceforge.net/mail/?group_id=11118. Archives are available
34 # here too.
35
36 #################################################################################
37 #
38 # Syntax:
39 #
40 # Filters start with a line "FILTER: name description". They are then referrable
41 # from the actionsfile with +filter{name}
42 #
43 # Inside the filters, write one Perl-Style substitution (job) per line.
44 # Jobs that precede the first FILTER: line are ignored.
45 #
46 # For Details see the pcrs manpage contained in this distribution.
47 # (and the perlre, perlop and pcre manpages)
48 #
49 # Note that you are free to choose the delimter as you see fit.
50 #
51 # Note2: In addidion to the Perl options gimsx, the following nonstandard
52 # options are supported:
53
54 # 'U' turns the default to ungreedy matching.  Add ? to quantifiers to
55 #     switch back to greedy.
56 # 'T' (trivial) prevents parsing for backreferences in the substitute.
57 #     Use if you want to include text like '$&' in your substitute without
58 #     quoting.
59
60 #################################################################################
61
62
63 #################################################################################
64 #
65 # html-annoyances: Get rid of particularly annoying HTML abuse
66 #
67 #################################################################################
68 FILTER: html-annoyances Get rid of particularly annoying HTML abuse
69
70 # New browser windows (if allowed -- see no-popups filter below) should be
71 # resizeable and have a location and status bar
72 #
73 s/(<a\s+href[^>]+)resizable=['"]?(no|0|false)['"]?(.*>)/$1resizable="1"$3/igU 
74 s/(<a\s+href[^>]+)location=['"]?(no|0)['"]?(.*>)/$1location="1"$3/igU 
75 s/(<a\s+href[^>]+)status=['"]?(no|0)['"]?(.*>)/$1status="1"$3/igU
76 s/(<a\s+href[^>]+)scrolling=['"]?(no|0|auto)['"]?(.*>)/$1scrolling="no"$3/igU
77 s/(<a\s+href[^>]+)menubar=['"]?(no|0)['"]?(.*>)/$1menubar="1"$3/igU
78
79 # The <BLINK> tag was a crime!
80 #
81 s*<blink>|</blink>**ig
82
83
84 #################################################################################
85 #
86 # js-annoyances: Get rid of particularly annoying JavaScript abuse
87 #
88 #################################################################################
89 FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
90
91 # Get rid of Javascript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
92 #
93 s|(<script.*)document\.referrer(.*</script>)|$1"Not Your Business!"$2|Usg
94
95 # The status bar is for displaying link targets, not pointless blahblah
96 #
97 s/window.status\s*=\s*['"].*?['"]/dUmMy=1/ig
98
99 # Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
100 #
101 s/(<body .*)onunload(.*>)/$1never$2/iU
102
103
104 #################################################################################
105 #
106 # content-cookies: Kill cookies that come in the HTML or JS content
107 #
108 #################################################################################
109 FILTER: content-cookies Kill cookies that come in the HTML or JS content
110
111 # JS cookies, like found on privacy.net:
112 #
113 s|(document\.cookie)([ \t\r\n]*=)|documenZapCooky$2|g
114
115 # HTML cookies:
116 #
117 s|<meta\s+http-equiv=['"]?set-cookie['"]?\s+content=[^>].*>|<!--no cookies here -->|iUT  
118
119
120 ##################################################################################
121 #
122 # popups: Kill all popups in JS and HTML
123 #
124 #################################################################################
125 FILTER: popups Kill all popups in JS and HTML
126
127 s/window\.open\s*\(/concat(/ig               # JavaScript
128 s/([ =;])open\s*\(/$1concat(/ig              # JavaScript alternative
129 s/target=['"]?(_blank|_new)['"]?/notarget/ig # HTML
130
131
132 #################################################################################
133 #
134 # frameset-borders: Give frames a border, make them resizable and scrollable
135 #
136 #################################################################################
137 FILTER: frameset-borders Give frames a border and make them resizable
138
139 s/(<frameset [^>]+)framespacing=['"]?(no|0)['"]?(.*>)/$1$3/igU
140 s/(<frameset [^>]+)(frame)?border=['"]?(no|0)['"]?(.*>)/$1$4/igU
141
142 s/(<frame [^>]+)frameborder=['"]?(no|0)['"]?(.*>)/$1$3/igU
143 s/(<frame [^>]+)noresize(.*>)/$1$2/igU
144 s/(<frame [^>]+)resizable=['"]?(no)['"]?(.*>)/$1$3/igU 
145 s/(<frame [^>]+)scrolling=['"]?(no)['"]?(.*>)/$1$3/igU
146
147 #################################################################################
148 #
149 # webbugs: Squish WebBugs (1x1 invisible GIFs used for user tracking)
150 #
151 #################################################################################
152 FILTER: webbugs Squish WebBugs (1x1 invisible GIFs used for user tracking)
153
154 s/<img\s+[^>]*?(width|height)\s*=\s*['"]?1\D[^>]*?(width|height)\s*=\s*['"]?1(\D[^>]*?)?>/<!-- Squished WebBug -->/siUg
155
156
157 #################################################################################
158 #
159 # refresh-tags: Kill automatic refresh tags (for dial-on-demand setups)
160 #
161 #################################################################################
162 FILTER: refresh-tags Kill automatic refresh tags (for dial-on-demand setups)
163
164 s/<meta\s+http-equiv=['"]?refresh['"]?\s+content=['"]?[0-9]*;\s+url=([^>]*)['"]?>/<link rev="x-refresh" href=$1>/iU   
165 s/<meta\s+http-equiv=['"]?page-enter['"]?\s+content=[^>].*>/<!--no page enter for me-->/iU 
166
167
168 #################################################################################
169 #
170 # fun: Text replacements for subversive browsing fun!
171 #
172 #################################################################################
173 FILTER: fun Text replacements for subversive browsing fun!
174
175 s/microsoft(?!.com)/MicroSuck/ig
176
177 # Buzzword Bingo (example for extended regex syntax)
178 #
179 s* industry[ -]leading \
180 |  cutting[ -]edge \
181 |  award[ -]winning # Comments are OK, too! \
182 |  high[ -]performance \
183 |  solutions[ -]based \
184 |  unmatched \
185 |  unparalleled \
186 |  unrivalled \
187 *<font color="red"><b>BINGO!</b></font> \
188 *igx
189
190
191 #################################################################################
192 #
193 # nimda: Remove Nimda (virus) code
194 #
195 #################################################################################
196 FILTER: nimda Remove Nimda (virus) code
197
198 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
199
200 #################################################################################
201 #
202 # banners-by-size: Kill banners by size
203 #
204 #################################################################################
205 #
206 # Standard banner sizes taken from http://www.iab.net/iab_banner_standards/bannersizes.html
207 #
208 # Note: Use http://config.privoxy.org/send-banner?type=trans for a transparent 1x1 image
209 #       Use http://config.privoxy.org/send-banner?type=pattern for a grey/white pattern image
210 #       Use http://config.privoxy.org/send-banner?type=auto  to auto-select.
211 #
212 #################################################################################
213 FILTER: banners-by-size Kill banners by size
214
215 s|<img\s+[^>]*?(width=['"]?468\D)[^>]*(height=['"]?60[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
216 s|<img\s+[^>]*?(width=['"]?234\D)[^>]*(height=['"]?60[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
217 s|<img\s+[^>]*?(width=['"]?88\D)[^>]*(height=['"]?31[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
218 s|<img\s+[^>]*?(width=['"]?120\D)[^>]*(height=['"]?90[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
219 s|<img\s+[^>]*?(width=['"]?120\D)[^>]*(height=['"]?600[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
220 s|<img\s+[^>]*?(width=['"]?120\D)[^>]*(height=['"]?60[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
221 s|<img\s+[^>]*?(width=['"]?160\D)[^>]*(height=['"]?600[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
222 s|<img\s+[^>]*?(width=['"]?125\D)[^>]*(height=['"]?125[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
223 s|<img\s+[^>]*?(width=['"]?120\D)[^>]*(height=['"]?240[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
224 s|<img\s+[^>]*?(width=['"]?180\D)[^>]*(height=['"]?150[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
225 s|<img\s+[^>]*?(width=['"]?300\D)[^>]*(height=['"]?250[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
226 s|<img\s+[^>]*?(width=['"]?250\D)[^>]*(height=['"]?250[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
227 s|<img\s+[^>]*?(width=['"]?240\D)[^>]*(height=['"]?400[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
228 s|<img\s+[^>]*?(width=['"]?336\D)[^>]*(height=['"]?280[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
229
230 # One more. (Where is 200x50 from?)
231 #
232 s|<img\s+[^>]*?(width=['"]?200\D)[^>]*(height=['"]?50[^>]*?)>|<img src="http://config.privoxy.org/send-banner?type=auto" $1 $2>|sig
233
234
235 #################################################################################
236 #
237 # shockwave-flash: Kill embedded Shockwave Flash objects
238 #
239 #################################################################################
240 FILTER: shockwave-flash Kill embedded Shockwave Flash objects
241
242 s|<embed [^>]*application/x-shockwave-flash.*</embed>|<!-- Squished Shockwave Flash Embed -->|sigU
243
244
245 #################################################################################
246 #
247 # crude-parental: Crude parental filtering?  (Use along with a suitable blocklist).
248 #                 Shows how to deny access to whole page based on a keyword.
249 #
250 #################################################################################
251 #
252 # (Note: Middlesex, Sussex and Essex are counties in the UK, not rude words)
253 # (Note #2: Is 'sex' a rude word?!)
254 #
255 #################################################################################
256 FILTER: crude-parental Crude parental filtering (demo only)
257
258 s%^.*(?<!middle)(?<!sus)(?<!es)sex.*$%<html><head><title>Blocked</title></head><body><h3>Blocked due to possible adult content. Please see <a href="http://dmoz.org/Kids_and_Teens/">this site</a>.</h3></body></html>%is
259 s+^.*warez.*$+<html><head><title>No Warez</title></head><body><h3>You're not searching for illegal stuff, are you?</h3></body></html>+is
260
261 ############################################################################## 
262 #
263 #  Revisions   :
264 #     $Log: default.filter,v $
265 #     Revision 1.10  2002/04/18 10:14:19  oes
266 #     renamed some filters
267 #
268 #     Revision 1.9  2002/04/11 07:36:35  oes
269 #     Generalized js-popup filter
270 #
271 #     Revision 1.8  2002/04/10 17:07:21  oes
272 #     Fixed potentially desctructive jobs, added noflash filter
273 #
274 #     Revision 1.7  2002/04/09 18:34:51  oes
275 #     Fixed HTML syntax in replacements
276 #
277 #     Revision 1.6  2002/04/03 19:49:52  swa
278 #     name change
279 #
280 #     Revision 1.5  2002/03/27 15:30:26  swa
281 #     have a consistent appearance
282 #
283 #     Revision 1.4  2002/03/26 22:29:54  swa
284 #     we have a new homepage!
285 #
286 #     Revision 1.3  2002/03/24 16:08:03  jongfoster
287 #     Fixing banners-by-size for new config URLs
288 #
289 #     Revision 1.2  2002/03/24 13:02:18  swa
290 #     name change related issues.
291 #
292 #     Revision 1.1  2002/03/24 11:37:39  jongfoster
293 #     Name change
294 #
295 #     Revision 1.24  2002/03/16 20:39:54  oes
296 #      - Added descriptions to the filters so users will know what they select in the cgi editor
297 #      - Added content-cookies filter
298 #      - Bugfixed many jobs (Thanks to Al for some hints)
299 #
300 #     Revision 1.22  2002/03/12 13:42:50  oes
301 #     Fixing & Optimizing REs
302 #
303 #     Revision 1.21  2002/03/12 11:59:20  oes
304 #     Beefed up Buzzword Bingo
305 #
306 #     Revision 1.20  2002/03/12 01:42:50  oes
307 #     Introduced modular filters
308 #
309 #     Revision 1.19  2002/03/10 19:49:24  oes
310 #     Added expression to kill referer tracking in JavaScripts
311 #
312 #     Revision 1.18  2002/03/08 17:14:12  oes
313 #     PNG -> image in comments
314 #
315 #     Revision 1.17  2002/03/07 03:50:54  oes
316 #     Adapted comments to new built-in images
317 #
318 #     Revision 1.16  2002/02/21 00:12:19  jongfoster
319 #     Modifying the banner regexps to use long URLS and to autodetect
320 #     whether to show a logo or a transparent GIF, based on actionsfile
321 #     setting.
322 #
323 #     Revision 1.15  2001/12/28 23:54:20  steudten
324 #     Fix for feature Req #495374: http-equiv problem
325 #
326 #     Revision 1.14  2001/12/09 18:55:11  david__schmidt
327 #     Updated CODE_STATUS to beta, commented out microsuck line in re_filterfile
328 #     for 2.9.10 beta
329 #
330 #     Revision 1.13  2001/10/13 13:11:20  joergs
331 #     Fixed WebBug filter.
332 #
333 #     Revision 1.12  2001/10/07 15:46:42  oes
334 #     Followed Guy's proposal to change the document.cookie job
335 #
336 #     Revision 1.11  2001/09/21 12:34:00  joergs
337 #     Added filter to replace "Nimda" code by a warning.
338 #
339 #     Revision 1.10  2001/07/20 11:04:26  oes
340 #     Added Rodneys javascript cookie filter
341 #
342 #     Revision 1.9  2001/07/13 14:03:48  oes
343 #     Elimiated yet another bug in the banner-by-size jobs. Shame on me!
344 #
345 #     Revision 1.8  2001/06/29 13:34:00  oes
346 #     - Added explanation for U and T options
347 #     - Added hint on image replacement by CGI call
348 #     - Fixed bug in banner-by-size jobs
349 #
350 #     Revision 1.7  2001/06/19 14:21:56  oes
351 #     Fixed microsuck line
352 #
353 #     Revision 1.6  2001/06/09 14:01:57  swa
354 #     header. cosmetics. default: no messing ala microsuck.
355 #
356 #
357