Add a "Whats New in this release" Section. Further work on multiple filter
[privoxy.git] / doc / webserver / user-manual / filter-file.html
1 <HTML
2 ><HEAD
3 ><TITLE
4 >Filter Files</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8 "><LINK
9 REL="HOME"
10 TITLE="Privoxy 3.0.4 User Manual"
11 HREF="index.html"><LINK
12 REL="PREVIOUS"
13 TITLE="Actions Files"
14 HREF="actions-file.html"><LINK
15 REL="NEXT"
16 TITLE="Templates"
17 HREF="templates.html"><LINK
18 REL="STYLESHEET"
19 TYPE="text/css"
20 HREF="../p_doc.css"></HEAD
21 ><BODY
22 CLASS="SECT1"
23 BGCOLOR="#EEEEEE"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >Privoxy 3.0.4 User Manual</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="actions-file.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 ></TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="templates.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="SECT1"
73 ><H1
74 CLASS="SECT1"
75 ><A
76 NAME="FILTER-FILE"
77 ></A
78 >9. Filter Files</H1
79 ><P
80 > All text substitutions that can be invoked through the
81  <TT
82 CLASS="LITERAL"
83 ><A
84 HREF="actions-file.html#FILTER"
85 >filter</A
86 ></TT
87 > action which 
88  must first be defined in a <SPAN
89 CLASS="QUOTE"
90 >"filter file"</SPAN
91 >, such as 
92  <TT
93 CLASS="FILENAME"
94 >default.filter</TT
95 >. Mulitple filter files can be
96  defined through the <TT
97 CLASS="LITERAL"
98 > <A
99 HREF="config.html#FILTERFILE"
100 >filterfile</A
101 ></TT
102 > config
103  option. The filters as supplied by the developers will be found in 
104  <TT
105 CLASS="FILENAME"
106 >default.filter</TT
107 >. It is recommended that any locally
108  defined or modified filters go in a separately defined file such as 
109  <TT
110 CLASS="FILENAME"
111 >user.filter</TT
112 >.
113  </P
114 ><P
115 > Typical reasons for doing these kinds of substitutions are to eliminate
116  common annoyances in HTML and JavaScript, such as pop-up windows,
117  exit consoles, crippled windows without navigation tools, the
118  infamous &#60;BLINK&#62; tag etc, to suppress images with certain
119  width and height attributes (standard banner sizes or web-bugs),
120  or just to have fun. The possibilities are endless.</P
121 ><P
122 > Filtering works on any text-based document type, including 
123  HTML, JavaScript, CSS etc. (all <TT
124 CLASS="LITERAL"
125 >text/*</TT
126 >
127  MIME types, <SPAN
128 CLASS="emphasis"
129 ><I
130 CLASS="EMPHASIS"
131 >except</I
132 ></SPAN
133 > <TT
134 CLASS="LITERAL"
135 >text/plain</TT
136 >).
137  Substitutions are made at the source level, so if you want to <SPAN
138 CLASS="QUOTE"
139 >"roll
140  your own"</SPAN
141 > filters, you should be familiar with HTML syntax.</P
142 ><P
143 > Just like the <A
144 HREF="actions-file.html"
145 >actions files</A
146 >, the
147  filter file is organized in sections, which are called <SPAN
148 CLASS="emphasis"
149 ><I
150 CLASS="EMPHASIS"
151 >filters</I
152 ></SPAN
153 >
154  here. Each filter consists of a heading line, that starts with the
155  <SPAN
156 CLASS="emphasis"
157 ><I
158 CLASS="EMPHASIS"
159 >keyword</I
160 ></SPAN
161 > <TT
162 CLASS="LITERAL"
163 >FILTER:</TT
164 >, followed by
165  the filter's <SPAN
166 CLASS="emphasis"
167 ><I
168 CLASS="EMPHASIS"
169 >name</I
170 ></SPAN
171 >, and a short (one line) 
172  <SPAN
173 CLASS="emphasis"
174 ><I
175 CLASS="EMPHASIS"
176 >description</I
177 ></SPAN
178 > of what it does. Below that line
179  come the <SPAN
180 CLASS="emphasis"
181 ><I
182 CLASS="EMPHASIS"
183 >jobs</I
184 ></SPAN
185 >, i.e. lines that define the actual
186  text substitutions. By convention, the name of a filter
187  should describe what the filter <SPAN
188 CLASS="emphasis"
189 ><I
190 CLASS="EMPHASIS"
191 >eliminates</I
192 ></SPAN
193 >. The
194  comment is used in the <A
195 HREF="http://config.privoxy.org/"
196 TARGET="_top"
197 >web-based
198  user interface</A
199 >.</P
200 ><P
201 > Once a filter called <TT
202 CLASS="REPLACEABLE"
203 ><I
204 >name</I
205 ></TT
206 > has been defined
207  in the filter file, it can be invoked by using an action of the form
208  +<TT
209 CLASS="LITERAL"
210 ><A
211 HREF="actions-file.html#FILTER"
212 >filter</A
213 >{<TT
214 CLASS="REPLACEABLE"
215 ><I
216 >name</I
217 ></TT
218 >}</TT
219 >
220  in any <A
221 HREF="actions-file.html"
222 >actions file</A
223 >.</P
224 ><P
225 > A filter header line for a filter called <SPAN
226 CLASS="QUOTE"
227 >"foo"</SPAN
228 > could look
229  like this:</P
230 ><P
231 > <TABLE
232 BORDER="0"
233 BGCOLOR="#E0E0E0"
234 WIDTH="100%"
235 ><TR
236 ><TD
237 ><PRE
238 CLASS="SCREEN"
239 >FILTER: foo Replace all "foo" with "bar"</PRE
240 ></TD
241 ></TR
242 ></TABLE
243 ></P
244 ><P
245 > Below that line, and up to the next header line, come the jobs that
246  define what text replacements the filter executes. They are specified
247  in a syntax that imitates <A
248 HREF="http://www.perl.org/"
249 TARGET="_top"
250 >Perl</A
251 >'s
252  <TT
253 CLASS="LITERAL"
254 >s///</TT
255 > operator. If you are familiar with Perl, you
256  will find this to be quite intuitive, and may want to look at the
257  PCRS documentation for the subtle differences to Perl behaviour. Most
258  notably, the non-standard option letter <TT
259 CLASS="LITERAL"
260 >U</TT
261 > is supported,
262  which turns the default to ungreedy matching.</P
263 ><P
264 > If you are new to regular expressions, you might want to take a look at
265  the <A
266 HREF="appendix.html#REGEX"
267 >Appendix on regular expressions</A
268 >, and
269  see the <A
270 HREF="http://perldoc.com/perl5.6.1/pod/perl.html"
271 TARGET="_top"
272 >Perl
273  manual</A
274 > for
275  <A
276 HREF="http://perldoc.com/perl5.6.1/pod/perlop.html#s-PATTERN-REPLACEMENT-egimosx"
277 TARGET="_top"
278 >the 
279  <TT
280 CLASS="LITERAL"
281 >s///</TT
282 > operator's syntax</A
283 > and <A
284 HREF="http://perldoc.com/perl5.6.1/pod/perlre.html"
285 TARGET="_top"
286 >Perl-style regular
287  expressions</A
288 > in general.
289  The below examples might also help to get you started.</P
290 ><DIV
291 CLASS="SECT2"
292 ><H2
293 CLASS="SECT2"
294 ><A
295 NAME="AEN3902"
296 ></A
297 >9.1. Filter File Tutorial</H2
298 ><P
299 > Now, let's complete our <SPAN
300 CLASS="QUOTE"
301 >"foo"</SPAN
302 > filter. We have already defined
303  the heading, but the jobs are still missing. Since all it does is to replace
304  <SPAN
305 CLASS="QUOTE"
306 >"foo"</SPAN
307 > with <SPAN
308 CLASS="QUOTE"
309 >"bar"</SPAN
310 >, there is only one (trivial) job
311  needed:</P
312 ><P
313 > <TABLE
314 BORDER="0"
315 BGCOLOR="#E0E0E0"
316 WIDTH="100%"
317 ><TR
318 ><TD
319 ><PRE
320 CLASS="SCREEN"
321 >s/foo/bar/</PRE
322 ></TD
323 ></TR
324 ></TABLE
325 ></P
326 ><P
327 > But wait! Didn't the comment say that <SPAN
328 CLASS="emphasis"
329 ><I
330 CLASS="EMPHASIS"
331 >all</I
332 ></SPAN
333 > occurrences
334  of <SPAN
335 CLASS="QUOTE"
336 >"foo"</SPAN
337 > should be replaced? Our current job will only take
338  care of the first <SPAN
339 CLASS="QUOTE"
340 >"foo"</SPAN
341 > on each page. For global substitution,
342  we'll need to add the <TT
343 CLASS="LITERAL"
344 >g</TT
345 > option:</P
346 ><P
347 > <TABLE
348 BORDER="0"
349 BGCOLOR="#E0E0E0"
350 WIDTH="100%"
351 ><TR
352 ><TD
353 ><PRE
354 CLASS="SCREEN"
355 >s/foo/bar/g</PRE
356 ></TD
357 ></TR
358 ></TABLE
359 ></P
360 ><P
361 > Our complete filter now looks like this:</P
362 ><P
363 > <TABLE
364 BORDER="0"
365 BGCOLOR="#E0E0E0"
366 WIDTH="100%"
367 ><TR
368 ><TD
369 ><PRE
370 CLASS="SCREEN"
371 >FILTER: foo Replace all "foo" with "bar"
372 s/foo/bar/g</PRE
373 ></TD
374 ></TR
375 ></TABLE
376 ></P
377 ><P
378 > Let's look at some real filters for more interesting examples. Here you see
379  a filter that protects against some common annoyances that arise from JavaScript
380  abuse. Let's look at its jobs one after the other:</P
381 ><P
382 > <TABLE
383 BORDER="0"
384 BGCOLOR="#E0E0E0"
385 WIDTH="100%"
386 ><TR
387 ><TD
388 ><PRE
389 CLASS="SCREEN"
390 >FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
391
392 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
393 #
394 s|(&#60;script.*)document\.referrer(.*&#60;/script&#62;)|$1"Not Your Business!"$2|Usg</PRE
395 ></TD
396 ></TR
397 ></TABLE
398 ></P
399 ><P
400 > Following the header line and a comment, you see the job. Note that it uses
401  <TT
402 CLASS="LITERAL"
403 >|</TT
404 > as the delimiter instead of <TT
405 CLASS="LITERAL"
406 >/</TT
407 >, because
408  the pattern contains a forward slash, which would otherwise have to be escaped
409  by a backslash (<TT
410 CLASS="LITERAL"
411 >\</TT
412 >).</P
413 ><P
414 > Now, let's examine the pattern: it starts with the text <TT
415 CLASS="LITERAL"
416 >&#60;script.*</TT
417 >
418  enclosed in parentheses. Since the dot matches any character, and <TT
419 CLASS="LITERAL"
420 >*</TT
421 >
422  means: <SPAN
423 CLASS="QUOTE"
424 >"Match an arbitrary number of the element left of myself"</SPAN
425 >, this
426  matches <SPAN
427 CLASS="QUOTE"
428 >"&#60;script"</SPAN
429 >, followed by <SPAN
430 CLASS="emphasis"
431 ><I
432 CLASS="EMPHASIS"
433 >any</I
434 ></SPAN
435 > text, i.e.
436  it matches the whole page, from the start of the first &#60;script&#62; tag.</P
437 ><P
438 > That's more than we want, but the pattern continues: <TT
439 CLASS="LITERAL"
440 >document\.referrer</TT
441 >
442  matches only the exact string <SPAN
443 CLASS="QUOTE"
444 >"document.referrer"</SPAN
445 >. The dot needed to
446  be <SPAN
447 CLASS="emphasis"
448 ><I
449 CLASS="EMPHASIS"
450 >escaped</I
451 ></SPAN
452 >, i.e. preceded by a backslash, to take away its
453  special meaning as a joker, and make it just a regular dot. So far, the meaning is:
454  Match from the start of the first &#60;script&#62; tag in a the page, up to, and including,
455  the text <SPAN
456 CLASS="QUOTE"
457 >"document.referrer"</SPAN
458 >, if <SPAN
459 CLASS="emphasis"
460 ><I
461 CLASS="EMPHASIS"
462 >both</I
463 ></SPAN
464 > are present
465  in the page (and appear in that order).</P
466 ><P
467 > But there's still more pattern to go. The next element, again enclosed in parentheses,
468  is <TT
469 CLASS="LITERAL"
470 >.*&#60;/script&#62;</TT
471 >. You already know what <TT
472 CLASS="LITERAL"
473 >.*</TT
474 >
475  means, so the whole pattern translates to: Match from the start of the first  &#60;script&#62;
476  tag in a page to the end of the last &#60;script&#62; tag, provided that the text
477  <SPAN
478 CLASS="QUOTE"
479 >"document.referrer"</SPAN
480 > appears somewhere in between.</P
481 ><P
482 > This is still not the whole story, since we have ignored the options and the parentheses:
483  The portions of the page matched by sub-patterns that are enclosed in parentheses, will be
484  remembered and be available through the variables <TT
485 CLASS="LITERAL"
486 >$1, $2, ...</TT
487 > in
488  the substitute. The <TT
489 CLASS="LITERAL"
490 >U</TT
491 > option switches to ungreedy matching, which means
492  that the first <TT
493 CLASS="LITERAL"
494 >.*</TT
495 > in the pattern will only <SPAN
496 CLASS="QUOTE"
497 >"eat up"</SPAN
498 > all
499  text in between <SPAN
500 CLASS="QUOTE"
501 >"&#60;script"</SPAN
502 > and the <SPAN
503 CLASS="emphasis"
504 ><I
505 CLASS="EMPHASIS"
506 >first</I
507 ></SPAN
508 > occurrence
509  of <SPAN
510 CLASS="QUOTE"
511 >"document.referrer"</SPAN
512 >, and that the second <TT
513 CLASS="LITERAL"
514 >.*</TT
515 > will
516  only span the text up to the <SPAN
517 CLASS="emphasis"
518 ><I
519 CLASS="EMPHASIS"
520 >first</I
521 ></SPAN
522 > <SPAN
523 CLASS="QUOTE"
524 >"&#60;/script&#62;"</SPAN
525 >
526  tag. Furthermore, the <TT
527 CLASS="LITERAL"
528 >s</TT
529 > option says that the match may span
530  multiple lines in the page, and the <TT
531 CLASS="LITERAL"
532 >g</TT
533 > option again means that the
534  substitution is global.</P
535 ><P
536 > So, to summarize, the pattern means: Match all scripts that contain the text
537  <SPAN
538 CLASS="QUOTE"
539 >"document.referrer"</SPAN
540 >. Remember the parts of the script from
541  (and including) the start tag up to (and excluding) the string
542  <SPAN
543 CLASS="QUOTE"
544 >"document.referrer"</SPAN
545 > as <TT
546 CLASS="LITERAL"
547 >$1</TT
548 >, and the part following
549  that string, up to and including the closing tag, as <TT
550 CLASS="LITERAL"
551 >$2</TT
552 >.</P
553 ><P
554 > Now the pattern is deciphered, but wasn't this about substituting things? So
555  lets look at the substitute: <TT
556 CLASS="LITERAL"
557 >$1"Not Your Business!"$2</TT
558 > is
559  easy to read: The text remembered as <TT
560 CLASS="LITERAL"
561 >$1</TT
562 >, followed by 
563  <TT
564 CLASS="LITERAL"
565 >"Not Your Business!"</TT
566 > (<SPAN
567 CLASS="emphasis"
568 ><I
569 CLASS="EMPHASIS"
570 >including</I
571 ></SPAN
572 >
573  the quotation marks!), followed by the text remembered as <TT
574 CLASS="LITERAL"
575 >$2</TT
576 >.
577  This produces an exact copy of the original string, with the middle part
578  (the <SPAN
579 CLASS="QUOTE"
580 >"document.referrer"</SPAN
581 >) replaced by <TT
582 CLASS="LITERAL"
583 >"Not Your
584  Business!"</TT
585 >.</P
586 ><P
587 > The whole job now reads: Replace <SPAN
588 CLASS="QUOTE"
589 >"document.referrer"</SPAN
590 > by
591  <TT
592 CLASS="LITERAL"
593 >"Not Your Business!"</TT
594 > wherever it appears inside a
595  &#60;script&#62; tag. Note that this job won't break JavaScript syntax,
596  since both the original and the replacement are syntactically valid
597  string objects. The script just won't have access to the referrer
598  information anymore.</P
599 ><P
600 > We'll show you two other jobs from the JavaScript taming department, but
601  this time only point out the constructs of special interest:</P
602 ><P
603 > <TABLE
604 BORDER="0"
605 BGCOLOR="#E0E0E0"
606 WIDTH="100%"
607 ><TR
608 ><TD
609 ><PRE
610 CLASS="SCREEN"
611 ># The status bar is for displaying link targets, not pointless blahblah
612 #
613 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</PRE
614 ></TD
615 ></TR
616 ></TABLE
617 ></P
618 ><P
619 > <TT
620 CLASS="LITERAL"
621 >\s</TT
622 > stands for whitespace characters (space, tab, newline,
623  carriage return, form feed), so that <TT
624 CLASS="LITERAL"
625 >\s*</TT
626 > means: <SPAN
627 CLASS="QUOTE"
628 >"zero
629  or more whitespace"</SPAN
630 >. The <TT
631 CLASS="LITERAL"
632 >?</TT
633 > in <TT
634 CLASS="LITERAL"
635 >.*?</TT
636 >
637  makes this matching of arbitrary text ungreedy. (Note that the <TT
638 CLASS="LITERAL"
639 >U</TT
640 >
641  option is not set). The <TT
642 CLASS="LITERAL"
643 >['"]</TT
644 > construct means: <SPAN
645 CLASS="QUOTE"
646 >"a single
647  <SPAN
648 CLASS="emphasis"
649 ><I
650 CLASS="EMPHASIS"
651 >or</I
652 ></SPAN
653 > a double quote"</SPAN
654 >. Finally, <TT
655 CLASS="LITERAL"
656 >\1</TT
657 > is
658  a backreference to the first parenthesis just like <TT
659 CLASS="LITERAL"
660 >$1</TT
661 > above,
662  with the difference that in the <SPAN
663 CLASS="emphasis"
664 ><I
665 CLASS="EMPHASIS"
666 >pattern</I
667 ></SPAN
668 >, a backslash indicates
669  a backreference, whereas in the <SPAN
670 CLASS="emphasis"
671 ><I
672 CLASS="EMPHASIS"
673 >substitute</I
674 ></SPAN
675 >, it's the dollar.</P
676 ><P
677 > So what does this job do? It replaces assignments of single- or double-quoted
678  strings to the <SPAN
679 CLASS="QUOTE"
680 >"window.status"</SPAN
681 > object with a dummy assignment
682  (using a variable name that is hopefully odd enough not to conflict with
683  real variables in scripts). Thus, it catches many cases where e.g. pointless
684  descriptions are displayed in the status bar instead of the link target when
685  you move your mouse over links.</P
686 ><P
687 > <TABLE
688 BORDER="0"
689 BGCOLOR="#E0E0E0"
690 WIDTH="100%"
691 ><TR
692 ><TD
693 ><PRE
694 CLASS="SCREEN"
695 ># Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
696 #
697 s/(&#60;body [^&#62;]*)onunload(.*&#62;)/$1never$2/iU</PRE
698 ></TD
699 ></TR
700 ></TABLE
701 ></P
702 ><P
703 > Including the
704  <A
705 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
706 TARGET="_top"
707 >OnUnload
708  event binding</A
709 > in the HTML DOM was a <SPAN
710 CLASS="emphasis"
711 ><I
712 CLASS="EMPHASIS"
713 >CRIME</I
714 ></SPAN
715 >.
716  When I close a browser window, I want it to close and die. Basta.
717  This job replaces the <SPAN
718 CLASS="QUOTE"
719 >"onunload"</SPAN
720 > attribute in
721  <SPAN
722 CLASS="QUOTE"
723 >"&#60;body&#62;"</SPAN
724 > tags with the dummy word <TT
725 CLASS="LITERAL"
726 >never</TT
727 >.
728  Note that the <TT
729 CLASS="LITERAL"
730 >i</TT
731 > option makes the pattern matching
732  case-insensitive. Also note that ungreedy matching alone doesn't always guarantee
733  a minimal match: In the first parenthesis, we had to use <TT
734 CLASS="LITERAL"
735 >[^&#62;]*</TT
736 >
737  instead of <TT
738 CLASS="LITERAL"
739 >.*</TT
740 > to prevent the match from exceeding the 
741  &#60;body&#62; tag if it doesn't contain <SPAN
742 CLASS="QUOTE"
743 >"OnUnload"</SPAN
744 >, but the page's
745  content does.</P
746 ><P
747 > The last example is from the fun department:</P
748 ><P
749 > <TABLE
750 BORDER="0"
751 BGCOLOR="#E0E0E0"
752 WIDTH="100%"
753 ><TR
754 ><TD
755 ><PRE
756 CLASS="SCREEN"
757 >FILTER: fun Fun text replacements
758
759 # Spice the daily news:
760 #
761 s/microsoft(?!\.com)/MicroSuck/ig</PRE
762 ></TD
763 ></TR
764 ></TABLE
765 ></P
766 ><P
767 > Note the <TT
768 CLASS="LITERAL"
769 >(?!\.com)</TT
770 > part (a so-called negative lookahead)
771  in the job's pattern, which means: Don't match, if the string 
772  <SPAN
773 CLASS="QUOTE"
774 >".com"</SPAN
775 > appears directly following <SPAN
776 CLASS="QUOTE"
777 >"microsoft"</SPAN
778 >
779  in the page. This prevents links to microsoft.com from being trashed, while
780  still replacing the word everywhere else.</P
781 ><P
782 > <TABLE
783 BORDER="0"
784 BGCOLOR="#E0E0E0"
785 WIDTH="100%"
786 ><TR
787 ><TD
788 ><PRE
789 CLASS="SCREEN"
790 ># Buzzword Bingo (example for extended regex syntax)
791 #
792 s* industry[ -]leading \
793 |  cutting[ -]edge \
794 |  customer[ -]focused \
795 |  market[ -]driven \
796 |  award[ -]winning # Comments are OK, too! \
797 |  high[ -]performance \
798 |  solutions[ -]based \
799 |  unmatched \
800 |  unparalleled \
801 |  unrivalled \
802 *&#60;font color="red"&#62;&#60;b&#62;BINGO!&#60;/b&#62;&#60;/font&#62; \
803 *igx</PRE
804 ></TD
805 ></TR
806 ></TABLE
807 ></P
808 ><P
809 > The <TT
810 CLASS="LITERAL"
811 >x</TT
812 > option in this job turns on extended syntax, and allows for
813  e.g. the liberal use of (non-interpreted!) whitespace for nicer formatting. </P
814 ><P
815 > You get the idea?</P
816 ></DIV
817 ><DIV
818 CLASS="SECT2"
819 ><H2
820 CLASS="SECT2"
821 ><A
822 NAME="PREDEFINED-FILTERS"
823 ></A
824 >9.2. The Pre-defined Filters</H2
825 ><P
826 >The distribution <TT
827 CLASS="FILENAME"
828 >default.filter</TT
829 > file contains a selection of
830 pre-defined filters for your convenience:</P
831 ><P
832 ></P
833 ><DIV
834 CLASS="VARIABLELIST"
835 ><DL
836 ><DT
837 ><SPAN
838 CLASS="emphasis"
839 ><I
840 CLASS="EMPHASIS"
841 >js-annoyances</I
842 ></SPAN
843 ></DT
844 ><DD
845 ><P
846 >    The purpose of this filter is to get rid of particularly annoying JavaScript abuse.
847     To that end, it
848    <P
849 ></P
850 ><UL
851 ><LI
852 ><P
853 >      replaces JavaScript references to the browser's referrer information
854       with the string "Not Your Business!". This compliments the <TT
855 CLASS="LITERAL"
856 ><A
857 HREF="actions-file.html#HIDE-REFERRER"
858 >hide-referrer</A
859 ></TT
860 > action on the content level.
861      </P
862 ></LI
863 ><LI
864 ><P
865 >      removes the bindings to the DOM's
866       <A
867 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
868 TARGET="_top"
869 >unload
870       event</A
871 > which we feel has no right to exist and is responsible for most <SPAN
872 CLASS="QUOTE"
873 >"exit consoles"</SPAN
874 >, i.e.
875       nasty windows that pop up when you close another one.
876      </P
877 ></LI
878 ><LI
879 ><P
880 >      removes code that causes new windows to be opened with undesired properties, such as being
881       full-screen, non-resizable, without location, status or menu bar etc.
882      </P
883 ></LI
884 ></UL
885 >
886    </P
887 ></DD
888 ><DT
889 ><SPAN
890 CLASS="emphasis"
891 ><I
892 CLASS="EMPHASIS"
893 >js-events</I
894 ></SPAN
895 ></DT
896 ><DD
897 ><P
898 >    This is a very radical measure. It removes virtually all JavaScript event bindings, which
899     means that scripts can not react to user actions such as mouse movements or clicks, window
900     resizing etc, anymore. 
901    </P
902 ><P
903 >    We <SPAN
904 CLASS="emphasis"
905 ><I
906 CLASS="EMPHASIS"
907 >strongly discourage</I
908 ></SPAN
909 > using this filter as a default since it breaks
910     many legitimate scripts. It is meant for use only on extra-nasty sites (should you really
911     need to go there).
912    </P
913 ></DD
914 ><DT
915 ><SPAN
916 CLASS="emphasis"
917 ><I
918 CLASS="EMPHASIS"
919 >html-annoyances</I
920 ></SPAN
921 ></DT
922 ><DD
923 ><P
924 >    This filter will undo many common instances of HTML based abuse.
925    </P
926 ><P
927 >    The <TT
928 CLASS="LITERAL"
929 >BLINK</TT
930 > and <TT
931 CLASS="LITERAL"
932 >MARQUEE</TT
933 > tags 
934     are neutralized (yeah baby!), and browser windows will be created as
935     resizable (as of course they should be!), and will have location,
936     scroll and menu bars -- even if specified otherwise.
937    </P
938 ></DD
939 ><DT
940 ><SPAN
941 CLASS="emphasis"
942 ><I
943 CLASS="EMPHASIS"
944 >content-cookies</I
945 ></SPAN
946 ></DT
947 ><DD
948 ><P
949 >    Most cookies are set in the HTTP dialogue, where they can be intercepted
950     by the
951     <TT
952 CLASS="LITERAL"
953 ><A
954 HREF="actions-file.html#CRUNCH-INCOMING-COOKIES"
955 >crunch-incoming-cookies</A
956 ></TT
957 >
958     and <TT
959 CLASS="LITERAL"
960 ><A
961 HREF="actions-file.html#CRUNCH-OUTGOING-COOKIES"
962 >crunch-outgoing-cookies</A
963 ></TT
964 >
965     actions. But web sites increasingly make use of HTML meta tags and JavaScript
966     to sneak cookies to the browser on the content level.
967    </P
968 ><P
969 >    This filter disables HTML and JavaScript code that reads or sets cookies. Use
970     it wherever you would also use the cookie crunch actions.
971    </P
972 ></DD
973 ><DT
974 ><SPAN
975 CLASS="emphasis"
976 ><I
977 CLASS="EMPHASIS"
978 >refresh tags</I
979 ></SPAN
980 ></DT
981 ><DD
982 ><P
983 >    Disable any refresh tags if the interval is greater than nine seconds (so 
984     that redirections done via refresh tags are not destroyed). This is useful 
985     for dial-on-demand setups, or for those who find this HTML feature
986     annoying.
987    </P
988 ></DD
989 ><DT
990 ><SPAN
991 CLASS="emphasis"
992 ><I
993 CLASS="EMPHASIS"
994 >unsolicited-popups</I
995 ></SPAN
996 ></DT
997 ><DD
998 ><P
999 >    This filter attempts to prevent only <SPAN
1000 CLASS="QUOTE"
1001 >"unsolicited"</SPAN
1002 > pop-up 
1003     windows from opening, yet still allow pop-up windows that the user 
1004     has explicitly chosen to open. It was added in version 3.0.1, 
1005     as an improvement over earlier such filters.
1006    </P
1007 ><P
1008 >    Technical note: The filter works by redefining the window.open JavaScript
1009     function to a dummy function during the loading and rendering phase of each
1010     HTML page access, and restoring the function afterwards.
1011    </P
1012 ></DD
1013 ><DT
1014 ><SPAN
1015 CLASS="emphasis"
1016 ><I
1017 CLASS="EMPHASIS"
1018 >all-popups</I
1019 ></SPAN
1020 ></DT
1021 ><DD
1022 ><P
1023 >    Attempt to prevent <SPAN
1024 CLASS="emphasis"
1025 ><I
1026 CLASS="EMPHASIS"
1027 >all</I
1028 ></SPAN
1029 > pop-up windows from opening.
1030     Note this should be used with more discretion than the above, since it is
1031     more likely to break some sites that require pop-ups for normal usage. Use 
1032     with caution.
1033    </P
1034 ></DD
1035 ><DT
1036 ><SPAN
1037 CLASS="emphasis"
1038 ><I
1039 CLASS="EMPHASIS"
1040 >img-reorder</I
1041 ></SPAN
1042 ></DT
1043 ><DD
1044 ><P
1045 >    This is a helper filter that has no value if used alone. It makes the
1046     <TT
1047 CLASS="LITERAL"
1048 >banners-by-size</TT
1049 > and <TT
1050 CLASS="LITERAL"
1051 >banners-by-link</TT
1052 >
1053     (see below) filters more effective and should be enabled together with them.
1054    </P
1055 ></DD
1056 ><DT
1057 ><SPAN
1058 CLASS="emphasis"
1059 ><I
1060 CLASS="EMPHASIS"
1061 >banners-by-size</I
1062 ></SPAN
1063 ></DT
1064 ><DD
1065 ><P
1066 >    This filter removes image tags purely based on what size they are. Fortunately 
1067     for us, many ads and banner images tend to conform to certain standardized
1068     sizes, which makes this filter quite effective for ad stripping purposes.
1069    </P
1070 ><P
1071 >    Occasionally this filter will cause false positives on images that are not ads,
1072     but just happen to be of one of the standard banner sizes.
1073    </P
1074 ></DD
1075 ><DT
1076 ><SPAN
1077 CLASS="emphasis"
1078 ><I
1079 CLASS="EMPHASIS"
1080 >banners-by-link</I
1081 ></SPAN
1082 ></DT
1083 ><DD
1084 ><P
1085 >    This is an experimental filter that attempts to kill any banners if 
1086     their URLs seem to point to known or suspected click trackers. It is currently
1087     not of much value and is not recommended for use by default.
1088    </P
1089 ></DD
1090 ><DT
1091 ><SPAN
1092 CLASS="emphasis"
1093 ><I
1094 CLASS="EMPHASIS"
1095 >webbugs</I
1096 ></SPAN
1097 ></DT
1098 ><DD
1099 ><P
1100 >    Webbugs are small, invisible images (technically 1X1 GIF images), that 
1101     are used to track users across websites, and collect information on them.
1102     As an HTML page is loaded by the browser, an embedded image tag causes the
1103     browser to contact a third-party site, disclosing the tracking information
1104     through the requested URL and/or cookies for that third-party domain, without
1105     the use ever becoming aware of the interaction with the third-party site.
1106     HTML-ized spam also uses a similar technique to verify email addresses.
1107    </P
1108 ><P
1109 >    This filter removes the HTML code that loads such <SPAN
1110 CLASS="QUOTE"
1111 >"webbugs"</SPAN
1112 >.
1113    </P
1114 ></DD
1115 ><DT
1116 ><SPAN
1117 CLASS="emphasis"
1118 ><I
1119 CLASS="EMPHASIS"
1120 >tiny-textforms</I
1121 ></SPAN
1122 ></DT
1123 ><DD
1124 ><P
1125 >    A rather special-purpose filter that can be used to enlarge textareas (those
1126     multi-line text boxes in web forms) and turn off hard word wrap in them. 
1127     It was written for the sourceforge.net tracker system where such boxes are
1128     a nuisance, but it can be handy on other sites, too.
1129    </P
1130 ><P
1131 >    It is not recommended to use this filter as a default.
1132    </P
1133 ></DD
1134 ><DT
1135 ><SPAN
1136 CLASS="emphasis"
1137 ><I
1138 CLASS="EMPHASIS"
1139 >jumping-windows</I
1140 ></SPAN
1141 ></DT
1142 ><DD
1143 ><P
1144 >    Many consider windows that move, or resize themselves to be abusive. This filter
1145     neutralizes the related JavaScript code. Note that some sites might not display
1146     or behave as intended when using this filter.
1147    </P
1148 ></DD
1149 ><DT
1150 ><SPAN
1151 CLASS="emphasis"
1152 ><I
1153 CLASS="EMPHASIS"
1154 >frameset-borders</I
1155 ></SPAN
1156 ></DT
1157 ><DD
1158 ><P
1159 >    Some web designers seem to assume that everyone in the world will view their
1160     web sites using the same browser brand and version, screen resolution etc,
1161     because only that assumption could explain why they'd use static frame sizes,
1162     yet prevent their frames from being resized by the user, should they be too
1163     small to show their whole content.
1164    </P
1165 ><P
1166 >    This filter removes the related HTML code. It should only be applied to sites
1167     which need it.
1168    </P
1169 ></DD
1170 ><DT
1171 ><SPAN
1172 CLASS="emphasis"
1173 ><I
1174 CLASS="EMPHASIS"
1175 >demoronizer</I
1176 ></SPAN
1177 ></DT
1178 ><DD
1179 ><P
1180 >    Many Microsoft products that generate HTML use non-standard extensions (read:
1181     violations) of the ISO 8859-1 aka Latin-1 character set. This can cause those
1182     HTML documents to display with errors on standard-compliant platforms. 
1183    </P
1184 ><P
1185 >    This filter translates the MS-only characters into Latin-1 equivalents. 
1186     It is not necessary when using MS products, and will cause corruption of  
1187     all documents that use 8-bit character sets other than Latin-1. It's mostly
1188     worthwhile for Europeans on non-MS platforms, if wierd garbage characters
1189     sometimes appear on some pages, or user agents that don't correct for this on 
1190     the fly.
1191  
1192    </P
1193 ></DD
1194 ><DT
1195 ><SPAN
1196 CLASS="emphasis"
1197 ><I
1198 CLASS="EMPHASIS"
1199 >shockwave-flash</I
1200 ></SPAN
1201 ></DT
1202 ><DD
1203 ><P
1204 >    A filter for shockwave haters. As the name suggests, this filter strips code
1205     out of web pages that is used to embed shockwave flash objects. 
1206    </P
1207 ><P
1208 >   </P
1209 ></DD
1210 ><DT
1211 ><SPAN
1212 CLASS="emphasis"
1213 ><I
1214 CLASS="EMPHASIS"
1215 >quicktime-kioskmode</I
1216 ></SPAN
1217 ></DT
1218 ><DD
1219 ><P
1220 >    Change HTML code that embeds Quicktime objects so that kioskmode, which
1221     prevents saving, is disabled.
1222    </P
1223 ></DD
1224 ><DT
1225 ><SPAN
1226 CLASS="emphasis"
1227 ><I
1228 CLASS="EMPHASIS"
1229 >fun</I
1230 ></SPAN
1231 ></DT
1232 ><DD
1233 ><P
1234 >    Text replacements for subversive browsing fun. Make fun of your favorite
1235     Monopolist or play buzzword bingo.
1236    </P
1237 ></DD
1238 ><DT
1239 ><SPAN
1240 CLASS="emphasis"
1241 ><I
1242 CLASS="EMPHASIS"
1243 >crude-parental</I
1244 ></SPAN
1245 ></DT
1246 ><DD
1247 ><P
1248 >    A demonstration-only filter that shows how <SPAN
1249 CLASS="APPLICATION"
1250 >Privoxy</SPAN
1251 >
1252     can be used to delete web content on a keyword basis.
1253    </P
1254 ></DD
1255 ><DT
1256 ><SPAN
1257 CLASS="emphasis"
1258 ><I
1259 CLASS="EMPHASIS"
1260 >ie-exploits</I
1261 ></SPAN
1262 ></DT
1263 ><DD
1264 ><P
1265 >    A collection of text replacements to disable malicious HTML and JavaScript
1266     code that exploits known security holes in Internet Explorer.
1267    </P
1268 ><P
1269 >    Presently, it only protects against Nimda and a cross-site scripting bug, and
1270     would need active maintenance to provide more substantial protection.
1271    </P
1272 ></DD
1273 ><DT
1274 ><SPAN
1275 CLASS="emphasis"
1276 ><I
1277 CLASS="EMPHASIS"
1278 >site-specifics</I
1279 ></SPAN
1280 ></DT
1281 ><DD
1282 ><P
1283 >    Some web sites have very specific problems, the cure for which doesn't apply
1284     anywhere else, or could even cause damage on other sites.
1285    </P
1286 ><P
1287 >    This is a collection of such site-specific cures which should only be applied
1288     to the sites they were intended for, which is what the supplied
1289     <TT
1290 CLASS="FILENAME"
1291 >default.action</TT
1292 > file does. Users shouldn't need to change
1293     anything regarding this filter.
1294    </P
1295 ></DD
1296 ><DT
1297 ><A
1298 NAME="FILTER-SERVER-HEADERS"
1299 ></A
1300 ><SPAN
1301 CLASS="emphasis"
1302 ><I
1303 CLASS="EMPHASIS"
1304 >filter-server-headers</I
1305 ></SPAN
1306 ></DT
1307 ><DD
1308 ><P
1309 >   </P
1310 ></DD
1311 ><DT
1312 ><A
1313 NAME="FILTER-CLIENT-HEADERS"
1314 ></A
1315 ><SPAN
1316 CLASS="emphasis"
1317 ><I
1318 CLASS="EMPHASIS"
1319 >filter-client-headers</I
1320 ></SPAN
1321 ></DT
1322 ><DD
1323 ><P
1324 >   </P
1325 ></DD
1326 ></DL
1327 ></DIV
1328 ></DIV
1329 ></DIV
1330 ><DIV
1331 CLASS="NAVFOOTER"
1332 ><HR
1333 ALIGN="LEFT"
1334 WIDTH="100%"><TABLE
1335 SUMMARY="Footer navigation table"
1336 WIDTH="100%"
1337 BORDER="0"
1338 CELLPADDING="0"
1339 CELLSPACING="0"
1340 ><TR
1341 ><TD
1342 WIDTH="33%"
1343 ALIGN="left"
1344 VALIGN="top"
1345 ><A
1346 HREF="actions-file.html"
1347 ACCESSKEY="P"
1348 >Prev</A
1349 ></TD
1350 ><TD
1351 WIDTH="34%"
1352 ALIGN="center"
1353 VALIGN="top"
1354 ><A
1355 HREF="index.html"
1356 ACCESSKEY="H"
1357 >Home</A
1358 ></TD
1359 ><TD
1360 WIDTH="33%"
1361 ALIGN="right"
1362 VALIGN="top"
1363 ><A
1364 HREF="templates.html"
1365 ACCESSKEY="N"
1366 >Next</A
1367 ></TD
1368 ></TR
1369 ><TR
1370 ><TD
1371 WIDTH="33%"
1372 ALIGN="left"
1373 VALIGN="top"
1374 >Actions Files</TD
1375 ><TD
1376 WIDTH="34%"
1377 ALIGN="center"
1378 VALIGN="top"
1379 >&nbsp;</TD
1380 ><TD
1381 WIDTH="33%"
1382 ALIGN="right"
1383 VALIGN="top"
1384 >Templates</TD
1385 ></TR
1386 ></TABLE
1387 ></DIV
1388 ></BODY
1389 ></HTML
1390 >