7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10 TITLE="Privoxy 3.0.4 User Manual"
11 HREF="index.html"><LINK
14 HREF="actions-file.html"><LINK
17 HREF="templates.html"><LINK
20 HREF="../p_doc.css"></HEAD
31 SUMMARY="Header navigation table"
40 >Privoxy 3.0.4 User Manual</TH
48 HREF="actions-file.html"
80 > All text substitutions that can be invoked through the
84 HREF="actions-file.html#FILTER"
88 must first be defined in a <SPAN
95 >. Mulitple filter files can be
96 defined through the <TT
99 HREF="config.html#FILTERFILE"
103 option. The filters as supplied by the developers will be found in
107 >. It is recommended that any locally
108 defined or modified filters go in a separately defined file such as
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 <BLINK> 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
122 > Filtering works on any text-based document type, including
123 HTML, JavaScript, CSS etc. (all <TT
137 Substitutions are made at the source level, so if you want to <SPAN
141 > filters, you should be familiar with HTML syntax.</P
144 HREF="actions-file.html"
147 filter file is organized in sections, which are called <SPAN
154 here. Each filter consists of a heading line, that starts with the
171 >, and a short (one line)
178 > of what it does. Below that line
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
194 comment is used in the <A
195 HREF="http://config.privoxy.org/"
201 > Once a filter called <TT
207 in the filter file, it can be invoked by using an action of the form
211 HREF="actions-file.html#FILTER"
221 HREF="actions-file.html"
225 > A filter header line for a filter called <SPAN
239 >FILTER: foo Replace all "foo" with "bar"</PRE
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/"
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
262 which turns the default to ungreedy matching.</P
264 > If you are new to regular expressions, you might want to take a look at
266 HREF="appendix.html#REGEX"
267 >Appendix on regular expressions</A
270 HREF="http://perldoc.com/perl5.6.1/pod/perl.html"
276 HREF="http://perldoc.com/perl5.6.1/pod/perlop.html#s-PATTERN-REPLACEMENT-egimosx"
282 > operator's syntax</A
284 HREF="http://perldoc.com/perl5.6.1/pod/perlre.html"
289 The below examples might also help to get you started.</P
297 >9.1. Filter File Tutorial</H2
299 > Now, let's complete our <SPAN
302 > filter. We have already defined
303 the heading, but the jobs are still missing. Since all it does is to replace
310 >, there is only one (trivial) job
327 > But wait! Didn't the comment say that <SPAN
337 > should be replaced? Our current job will only take
338 care of the first <SPAN
341 > on each page. For global substitution,
342 we'll need to add the <TT
361 > Our complete filter now looks like this:</P
371 >FILTER: foo Replace all "foo" with "bar"
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
390 >FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
392 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
394 s|(<script.*)document\.referrer(.*</script>)|$1"Not Your Business!"$2|Usg</PRE
400 > Following the header line and a comment, you see the job. Note that it uses
404 > as the delimiter instead of <TT
408 the pattern contains a forward slash, which would otherwise have to be escaped
414 > Now, let's examine the pattern: it starts with the text <TT
418 enclosed in parentheses. Since the dot matches any character, and <TT
424 >"Match an arbitrary number of the element left of myself"</SPAN
436 it matches the whole page, from the start of the first <script> tag.</P
438 > That's more than we want, but the pattern continues: <TT
440 >document\.referrer</TT
442 matches only the exact string <SPAN
444 >"document.referrer"</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 <script> tag in a the page, up to, and including,
457 >"document.referrer"</SPAN
465 in the page (and appear in that order).</P
467 > But there's still more pattern to go. The next element, again enclosed in parentheses,
470 >.*</script></TT
471 >. You already know what <TT
475 means, so the whole pattern translates to: Match from the start of the first <script>
476 tag in a page to the end of the last <script> tag, provided that the text
479 >"document.referrer"</SPAN
480 > appears somewhere in between.</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
488 the substitute. The <TT
491 > option switches to ungreedy matching, which means
495 > in the pattern will only <SPAN
499 text in between <SPAN
511 >"document.referrer"</SPAN
512 >, and that the second <TT
516 only span the text up to the <SPAN
524 >"</script>"</SPAN
526 tag. Furthermore, the <TT
529 > option says that the match may span
530 multiple lines in the page, and the <TT
533 > option again means that the
534 substitution is global.</P
536 > So, to summarize, the pattern means: Match all scripts that contain the text
539 >"document.referrer"</SPAN
540 >. Remember the parts of the script from
541 (and including) the start tag up to (and excluding) the string
544 >"document.referrer"</SPAN
548 >, and the part following
549 that string, up to and including the closing tag, as <TT
554 > Now the pattern is deciphered, but wasn't this about substituting things? So
555 lets look at the substitute: <TT
557 >$1"Not Your Business!"$2</TT
559 easy to read: The text remembered as <TT
565 >"Not Your Business!"</TT
573 the quotation marks!), followed by the text remembered as <TT
577 This produces an exact copy of the original string, with the middle part
580 >"document.referrer"</SPAN
587 > The whole job now reads: Replace <SPAN
589 >"document.referrer"</SPAN
593 >"Not Your Business!"</TT
594 > wherever it appears inside a
595 <script> 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
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
611 ># The status bar is for displaying link targets, not pointless blahblah
613 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</PRE
622 > stands for whitespace characters (space, tab, newline,
623 carriage return, form feed), so that <TT
629 or more whitespace"</SPAN
637 makes this matching of arbitrary text ungreedy. (Note that the <TT
641 option is not set). The <TT
644 > construct means: <SPAN
653 > a double quote"</SPAN
658 a backreference to the first parenthesis just like <TT
662 with the difference that in the <SPAN
668 >, a backslash indicates
669 a backreference, whereas in the <SPAN
675 >, it's the dollar.</P
677 > So what does this job do? It replaces assignments of single- or double-quoted
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
695 ># Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
697 s/(<body [^>]*)onunload(.*>)/$1never$2/iU</PRE
705 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
709 > in the HTML DOM was a <SPAN
716 When I close a browser window, I want it to close and die. Basta.
717 This job replaces the <SPAN
723 >"<body>"</SPAN
724 > tags with the dummy word <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
740 > to prevent the match from exceeding the
741 <body> tag if it doesn't contain <SPAN
747 > The last example is from the fun department:</P
757 >FILTER: fun Fun text replacements
759 # Spice the daily news:
761 s/microsoft(?!\.com)/MicroSuck/ig</PRE
770 > part (a so-called negative lookahead)
771 in the job's pattern, which means: Don't match, if the string
775 > appears directly following <SPAN
779 in the page. This prevents links to microsoft.com from being trashed, while
780 still replacing the word everywhere else.</P
790 ># Buzzword Bingo (example for extended regex syntax)
792 s* industry[ -]leading \
794 | customer[ -]focused \
796 | award[ -]winning # Comments are OK, too! \
797 | high[ -]performance \
798 | solutions[ -]based \
802 *<font color="red"><b>BINGO!</b></font> \
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
815 > You get the idea?</P
822 NAME="PREDEFINED-FILTERS"
824 >9.2. The Pre-defined Filters</H2
826 >The distribution <TT
829 > file contains a selection of
830 pre-defined filters for your convenience:</P
846 > The purpose of this filter is to get rid of particularly annoying JavaScript abuse.
853 > replaces JavaScript references to the browser's referrer information
854 with the string "Not Your Business!". This compliments the <TT
857 HREF="actions-file.html#HIDE-REFERRER"
860 > action on the content level.
865 > removes the bindings to the DOM's
867 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
871 > which we feel has no right to exist and is responsible for most <SPAN
873 >"exit consoles"</SPAN
875 nasty windows that pop up when you close another one.
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.
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.
907 >strongly discourage</I
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
924 > This filter will undo many common instances of HTML based abuse.
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.
949 > Most cookies are set in the HTTP dialogue, where they can be intercepted
954 HREF="actions-file.html#CRUNCH-INCOMING-COOKIES"
955 >crunch-incoming-cookies</A
961 HREF="actions-file.html#CRUNCH-OUTGOING-COOKIES"
962 >crunch-outgoing-cookies</A
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.
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.
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
994 >unsolicited-popups</I
999 > This filter attempts to prevent only <SPAN
1001 >"unsolicited"</SPAN
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.
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.
1023 > Attempt to prevent <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
1045 > This is a helper filter that has no value if used alone. It makes the
1048 >banners-by-size</TT
1051 >banners-by-link</TT
1053 (see below) filters more effective and should be enabled together with them.
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.
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.
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.
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.
1109 > This filter removes the HTML code that loads such <SPAN
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.
1131 > It is not recommended to use this filter as a default.
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.
1154 >frameset-borders</I
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.
1166 > This filter removes the related HTML code. It should only be applied to sites
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.
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
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.
1215 >quicktime-kioskmode</I
1220 > Change HTML code that embeds Quicktime objects so that kioskmode, which
1221 prevents saving, is disabled.
1234 > Text replacements for subversive browsing fun. Make fun of your favorite
1235 Monopolist or play buzzword bingo.
1248 > A demonstration-only filter that shows how <SPAN
1252 can be used to delete web content on a keyword basis.
1265 > A collection of text replacements to disable malicious HTML and JavaScript
1266 code that exploits known security holes in Internet Explorer.
1269 > Presently, it only protects against Nimda and a cross-site scripting bug, and
1270 would need active maintenance to provide more substantial protection.
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.
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
1292 > file does. Users shouldn't need to change
1293 anything regarding this filter.
1298 NAME="FILTER-SERVER-HEADERS"
1304 >filter-server-headers</I
1313 NAME="FILTER-CLIENT-HEADERS"
1319 >filter-client-headers</I
1335 SUMMARY="Footer navigation table"
1346 HREF="actions-file.html"
1364 HREF="templates.html"