1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10 TITLE="Privoxy 3.0.14 User Manual"
11 HREF="index.html"><LINK
14 HREF="actions-file.html"><LINK
16 TITLE="Privoxy's Template Files"
17 HREF="templates.html"><LINK
20 HREF="../p_doc.css"><META
21 HTTP-EQUIV="Content-Type"
24 <LINK REL="STYLESHEET" TYPE="text/css" HREF="p_doc.css">
36 SUMMARY="Header navigation table"
45 >Privoxy 3.0.14 User Manual</TH
53 HREF="actions-file.html"
85 > On-the-fly text substitutions need
86 to be defined in a <SPAN
90 can then be invoked as an <SPAN
98 > supports three different filter actions:
102 HREF="actions-file.html#FILTER"
106 rewrite the content that is send to the client,
110 HREF="actions-file.html#CLIENT-HEADER-FILTER"
111 >client-header-filter</A
114 to rewrite headers that are send by the client, and
118 HREF="actions-file.html#SERVER-HEADER-FILTER"
119 >server-header-filter</A
122 to rewrite headers that are send by the server.</P
127 > also supports two tagger actions:
131 HREF="actions-file.html#CLIENT-HEADER-TAGGER"
132 >client-header-tagger</A
139 HREF="actions-file.html#SERVER-HEADER-TAGGER"
140 >server-header-tagger</A
143 Taggers and filters use the same syntax in the filter files, the difference
144 is that taggers don't modify the text they are filtering, but use a rewritten
145 version of the filtered text as tag. The tags can then be used to change the
146 applying actions through sections with <A
147 HREF="actions-file.html#TAG-PATTERN"
151 > Multiple filter files can be defined through the <TT
154 HREF="config.html#FILTERFILE"
157 > config directive. The filters
158 as supplied by the developers are located in
162 >. It is recommended that any locally
163 defined or modified filters go in a separately defined file such as
170 > Common tasks for content filters are to eliminate common annoyances in
171 HTML and JavaScript, such as pop-up windows,
172 exit consoles, crippled windows without navigation tools, the
173 infamous <BLINK> tag etc, to suppress images with certain
174 width and height attributes (standard banner sizes or web-bugs),
175 or just to have fun.</P
177 > Enabled content filters are applied to any content whose
180 >"Content Type"</SPAN
181 > header is recognised as a sign
182 of text-based content, with the exception of <TT
187 HREF="actions-file.html#FORCE-TEXT-MODE"
190 to also filter other content.</P
192 > Substitutions are made at the source level, so if you want to <SPAN
196 > filters, you should first be familiar with HTML syntax,
197 and, of course, regular expressions.</P
200 HREF="actions-file.html"
203 filter file is organized in sections, which are called <SPAN
210 here. Each filter consists of a heading line, that starts with one of the
223 >CLIENT-HEADER-FILTER:</TT
226 >SERVER-HEADER-FILTER:</TT
228 followed by the filter's <SPAN
234 >, and a short (one line)
241 > of what it does. Below that line
248 >, i.e. lines that define the actual
249 text substitutions. By convention, the name of a filter
250 should describe what the filter <SPAN
257 comment is used in the <A
258 HREF="http://config.privoxy.org/"
264 > Once a filter called <TT
270 in the filter file, it can be invoked by using an action of the form
274 HREF="actions-file.html#FILTER"
284 HREF="actions-file.html"
288 > Filter definitions start with a header line that contains the filter
289 type, the filter name and the filter description.
290 A content filter header line for a filter called <SPAN
304 >FILTER: foo Replace all "foo" with "bar"</PRE
310 > Below that line, and up to the next header line, come the jobs that
311 define what text replacements the filter executes. They are specified
312 in a syntax that imitates <A
313 HREF="http://www.perl.org/"
320 > operator. If you are familiar with Perl, you
321 will find this to be quite intuitive, and may want to look at the
322 PCRS documentation for the subtle differences to Perl behaviour. Most
323 notably, the non-standard option letter <TT
327 which turns the default to ungreedy matching.</P
331 HREF="http://en.wikipedia.org/wiki/Regular_expressions"
338 >, you might want to take a look at
340 HREF="appendix.html#REGEX"
341 >Appendix on regular expressions</A
344 HREF="http://perldoc.perl.org/perlre.html"
350 HREF="http://perldoc.perl.org/perlop.html"
356 > operator's syntax</A
358 HREF="http://perldoc.perl.org/perlre.html"
363 The below examples might also help to get you started.</P
370 >9.1. Filter File Tutorial</A
373 > Now, let's complete our <SPAN
376 > content filter. We have already defined
377 the heading, but the jobs are still missing. Since all it does is to replace
384 >, there is only one (trivial) job
401 > But wait! Didn't the comment say that <SPAN
411 > should be replaced? Our current job will only take
412 care of the first <SPAN
415 > on each page. For global substitution,
416 we'll need to add the <TT
435 > Our complete filter now looks like this:</P
445 >FILTER: foo Replace all "foo" with "bar"
452 > Let's look at some real filters for more interesting examples. Here you see
453 a filter that protects against some common annoyances that arise from JavaScript
454 abuse. Let's look at its jobs one after the other:</P
464 >FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
466 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
468 s|(<script.*)document\.referrer(.*</script>)|$1"Not Your Business!"$2|Usg</PRE
474 > Following the header line and a comment, you see the job. Note that it uses
478 > as the delimiter instead of <TT
482 the pattern contains a forward slash, which would otherwise have to be escaped
488 > Now, let's examine the pattern: it starts with the text <TT
492 enclosed in parentheses. Since the dot matches any character, and <TT
498 >"Match an arbitrary number of the element left of myself"</SPAN
510 it matches the whole page, from the start of the first <script> tag.</P
512 > That's more than we want, but the pattern continues: <TT
514 >document\.referrer</TT
516 matches only the exact string <SPAN
518 >"document.referrer"</SPAN
526 >, i.e. preceded by a backslash, to take away its
527 special meaning as a joker, and make it just a regular dot. So far, the meaning is:
528 Match from the start of the first <script> tag in a the page, up to, and including,
531 >"document.referrer"</SPAN
539 in the page (and appear in that order).</P
541 > But there's still more pattern to go. The next element, again enclosed in parentheses,
544 >.*</script></TT
545 >. You already know what <TT
549 means, so the whole pattern translates to: Match from the start of the first <script>
550 tag in a page to the end of the last <script> tag, provided that the text
553 >"document.referrer"</SPAN
554 > appears somewhere in between.</P
556 > This is still not the whole story, since we have ignored the options and the parentheses:
557 The portions of the page matched by sub-patterns that are enclosed in parentheses, will be
558 remembered and be available through the variables <TT
562 the substitute. The <TT
565 > option switches to ungreedy matching, which means
569 > in the pattern will only <SPAN
573 text in between <SPAN
585 >"document.referrer"</SPAN
586 >, and that the second <TT
590 only span the text up to the <SPAN
598 >"</script>"</SPAN
600 tag. Furthermore, the <TT
603 > option says that the match may span
604 multiple lines in the page, and the <TT
607 > option again means that the
608 substitution is global.</P
610 > So, to summarize, the pattern means: Match all scripts that contain the text
613 >"document.referrer"</SPAN
614 >. Remember the parts of the script from
615 (and including) the start tag up to (and excluding) the string
618 >"document.referrer"</SPAN
622 >, and the part following
623 that string, up to and including the closing tag, as <TT
628 > Now the pattern is deciphered, but wasn't this about substituting things? So
629 lets look at the substitute: <TT
631 >$1"Not Your Business!"$2</TT
633 easy to read: The text remembered as <TT
639 >"Not Your Business!"</TT
647 the quotation marks!), followed by the text remembered as <TT
651 This produces an exact copy of the original string, with the middle part
654 >"document.referrer"</SPAN
661 > The whole job now reads: Replace <SPAN
663 >"document.referrer"</SPAN
667 >"Not Your Business!"</TT
668 > wherever it appears inside a
669 <script> tag. Note that this job won't break JavaScript syntax,
670 since both the original and the replacement are syntactically valid
671 string objects. The script just won't have access to the referrer
672 information anymore.</P
674 > We'll show you two other jobs from the JavaScript taming department, but
675 this time only point out the constructs of special interest:</P
685 ># The status bar is for displaying link targets, not pointless blahblah
687 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</PRE
696 > stands for whitespace characters (space, tab, newline,
697 carriage return, form feed), so that <TT
703 or more whitespace"</SPAN
711 makes this matching of arbitrary text ungreedy. (Note that the <TT
715 option is not set). The <TT
718 > construct means: <SPAN
727 > a double quote"</SPAN
732 a back-reference to the first parenthesis just like <TT
736 with the difference that in the <SPAN
742 >, a backslash indicates
743 a back-reference, whereas in the <SPAN
749 >, it's the dollar.</P
751 > So what does this job do? It replaces assignments of single- or double-quoted
754 >"window.status"</SPAN
755 > object with a dummy assignment
756 (using a variable name that is hopefully odd enough not to conflict with
757 real variables in scripts). Thus, it catches many cases where e.g. pointless
758 descriptions are displayed in the status bar instead of the link target when
759 you move your mouse over links.</P
769 ># Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
771 s/(<body [^>]*)onunload(.*>)/$1never$2/iU</PRE
779 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
783 > in the HTML DOM was a <SPAN
790 When I close a browser window, I want it to close and die. Basta.
791 This job replaces the <SPAN
797 >"<body>"</SPAN
798 > tags with the dummy word <TT
805 > option makes the pattern matching
806 case-insensitive. Also note that ungreedy matching alone doesn't always guarantee
807 a minimal match: In the first parenthesis, we had to use <TT
814 > to prevent the match from exceeding the
815 <body> tag if it doesn't contain <SPAN
821 > The last example is from the fun department:</P
831 >FILTER: fun Fun text replacements
833 # Spice the daily news:
835 s/microsoft(?!\.com)/MicroSuck/ig</PRE
844 > part (a so-called negative lookahead)
845 in the job's pattern, which means: Don't match, if the string
849 > appears directly following <SPAN
853 in the page. This prevents links to microsoft.com from being trashed, while
854 still replacing the word everywhere else.</P
864 ># Buzzword Bingo (example for extended regex syntax)
866 s* industry[ -]leading \
868 | customer[ -]focused \
870 | award[ -]winning # Comments are OK, too! \
871 | high[ -]performance \
872 | solutions[ -]based \
876 *<font color="red"><b>BINGO!</b></font> \
886 > option in this job turns on extended syntax, and allows for
887 e.g. the liberal use of (non-interpreted!) whitespace for nicer formatting. </P
889 > You get the idea?</P
896 NAME="PREDEFINED-FILTERS"
897 >9.2. The Pre-defined Filters</A
900 >The distribution <TT
903 > file contains a selection of
904 pre-defined filters for your convenience:</P
920 > The purpose of this filter is to get rid of particularly annoying JavaScript abuse.
927 > replaces JavaScript references to the browser's referrer information
928 with the string "Not Your Business!". This compliments the <TT
931 HREF="actions-file.html#HIDE-REFERRER"
934 > action on the content level.
939 > removes the bindings to the DOM's
941 HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
945 > which we feel has no right to exist and is responsible for most <SPAN
947 >"exit consoles"</SPAN
949 nasty windows that pop up when you close another one.
954 > removes code that causes new windows to be opened with undesired properties, such as being
955 full-screen, non-resizeable, without location, status or menu bar etc.
962 > Use with caution. This is an aggressive filter, and can break sites that
963 rely heavily on JavaScript.
976 > This is a very radical measure. It removes virtually all JavaScript event bindings, which
977 means that scripts can not react to user actions such as mouse movements or clicks, window
978 resizing etc, anymore. Use with caution!
985 >strongly discourage</I
987 > using this filter as a default since it breaks
988 many legitimate scripts. It is meant for use only on extra-nasty sites (should you really
1002 > This filter will undo many common instances of HTML based abuse.
1012 are neutralized (yeah baby!), and browser windows will be created as
1013 resizeable (as of course they should be!), and will have location,
1014 scroll and menu bars -- even if specified otherwise.
1027 > Most cookies are set in the HTTP dialog, where they can be intercepted
1032 HREF="actions-file.html#CRUNCH-INCOMING-COOKIES"
1033 >crunch-incoming-cookies</A
1039 HREF="actions-file.html#CRUNCH-OUTGOING-COOKIES"
1040 >crunch-outgoing-cookies</A
1043 actions. But web sites increasingly make use of HTML meta tags and JavaScript
1044 to sneak cookies to the browser on the content level.
1047 > This filter disables most HTML and JavaScript code that reads or sets
1048 cookies. It cannot detect all clever uses of these types of code, so it
1049 should not be relied on as an absolute fix. Use it wherever you would also
1050 use the cookie crunch actions.
1063 > Disable any refresh tags if the interval is greater than nine seconds (so
1064 that redirections done via refresh tags are not destroyed). This is useful
1065 for dial-on-demand setups, or for those who find this HTML feature
1074 >unsolicited-popups</I
1079 > This filter attempts to prevent only <SPAN
1081 >"unsolicited"</SPAN
1083 windows from opening, yet still allow pop-up windows that the user
1084 has explicitly chosen to open. It was added in version 3.0.1,
1085 as an improvement over earlier such filters.
1088 > Technical note: The filter works by redefining the window.open JavaScript
1089 function to a dummy function, <TT
1091 >PrivoxyWindowOpen()</TT
1093 during the loading and rendering phase of each HTML page access, and
1094 restoring the function afterward.
1097 > This is recommended only for browsers that cannot perform this function
1098 reliably themselves. And be aware that some sites require such windows
1099 in order to function normally. Use with caution.
1112 > Attempt to prevent <SPAN
1118 > pop-up windows from opening.
1119 Note this should be used with even more discretion than the above, since
1120 it is more likely to break some sites that require pop-ups for normal
1121 usage. Use with caution.
1134 > This is a helper filter that has no value if used alone. It makes the
1137 >banners-by-size</TT
1140 >banners-by-link</TT
1142 (see below) filters more effective and should be enabled together with them.
1155 > This filter removes image tags purely based on what size they are. Fortunately
1156 for us, many ads and banner images tend to conform to certain standardized
1157 sizes, which makes this filter quite effective for ad stripping purposes.
1160 > Occasionally this filter will cause false positives on images that are not ads,
1161 but just happen to be of one of the standard banner sizes.
1164 > Recommended only for those who require extreme ad blocking. The default
1165 block rules should catch 95+% of all ads <SPAN
1171 > this filter enabled.
1184 > This is an experimental filter that attempts to kill any banners if
1185 their URLs seem to point to known or suspected click trackers. It is currently
1186 not of much value and is not recommended for use by default.
1199 > Webbugs are small, invisible images (technically 1X1 GIF images), that
1200 are used to track users across websites, and collect information on them.
1201 As an HTML page is loaded by the browser, an embedded image tag causes the
1202 browser to contact a third-party site, disclosing the tracking information
1203 through the requested URL and/or cookies for that third-party domain, without
1204 the user ever becoming aware of the interaction with the third-party site.
1205 HTML-ized spam also uses a similar technique to verify email addresses.
1208 > This filter removes the HTML code that loads such <SPAN
1224 > A rather special-purpose filter that can be used to enlarge textareas (those
1225 multi-line text boxes in web forms) and turn off hard word wrap in them.
1226 It was written for the sourceforge.net tracker system where such boxes are
1227 a nuisance, but it can be handy on other sites, too.
1230 > It is not recommended to use this filter as a default.
1243 > Many consider windows that move, or resize themselves to be abusive. This filter
1244 neutralizes the related JavaScript code. Note that some sites might not display
1245 or behave as intended when using this filter. Use with caution.
1253 >frameset-borders</I
1258 > Some web designers seem to assume that everyone in the world will view their
1259 web sites using the same browser brand and version, screen resolution etc,
1260 because only that assumption could explain why they'd use static frame sizes,
1261 yet prevent their frames from being resized by the user, should they be too
1262 small to show their whole content.
1265 > This filter removes the related HTML code. It should only be applied to sites
1279 > Many Microsoft products that generate HTML use non-standard extensions (read:
1280 violations) of the ISO 8859-1 aka Latin-1 character set. This can cause those
1281 HTML documents to display with errors on standard-compliant platforms.
1284 > This filter translates the MS-only characters into Latin-1 equivalents.
1285 It is not necessary when using MS products, and will cause corruption of
1286 all documents that use 8-bit character sets other than Latin-1. It's mostly
1287 worthwhile for Europeans on non-MS platforms, if weird garbage characters
1288 sometimes appear on some pages, or user agents that don't correct for this on
1303 > A filter for shockwave haters. As the name suggests, this filter strips code
1304 out of web pages that is used to embed shockwave flash objects.
1314 >quicktime-kioskmode</I
1319 > Change HTML code that embeds Quicktime objects so that kioskmode, which
1320 prevents saving, is disabled.
1333 > Text replacements for subversive browsing fun. Make fun of your favorite
1334 Monopolist or play buzzword bingo.
1347 > A demonstration-only filter that shows how <SPAN
1351 can be used to delete web content on a keyword basis.
1364 > An experimental collection of text replacements to disable malicious HTML and JavaScript
1365 code that exploits known security holes in Internet Explorer.
1368 > Presently, it only protects against Nimda and a cross-site scripting bug, and
1369 would need active maintenance to provide more substantial protection.
1382 > Some web sites have very specific problems, the cure for which doesn't apply
1383 anywhere else, or could even cause damage on other sites.
1386 > This is a collection of such site-specific cures which should only be applied
1387 to the sites they were intended for, which is what the supplied
1391 > file does. Users shouldn't need to change
1392 anything regarding this filter.
1405 > A CSS based block for Google text ads. Also removes a width limitation
1406 and the toolbar advertisement.
1419 > Another CSS based block, this time for Yahoo text ads. And removes
1420 a width limitation as well.
1433 > Another CSS based block, this time for MSN text ads. And removes
1434 tracking URLs, as well as a width limitation.
1447 > Cleans up some Blogspot blogs. Read the fine print before using this one!
1450 > This filter also intentionally removes some navigation stuff and sets the
1451 page width to 100%. As a result, some rounded <SPAN
1455 appear to early or not at all and as fixing this would require a browser
1456 that understands background-size (CSS3), they are removed instead.
1469 > Server-header filter to change the Content-Type from xml to html.
1482 > Server-header filter to change the Content-Type from html to xml.
1495 > Removes the non-standard <TT
1499 anchor and area HTML tags.
1507 >hide-tor-exit-notation</I
1512 > Client-header filter to remove the <B
1515 > exit node notation
1516 found in Host and Referer headers.
1525 > are chained and <SPAN
1529 is configured to use socks4a, one can use <SPAN
1531 >"http://www.example.org.foobar.exit/"</SPAN
1533 to access the host <SPAN
1535 >"www.example.org"</SPAN
1546 > As the HTTP client isn't aware of this notation, it treats the
1549 >"www.example.org.foobar.exit"</SPAN
1550 > as host and uses it
1558 server's point of view the resulting headers are invalid and can cause problems.
1564 > header can trigger <SPAN
1566 >"hot-linking"</SPAN
1568 protections, an invalid <SPAN
1571 > header will make it impossible for
1572 the server to find the right vhost (several domains hosted on the same IP address).
1575 > This client-header filter removes the <SPAN
1578 > part in those headers
1579 to prevent the mentioned problems. Note that it only modifies
1580 the HTTP headers, it doesn't make it impossible for the server
1584 > exit node based on the IP address
1585 the request is coming from.
1597 SUMMARY="Footer navigation table"
1608 HREF="actions-file.html"
1626 HREF="templates.html"
1646 >Privoxy's Template Files</TD