1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <title>Filter Files</title>
6 <meta name="GENERATOR" content=
7 "Modular DocBook HTML Stylesheet Version 1.79">
8 <link rel="HOME" title="Privoxy 3.0.26 User Manual" href="index.html">
9 <link rel="PREVIOUS" title="Actions Files" href="actions-file.html">
10 <link rel="NEXT" title="Privoxy's Template Files" href="templates.html">
11 <link rel="STYLESHEET" type="text/css" href="../p_doc.css">
12 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
13 <link rel="STYLESHEET" type="text/css" href="p_doc.css">
15 <body class="SECT1" bgcolor="#EEEEEE" text="#000000" link="#0000FF" vlink=
16 "#840084" alink="#0000FF">
17 <div class="NAVHEADER">
18 <table summary="Header navigation table" width="100%" border="0"
19 cellpadding="0" cellspacing="0">
21 <th colspan="3" align="center">Privoxy 3.0.26 User Manual</th>
24 <td width="10%" align="left" valign="bottom"><a href=
25 "actions-file.html" accesskey="P">Prev</a></td>
26 <td width="80%" align="center" valign="bottom"></td>
27 <td width="10%" align="right" valign="bottom"><a href=
28 "templates.html" accesskey="N">Next</a></td>
31 <hr align="left" width="100%">
34 <h1 class="SECT1"><a name="FILTER-FILE" id="FILTER-FILE">9. Filter
36 <p>On-the-fly text substitutions need to be defined in a <span class=
37 "QUOTE">"filter file"</span>. Once defined, they can then be invoked as
38 an <span class="QUOTE">"action"</span>.</p>
39 <p><span class="APPLICATION">Privoxy</span> supports three different
40 pcrs-based filter actions: <tt class="LITERAL"><a href=
41 "actions-file.html#FILTER">filter</a></tt> to rewrite the content that is
42 send to the client, <tt class="LITERAL"><a href=
43 "actions-file.html#CLIENT-HEADER-FILTER">client-header-filter</a></tt> to
44 rewrite headers that are send by the client, and <tt class=
46 "actions-file.html#SERVER-HEADER-FILTER">server-header-filter</a></tt> to
47 rewrite headers that are send by the server.</p>
48 <p><span class="APPLICATION">Privoxy</span> also supports two tagger
49 actions: <tt class="LITERAL"><a href=
50 "actions-file.html#CLIENT-HEADER-TAGGER">client-header-tagger</a></tt>
51 and <tt class="LITERAL"><a href=
52 "actions-file.html#SERVER-HEADER-TAGGER">server-header-tagger</a></tt>.
53 Taggers and filters use the same syntax in the filter files, the
54 difference is that taggers don't modify the text they are filtering, but
55 use a rewritten version of the filtered text as tag. The tags can then be
56 used to change the applying actions through sections with <a href=
57 "actions-file.html#TAG-PATTERN">tag-patterns</a>.</p>
58 <p>Finally <span class="APPLICATION">Privoxy</span> supports the
59 <tt class="LITERAL"><a href=
60 "actions-file.html#EXTERNAL-FILTER">external-filter</a></tt> action to
61 enable <tt class="LITERAL"><a href=
62 "filter-file.html#EXTERNAL-FILTER-SYNTAX">external filters</a></tt>
63 written in proper programming languages.</p>
64 <p>Multiple filter files can be defined through the <tt class=
65 "LITERAL"><a href="config.html#FILTERFILE">filterfile</a></tt> config
66 directive. The filters as supplied by the developers are located in
67 <tt class="FILENAME">default.filter</tt>. It is recommended that any
68 locally defined or modified filters go in a separately defined file such
69 as <tt class="FILENAME">user.filter</tt>.</p>
70 <p>Common tasks for content filters are to eliminate common annoyances in
71 HTML and JavaScript, such as pop-up windows, exit consoles, crippled
72 windows without navigation tools, the infamous <BLINK> tag etc, to
73 suppress images with certain width and height attributes (standard banner
74 sizes or web-bugs), or just to have fun.</p>
75 <p>Enabled content filters are applied to any content whose <span class=
76 "QUOTE">"Content Type"</span> header is recognised as a sign of
77 text-based content, with the exception of <tt class=
78 "LITERAL">text/plain</tt>. Use the <a href=
79 "actions-file.html#FORCE-TEXT-MODE">force-text-mode</a> action to also
80 filter other content.</p>
81 <p>Substitutions are made at the source level, so if you want to
82 <span class="QUOTE">"roll your own"</span> filters, you should first be
83 familiar with HTML syntax, and, of course, regular expressions.</p>
84 <p>Just like the <a href="actions-file.html">actions files</a>, the
85 filter file is organized in sections, which are called <span class=
86 "emphasis"><i class="EMPHASIS">filters</i></span> here. Each filter
87 consists of a heading line, that starts with one of the <span class=
88 "emphasis"><i class="EMPHASIS">keywords</i></span> <tt class=
89 "LITERAL">FILTER:</tt>, <tt class="LITERAL">CLIENT-HEADER-FILTER:</tt> or
90 <tt class="LITERAL">SERVER-HEADER-FILTER:</tt> followed by the filter's
91 <span class="emphasis"><i class="EMPHASIS">name</i></span>, and a short
92 (one line) <span class="emphasis"><i class=
93 "EMPHASIS">description</i></span> of what it does. Below that line come
94 the <span class="emphasis"><i class="EMPHASIS">jobs</i></span>, i.e.
95 lines that define the actual text substitutions. By convention, the name
96 of a filter should describe what the filter <span class=
97 "emphasis"><i class="EMPHASIS">eliminates</i></span>. The comment is used
98 in the <a href="http://config.privoxy.org/" target="_top">web-based user
100 <p>Once a filter called <tt class="REPLACEABLE"><i>name</i></tt> has been
101 defined in the filter file, it can be invoked by using an action of the
102 form +<tt class="LITERAL"><a href=
103 "actions-file.html#FILTER">filter</a>{<tt class=
104 "REPLACEABLE"><i>name</i></tt>}</tt> in any <a href=
105 "actions-file.html">actions file</a>.</p>
106 <p>Filter definitions start with a header line that contains the filter
107 type, the filter name and the filter description. A content filter header
108 line for a filter called <span class="QUOTE">"foo"</span> could look like
110 <table border="0" bgcolor="#E0E0E0" width="100%">
113 <pre class="SCREEN">FILTER: foo Replace all "foo" with "bar"</pre>
117 <p>Below that line, and up to the next header line, come the jobs that
118 define what text replacements the filter executes. They are specified in
119 a syntax that imitates <a href="http://www.perl.org/" target=
120 "_top">Perl</a>'s <tt class="LITERAL">s///</tt> operator. If you are
121 familiar with Perl, you will find this to be quite intuitive, and may
122 want to look at the PCRS documentation for the subtle differences to Perl
124 <p>Most notably, the non-standard option letter <tt class=
125 "LITERAL">U</tt> is supported, which turns the default to ungreedy
126 matching (add <tt class="LITERAL">?</tt> to quantifiers to turn them
128 <p>The non-standard option letter <tt class="LITERAL">D</tt> (dynamic)
129 allows to use the variables $host, $origin (the IP address the request
130 came from), $path, $url and $listen-address (the address on which Privoxy
131 accepted the client request. Example: 127.0.0.1:8118). They will be
132 replaced with the value they refer to before the filter is executed.</p>
133 <p>Note that '$' is a bad choice for a delimiter in a dynamic filter as
134 you might end up with unintended variables if you use a variable name
135 directly after the delimiter. Variables will be resolved without escaping
136 anything, therefore you also have to be careful not to chose delimiters
137 that appear in the replacement text. For example '<' should be save,
138 while '?' will sooner or later cause conflicts with $url.</p>
139 <p>The non-standard option letter <tt class="LITERAL">T</tt> (trivial)
140 prevents parsing for backreferences in the substitute. Use it if you want
141 to include text like '$&' in your substitute without quoting.</p>
142 <p>If you are new to <a href=
143 "http://en.wikipedia.org/wiki/Regular_expressions" target=
144 "_top"><span class="QUOTE">"Regular Expressions"</span></a>, you might
145 want to take a look at the <a href="appendix.html#REGEX">Appendix on
146 regular expressions</a>, and see the <a href=
147 "http://perldoc.perl.org/perlre.html" target="_top">Perl manual</a> for
148 <a href="http://perldoc.perl.org/perlop.html" target="_top">the
149 <tt class="LITERAL">s///</tt> operator's syntax</a> and <a href=
150 "http://perldoc.perl.org/perlre.html" target="_top">Perl-style regular
151 expressions</a> in general. The below examples might also help to get you
154 <h2 class="SECT2"><a name="FILTER-FILE-TUT" id="FILTER-FILE-TUT">9.1.
155 Filter File Tutorial</a></h2>
156 <p>Now, let's complete our <span class="QUOTE">"foo"</span> content
157 filter. We have already defined the heading, but the jobs are still
158 missing. Since all it does is to replace <span class=
159 "QUOTE">"foo"</span> with <span class="QUOTE">"bar"</span>, there is
160 only one (trivial) job needed:</p>
161 <table border="0" bgcolor="#E0E0E0" width="100%">
164 <pre class="SCREEN">s/foo/bar/</pre>
168 <p>But wait! Didn't the comment say that <span class=
169 "emphasis"><i class="EMPHASIS">all</i></span> occurrences of
170 <span class="QUOTE">"foo"</span> should be replaced? Our current job
171 will only take care of the first <span class="QUOTE">"foo"</span> on
172 each page. For global substitution, we'll need to add the <tt class=
173 "LITERAL">g</tt> option:</p>
174 <table border="0" bgcolor="#E0E0E0" width="100%">
177 <pre class="SCREEN">s/foo/bar/g</pre>
181 <p>Our complete filter now looks like this:</p>
182 <table border="0" bgcolor="#E0E0E0" width="100%">
185 <pre class="SCREEN">FILTER: foo Replace all "foo" with "bar"
190 <p>Let's look at some real filters for more interesting examples. Here
191 you see a filter that protects against some common annoyances that
192 arise from JavaScript abuse. Let's look at its jobs one after the
194 <table border="0" bgcolor="#E0E0E0" width="100%">
198 FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
200 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
202 s|(<script.*)document\.referrer(.*</script>)|$1"Not Your Business!"$2|Usg</pre>
206 <p>Following the header line and a comment, you see the job. Note that
207 it uses <tt class="LITERAL">|</tt> as the delimiter instead of
208 <tt class="LITERAL">/</tt>, because the pattern contains a forward
209 slash, which would otherwise have to be escaped by a backslash
210 (<tt class="LITERAL">\</tt>).</p>
211 <p>Now, let's examine the pattern: it starts with the text <tt class=
212 "LITERAL"><script.*</tt> enclosed in parentheses. Since the dot
213 matches any character, and <tt class="LITERAL">*</tt> means:
214 <span class="QUOTE">"Match an arbitrary number of the element left of
215 myself"</span>, this matches <span class="QUOTE">"<script"</span>,
216 followed by <span class="emphasis"><i class="EMPHASIS">any</i></span>
217 text, i.e. it matches the whole page, from the start of the first
218 <script> tag.</p>
219 <p>That's more than we want, but the pattern continues: <tt class=
220 "LITERAL">document\.referrer</tt> matches only the exact string
221 <span class="QUOTE">"document.referrer"</span>. The dot needed to be
222 <span class="emphasis"><i class="EMPHASIS">escaped</i></span>, i.e.
223 preceded by a backslash, to take away its special meaning as a joker,
224 and make it just a regular dot. So far, the meaning is: Match from the
225 start of the first <script> tag in a the page, up to, and
226 including, the text <span class="QUOTE">"document.referrer"</span>, if
227 <span class="emphasis"><i class="EMPHASIS">both</i></span> are present
228 in the page (and appear in that order).</p>
229 <p>But there's still more pattern to go. The next element, again
230 enclosed in parentheses, is <tt class="LITERAL">.*</script></tt>.
231 You already know what <tt class="LITERAL">.*</tt> means, so the whole
232 pattern translates to: Match from the start of the first <script>
233 tag in a page to the end of the last <script> tag, provided that
234 the text <span class="QUOTE">"document.referrer"</span> appears
235 somewhere in between.</p>
236 <p>This is still not the whole story, since we have ignored the options
237 and the parentheses: The portions of the page matched by sub-patterns
238 that are enclosed in parentheses, will be remembered and be available
239 through the variables <tt class="LITERAL">$1, $2, ...</tt> in the
240 substitute. The <tt class="LITERAL">U</tt> option switches to ungreedy
241 matching, which means that the first <tt class="LITERAL">.*</tt> in the
242 pattern will only <span class="QUOTE">"eat up"</span> all text in
243 between <span class="QUOTE">"<script"</span> and the <span class=
244 "emphasis"><i class="EMPHASIS">first</i></span> occurrence of
245 <span class="QUOTE">"document.referrer"</span>, and that the second
246 <tt class="LITERAL">.*</tt> will only span the text up to the
247 <span class="emphasis"><i class="EMPHASIS">first</i></span>
248 <span class="QUOTE">"</script>"</span> tag. Furthermore, the
249 <tt class="LITERAL">s</tt> option says that the match may span multiple
250 lines in the page, and the <tt class="LITERAL">g</tt> option again
251 means that the substitution is global.</p>
252 <p>So, to summarize, the pattern means: Match all scripts that contain
253 the text <span class="QUOTE">"document.referrer"</span>. Remember the
254 parts of the script from (and including) the start tag up to (and
255 excluding) the string <span class="QUOTE">"document.referrer"</span> as
256 <tt class="LITERAL">$1</tt>, and the part following that string, up to
257 and including the closing tag, as <tt class="LITERAL">$2</tt>.</p>
258 <p>Now the pattern is deciphered, but wasn't this about substituting
259 things? So lets look at the substitute: <tt class="LITERAL">$1"Not Your
260 Business!"$2</tt> is easy to read: The text remembered as <tt class=
261 "LITERAL">$1</tt>, followed by <tt class="LITERAL">"Not Your
262 Business!"</tt> (<span class="emphasis"><i class=
263 "EMPHASIS">including</i></span> the quotation marks!), followed by the
264 text remembered as <tt class="LITERAL">$2</tt>. This produces an exact
265 copy of the original string, with the middle part (the <span class=
266 "QUOTE">"document.referrer"</span>) replaced by <tt class=
267 "LITERAL">"Not Your Business!"</tt>.</p>
268 <p>The whole job now reads: Replace <span class=
269 "QUOTE">"document.referrer"</span> by <tt class="LITERAL">"Not Your
270 Business!"</tt> wherever it appears inside a <script> tag. Note
271 that this job won't break JavaScript syntax, since both the original
272 and the replacement are syntactically valid string objects. The script
273 just won't have access to the referrer information anymore.</p>
274 <p>We'll show you two other jobs from the JavaScript taming department,
275 but this time only point out the constructs of special interest:</p>
276 <table border="0" bgcolor="#E0E0E0" width="100%">
280 # The status bar is for displaying link targets, not pointless blahblah
282 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</pre>
286 <p><tt class="LITERAL">\s</tt> stands for whitespace characters (space,
287 tab, newline, carriage return, form feed), so that <tt class=
288 "LITERAL">\s*</tt> means: <span class="QUOTE">"zero or more
289 whitespace"</span>. The <tt class="LITERAL">?</tt> in <tt class=
290 "LITERAL">.*?</tt> makes this matching of arbitrary text ungreedy.
291 (Note that the <tt class="LITERAL">U</tt> option is not set). The
292 <tt class="LITERAL">['"]</tt> construct means: <span class="QUOTE">"a
293 single <span class="emphasis"><i class="EMPHASIS">or</i></span> a
294 double quote"</span>. Finally, <tt class="LITERAL">\1</tt> is a
295 back-reference to the first parenthesis just like <tt class=
296 "LITERAL">$1</tt> above, with the difference that in the <span class=
297 "emphasis"><i class="EMPHASIS">pattern</i></span>, a backslash
298 indicates a back-reference, whereas in the <span class=
299 "emphasis"><i class="EMPHASIS">substitute</i></span>, it's the
301 <p>So what does this job do? It replaces assignments of single- or
302 double-quoted strings to the <span class="QUOTE">"window.status"</span>
303 object with a dummy assignment (using a variable name that is hopefully
304 odd enough not to conflict with real variables in scripts). Thus, it
305 catches many cases where e.g. pointless descriptions are displayed in
306 the status bar instead of the link target when you move your mouse over
308 <table border="0" bgcolor="#E0E0E0" width="100%">
312 # Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
314 s/(<body [^>]*)onunload(.*>)/$1never$2/iU</pre>
318 <p>Including the <a href=
319 "http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
320 target="_top">OnUnload event binding</a> in the HTML DOM was a
321 <span class="emphasis"><i class="EMPHASIS">CRIME</i></span>. When I
322 close a browser window, I want it to close and die. Basta. This job
323 replaces the <span class="QUOTE">"onunload"</span> attribute in
324 <span class="QUOTE">"<body>"</span> tags with the dummy word
325 <tt class="LITERAL">never</tt>. Note that the <tt class=
326 "LITERAL">i</tt> option makes the pattern matching case-insensitive.
327 Also note that ungreedy matching alone doesn't always guarantee a
328 minimal match: In the first parenthesis, we had to use <tt class=
329 "LITERAL">[^>]*</tt> instead of <tt class="LITERAL">.*</tt> to
330 prevent the match from exceeding the <body> tag if it doesn't
331 contain <span class="QUOTE">"OnUnload"</span>, but the page's content
333 <p>The last example is from the fun department:</p>
334 <table border="0" bgcolor="#E0E0E0" width="100%">
337 <pre class="SCREEN">FILTER: fun Fun text replacements
339 # Spice the daily news:
341 s/microsoft(?!\.com)/MicroSuck/ig</pre>
345 <p>Note the <tt class="LITERAL">(?!\.com)</tt> part (a so-called
346 negative lookahead) in the job's pattern, which means: Don't match, if
347 the string <span class="QUOTE">".com"</span> appears directly following
348 <span class="QUOTE">"microsoft"</span> in the page. This prevents links
349 to microsoft.com from being trashed, while still replacing the word
351 <table border="0" bgcolor="#E0E0E0" width="100%">
355 # Buzzword Bingo (example for extended regex syntax)
357 s* industry[ -]leading \
359 | customer[ -]focused \
361 | award[ -]winning # Comments are OK, too! \
362 | high[ -]performance \
363 | solutions[ -]based \
367 *<font color="red"><b>BINGO!</b></font> \
372 <p>The <tt class="LITERAL">x</tt> option in this job turns on extended
373 syntax, and allows for e.g. the liberal use of (non-interpreted!)
374 whitespace for nicer formatting.</p>
375 <p>You get the idea?</p>
378 <h2 class="SECT2"><a name="PREDEFINED-FILTERS" id=
379 "PREDEFINED-FILTERS">9.2. The Pre-defined Filters</a></h2>
380 <p>The distribution <tt class="FILENAME">default.filter</tt> file
381 contains a selection of pre-defined filters for your convenience:</p>
382 <div class="VARIABLELIST">
384 <dt><span class="emphasis"><i class=
385 "EMPHASIS">js-annoyances</i></span></dt>
387 <p>The purpose of this filter is to get rid of particularly
388 annoying JavaScript abuse. To that end, it</p>
391 <p>replaces JavaScript references to the browser's referrer
392 information with the string "Not Your Business!". This
393 compliments the <tt class="LITERAL"><a href=
394 "actions-file.html#HIDE-REFERRER">hide-referrer</a></tt>
395 action on the content level.</p>
398 <p>removes the bindings to the DOM's <a href=
399 "http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents"
400 target="_top">unload event</a> which we feel has no right to
401 exist and is responsible for most <span class="QUOTE">"exit
402 consoles"</span>, i.e. nasty windows that pop up when you
403 close another one.</p>
406 <p>removes code that causes new windows to be opened with
407 undesired properties, such as being full-screen,
408 non-resizeable, without location, status or menu bar etc.</p>
411 <p>Use with caution. This is an aggressive filter, and can break
412 sites that rely heavily on JavaScript.</p>
414 <dt><span class="emphasis"><i class=
415 "EMPHASIS">js-events</i></span></dt>
417 <p>This is a very radical measure. It removes virtually all
418 JavaScript event bindings, which means that scripts can not react
419 to user actions such as mouse movements or clicks, window
420 resizing etc, anymore. Use with caution!</p>
421 <p>We <span class="emphasis"><i class="EMPHASIS">strongly
422 discourage</i></span> using this filter as a default since it
423 breaks many legitimate scripts. It is meant for use only on
424 extra-nasty sites (should you really need to go there).</p>
426 <dt><span class="emphasis"><i class=
427 "EMPHASIS">html-annoyances</i></span></dt>
429 <p>This filter will undo many common instances of HTML based
431 <p>The <tt class="LITERAL">BLINK</tt> and <tt class=
432 "LITERAL">MARQUEE</tt> tags are neutralized (yeah baby!), and
433 browser windows will be created as resizeable (as of course they
434 should be!), and will have location, scroll and menu bars -- even
435 if specified otherwise.</p>
437 <dt><span class="emphasis"><i class=
438 "EMPHASIS">content-cookies</i></span></dt>
440 <p>Most cookies are set in the HTTP dialog, where they can be
441 intercepted by the <tt class="LITERAL"><a href=
442 "actions-file.html#CRUNCH-INCOMING-COOKIES">crunch-incoming-cookies</a></tt>
443 and <tt class="LITERAL"><a href=
444 "actions-file.html#CRUNCH-OUTGOING-COOKIES">crunch-outgoing-cookies</a></tt>
445 actions. But web sites increasingly make use of HTML meta tags
446 and JavaScript to sneak cookies to the browser on the content
448 <p>This filter disables most HTML and JavaScript code that reads
449 or sets cookies. It cannot detect all clever uses of these types
450 of code, so it should not be relied on as an absolute fix. Use it
451 wherever you would also use the cookie crunch actions.</p>
453 <dt><span class="emphasis"><i class=
454 "EMPHASIS">refresh-tags</i></span></dt>
456 <p>Disable any refresh tags if the interval is greater than nine
457 seconds (so that redirections done via refresh tags are not
458 destroyed). This is useful for dial-on-demand setups, or for
459 those who find this HTML feature annoying.</p>
461 <dt><span class="emphasis"><i class=
462 "EMPHASIS">unsolicited-popups</i></span></dt>
464 <p>This filter attempts to prevent only <span class=
465 "QUOTE">"unsolicited"</span> pop-up windows from opening, yet
466 still allow pop-up windows that the user has explicitly chosen to
467 open. It was added in version 3.0.1, as an improvement over
468 earlier such filters.</p>
469 <p>Technical note: The filter works by redefining the window.open
470 JavaScript function to a dummy function, <tt class=
471 "LITERAL">PrivoxyWindowOpen()</tt>, during the loading and
472 rendering phase of each HTML page access, and restoring the
473 function afterward.</p>
474 <p>This is recommended only for browsers that cannot perform this
475 function reliably themselves. And be aware that some sites
476 require such windows in order to function normally. Use with
479 <dt><span class="emphasis"><i class=
480 "EMPHASIS">all-popups</i></span></dt>
482 <p>Attempt to prevent <span class="emphasis"><i class=
483 "EMPHASIS">all</i></span> pop-up windows from opening. Note this
484 should be used with even more discretion than the above, since it
485 is more likely to break some sites that require pop-ups for
486 normal usage. Use with caution.</p>
488 <dt><span class="emphasis"><i class=
489 "EMPHASIS">img-reorder</i></span></dt>
491 <p>This is a helper filter that has no value if used alone. It
492 makes the <tt class="LITERAL">banners-by-size</tt> and <tt class=
493 "LITERAL">banners-by-link</tt> (see below) filters more effective
494 and should be enabled together with them.</p>
496 <dt><span class="emphasis"><i class=
497 "EMPHASIS">banners-by-size</i></span></dt>
499 <p>This filter removes image tags purely based on what size they
500 are. Fortunately for us, many ads and banner images tend to
501 conform to certain standardized sizes, which makes this filter
502 quite effective for ad stripping purposes.</p>
503 <p>Occasionally this filter will cause false positives on images
504 that are not ads, but just happen to be of one of the standard
506 <p>Recommended only for those who require extreme ad blocking.
507 The default block rules should catch 95+% of all ads <span class=
508 "emphasis"><i class="EMPHASIS">without</i></span> this filter
511 <dt><span class="emphasis"><i class=
512 "EMPHASIS">banners-by-link</i></span></dt>
514 <p>This is an experimental filter that attempts to kill any
515 banners if their URLs seem to point to known or suspected click
516 trackers. It is currently not of much value and is not
517 recommended for use by default.</p>
519 <dt><span class="emphasis"><i class=
520 "EMPHASIS">webbugs</i></span></dt>
522 <p>Webbugs are small, invisible images (technically 1X1 GIF
523 images), that are used to track users across websites, and
524 collect information on them. As an HTML page is loaded by the
525 browser, an embedded image tag causes the browser to contact a
526 third-party site, disclosing the tracking information through the
527 requested URL and/or cookies for that third-party domain, without
528 the user ever becoming aware of the interaction with the
529 third-party site. HTML-ized spam also uses a similar technique to
530 verify email addresses.</p>
531 <p>This filter removes the HTML code that loads such <span class=
532 "QUOTE">"webbugs"</span>.</p>
534 <dt><span class="emphasis"><i class=
535 "EMPHASIS">tiny-textforms</i></span></dt>
537 <p>A rather special-purpose filter that can be used to enlarge
538 textareas (those multi-line text boxes in web forms) and turn off
539 hard word wrap in them. It was written for the sourceforge.net
540 tracker system where such boxes are a nuisance, but it can be
541 handy on other sites, too.</p>
542 <p>It is not recommended to use this filter as a default.</p>
544 <dt><span class="emphasis"><i class=
545 "EMPHASIS">jumping-windows</i></span></dt>
547 <p>Many consider windows that move, or resize themselves to be
548 abusive. This filter neutralizes the related JavaScript code.
549 Note that some sites might not display or behave as intended when
550 using this filter. Use with caution.</p>
552 <dt><span class="emphasis"><i class=
553 "EMPHASIS">frameset-borders</i></span></dt>
555 <p>Some web designers seem to assume that everyone in the world
556 will view their web sites using the same browser brand and
557 version, screen resolution etc, because only that assumption
558 could explain why they'd use static frame sizes, yet prevent
559 their frames from being resized by the user, should they be too
560 small to show their whole content.</p>
561 <p>This filter removes the related HTML code. It should only be
562 applied to sites which need it.</p>
564 <dt><span class="emphasis"><i class=
565 "EMPHASIS">demoronizer</i></span></dt>
567 <p>Many Microsoft products that generate HTML use non-standard
568 extensions (read: violations) of the ISO 8859-1 aka Latin-1
569 character set. This can cause those HTML documents to display
570 with errors on standard-compliant platforms.</p>
571 <p>This filter translates the MS-only characters into Latin-1
572 equivalents. It is not necessary when using MS products, and will
573 cause corruption of all documents that use 8-bit character sets
574 other than Latin-1. It's mostly worthwhile for Europeans on
575 non-MS platforms, if weird garbage characters sometimes appear on
576 some pages, or user agents that don't correct for this on the
579 <dt><span class="emphasis"><i class=
580 "EMPHASIS">shockwave-flash</i></span></dt>
582 <p>A filter for shockwave haters. As the name suggests, this
583 filter strips code out of web pages that is used to embed
584 shockwave flash objects.</p>
586 <dt><span class="emphasis"><i class=
587 "EMPHASIS">quicktime-kioskmode</i></span></dt>
589 <p>Change HTML code that embeds Quicktime objects so that
590 kioskmode, which prevents saving, is disabled.</p>
592 <dt><span class="emphasis"><i class="EMPHASIS">fun</i></span></dt>
594 <p>Text replacements for subversive browsing fun. Make fun of
595 your favorite Monopolist or play buzzword bingo.</p>
597 <dt><span class="emphasis"><i class=
598 "EMPHASIS">crude-parental</i></span></dt>
600 <p>A demonstration-only filter that shows how <span class=
601 "APPLICATION">Privoxy</span> can be used to delete web content on
604 <dt><span class="emphasis"><i class=
605 "EMPHASIS">ie-exploits</i></span></dt>
607 <p>An experimental collection of text replacements to disable
608 malicious HTML and JavaScript code that exploits known security
609 holes in Internet Explorer.</p>
610 <p>Presently, it only protects against Nimda and a cross-site
611 scripting bug, and would need active maintenance to provide more
612 substantial protection.</p>
614 <dt><span class="emphasis"><i class=
615 "EMPHASIS">site-specifics</i></span></dt>
617 <p>Some web sites have very specific problems, the cure for which
618 doesn't apply anywhere else, or could even cause damage on other
620 <p>This is a collection of such site-specific cures which should
621 only be applied to the sites they were intended for, which is
622 what the supplied <tt class="FILENAME">default.action</tt> file
623 does. Users shouldn't need to change anything regarding this
626 <dt><span class="emphasis"><i class=
627 "EMPHASIS">google</i></span></dt>
629 <p>A CSS based block for Google text ads. Also removes a width
630 limitation and the toolbar advertisement.</p>
632 <dt><span class="emphasis"><i class=
633 "EMPHASIS">yahoo</i></span></dt>
635 <p>Another CSS based block, this time for Yahoo text ads. And
636 removes a width limitation as well.</p>
638 <dt><span class="emphasis"><i class="EMPHASIS">msn</i></span></dt>
640 <p>Another CSS based block, this time for MSN text ads. And
641 removes tracking URLs, as well as a width limitation.</p>
643 <dt><span class="emphasis"><i class=
644 "EMPHASIS">blogspot</i></span></dt>
646 <p>Cleans up some Blogspot blogs. Read the fine print before
648 <p>This filter also intentionally removes some navigation stuff
649 and sets the page width to 100%. As a result, some rounded
650 <span class="QUOTE">"corners"</span> would appear to early or not
651 at all and as fixing this would require a browser that
652 understands background-size (CSS3), they are removed instead.</p>
654 <dt><span class="emphasis"><i class=
655 "EMPHASIS">xml-to-html</i></span></dt>
657 <p>Server-header filter to change the Content-Type from xml to
660 <dt><span class="emphasis"><i class=
661 "EMPHASIS">html-to-xml</i></span></dt>
663 <p>Server-header filter to change the Content-Type from html to
666 <dt><span class="emphasis"><i class=
667 "EMPHASIS">no-ping</i></span></dt>
669 <p>Removes the non-standard <tt class="LITERAL">ping</tt>
670 attribute from anchor and area HTML tags.</p>
672 <dt><span class="emphasis"><i class=
673 "EMPHASIS">hide-tor-exit-notation</i></span></dt>
675 <p>Client-header filter to remove the <b class="COMMAND">Tor</b>
676 exit node notation found in Host and Referer headers.</p>
677 <p>If <span class="APPLICATION">Privoxy</span> and <b class=
678 "COMMAND">Tor</b> are chained and <span class=
679 "APPLICATION">Privoxy</span> is configured to use socks4a, one
681 "QUOTE">"http://www.example.org.foobar.exit/"</span> to access
682 the host <span class="QUOTE">"www.example.org"</span> through the
683 <b class="COMMAND">Tor</b> exit node <span class=
684 "QUOTE">"foobar"</span>.</p>
685 <p>As the HTTP client isn't aware of this notation, it treats the
686 whole string <span class=
687 "QUOTE">"www.example.org.foobar.exit"</span> as host and uses it
688 for the <span class="QUOTE">"Host"</span> and <span class=
689 "QUOTE">"Referer"</span> headers. From the server's point of view
690 the resulting headers are invalid and can cause problems.</p>
691 <p>An invalid <span class="QUOTE">"Referer"</span> header can
692 trigger <span class="QUOTE">"hot-linking"</span> protections, an
693 invalid <span class="QUOTE">"Host"</span> header will make it
694 impossible for the server to find the right vhost (several
695 domains hosted on the same IP address).</p>
696 <p>This client-header filter removes the <span class=
697 "QUOTE">"foo.exit"</span> part in those headers to prevent the
698 mentioned problems. Note that it only modifies the HTTP headers,
699 it doesn't make it impossible for the server to detect your
700 <b class="COMMAND">Tor</b> exit node based on the IP address the
701 request is coming from.</p>
707 <h2 class="SECT2"><a name="EXTERNAL-FILTER-SYNTAX" id=
708 "EXTERNAL-FILTER-SYNTAX">9.3. External filter syntax</a></h2>
709 <p>External filters are scripts or programs that can modify the content
710 in case common <tt class="LITERAL"><a href=
711 "actions-file.html#FILTER">filters</a></tt> aren't powerful enough.</p>
712 <p>External filters can be written in any language the platform
713 <span class="APPLICATION">Privoxy</span> runs on supports.</p>
714 <p>They are controlled with the <tt class="LITERAL"><a href=
715 "actions-file.html#EXTERNAL-FILTER">external-filter</a></tt> action and
716 have to be defined in the <tt class="LITERAL"><a href=
717 "config.html#FILTERFILE">filterfile</a></tt> first.</p>
718 <p>The header looks like any other filter, but instead of pcrs jobs,
719 external filters contain a single job which can be a program or a shell
720 script (which may call other scripts or programs).</p>
721 <p>External filters read the content from STDIN and write the rewritten
722 content to STDOUT. The environment variables PRIVOXY_URL, PRIVOXY_PATH,
723 PRIVOXY_HOST, PRIVOXY_ORIGIN, PRIVOXY_LISTEN_ADDRESS can be used to get
724 some details about the client request.</p>
725 <p><span class="APPLICATION">Privoxy</span> will temporary store the
726 content to filter in the <tt class="LITERAL"><a href=
727 "config.html#TEMPORARY-DIRECTORY">temporary-directory</a></tt>.</p>
728 <table border="0" bgcolor="#E0E0E0" width="100%">
732 EXTERNAL-FILTER: cat Pointless example filter that doesn't actually modify the content
735 # Incorrect reimplementation of the filter above in POSIX shell.
737 # Note that it's a single job that spans multiple lines, the line
738 # breaks are not passed to the shell, thus the semicolons are required.
740 # If the script isn't trivial, it is recommended to put it into an external file.
742 # In general, writing external filters entirely in POSIX shell is not
743 # considered a good idea.
744 EXTERNAL-FILTER: cat2 Pointless example filter that despite its name may actually modify the content
750 EXTERNAL-FILTER: rotate-image Rotate an image by 180 degree. Test filter with limited value.
751 /usr/local/bin/convert - -rotate 180 -
753 EXTERNAL-FILTER: citation-needed Adds a "[citation needed]" tag to an image. The coordinates may need adjustment.
754 /usr/local/bin/convert - -pointsize 16 -fill white -annotate +17+418 "[citation needed]" -</pre>
758 <div class="WARNING">
759 <table class="WARNING" border="1" width="100%">
761 <td align="center"><b>Warning</b></td>
765 <p>Currently external filters are executed with <span class=
766 "APPLICATION">Privoxy</span>'s privileges! Only use external
767 filters you understand and trust.</p>
772 <p>External filters are experimental and the syntax may change in the
776 <div class="NAVFOOTER">
777 <hr align="left" width="100%">
778 <table summary="Footer navigation table" width="100%" border="0"
779 cellpadding="0" cellspacing="0">
781 <td width="33%" align="left" valign="top"><a href="actions-file.html"
782 accesskey="P">Prev</a></td>
783 <td width="34%" align="center" valign="top"><a href="index.html"
784 accesskey="H">Home</a></td>
785 <td width="33%" align="right" valign="top"><a href="templates.html"
786 accesskey="N">Next</a></td>
789 <td width="33%" align="left" valign="top">Actions Files</td>
790 <td width="34%" align="center" valign="top"> </td>
791 <td width="33%" align="right" valign="top">Privoxy's Template