68a53abf02e63b8c5f6c344d43feac65cf91de1d
[privoxy.git] / doc / source / user-manual.sgml
1 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
2 <!entity % dummy "IGNORE">
3 <!entity supported SYSTEM "supported.sgml">
4 <!entity newfeatures SYSTEM "newfeatures.sgml">
5 <!entity p-intro SYSTEM "privoxy.sgml">
6 <!entity seealso SYSTEM "seealso.sgml">
7 <!entity buildsource SYSTEM "buildsource.sgml">
8 <!entity contacting SYSTEM "contacting.sgml">
9 <!entity history SYSTEM "history.sgml">
10 <!entity copyright SYSTEM "copyright.sgml">
11 <!entity license SYSTEM "license.sgml">
12 <!entity GPLv2 SYSTEM "../../LICENSE">
13 <!entity p-authors SYSTEM "p-authors.sgml">
14 <!entity config SYSTEM "p-config.sgml">
15 <!entity changelog SYSTEM "changelog.sgml">
16 <!entity p-version "3.0.27">
17 <!entity p-status "UNRELEASED">
18 <!entity % p-authors-formal "INCLUDE"> <!-- include additional text, etc  -->
19 <!entity % p-not-stable "INCLUDE">
20 <!entity % p-stable "IGNORE">
21 <!entity % p-text "IGNORE">        <!-- define we are not a text only doc -->
22 <!entity % p-doc "INCLUDE">        <!-- and we are a formal doc           -->
23 <!entity % p-readme "IGNORE">
24 <!entity % user-man "IGNORE">
25 <!entity % config-file "IGNORE">
26 <!entity % p-supp-userman "IGNORE"> <!-- Omit some from supported.sgml    -->
27 <!entity  my-copy "&copy;">         <!-- kludge for docbook2man           -->
28 <!entity % draft "IGNORE">          <!-- WIP stuff    -->
29 <!entity % seealso-extra "INCLUDE"> <!-- extra stuff from seealso.sgml    -->
30 <!entity  my-app "<application>Privoxy</application>">
31 ]>
32 <!--
33  File        :  $Source: /cvsroot/ijbswa/current/doc/source/user-manual.sgml,v $
34
35  Purpose     :  user manual
36                 This file belongs into
37                 ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
38
39  Copyright (C) 2001-2017 Privoxy Developers https://www.privoxy.org/
40  See LICENSE.
41
42  ========================================================================
43  NOTE: Please read developer-manual/documentation.html before touching
44  anything in this, or other Privoxy documentation.
45  ========================================================================
46
47 -->
48
49 <article id="index">
50 <artheader>
51
52 <title>Privoxy &p-version; User Manual</title>
53
54 <pubdate>
55  <subscript>
56 <!-- Completely the wrong markup, but very little is allowed  -->
57 <!-- in this part of an article. FIXME -->
58  <link linkend="copyright">Copyright</link> &my-copy; 2001-2017 by
59  <ulink url="https://www.privoxy.org/">Privoxy Developers</ulink>
60  </subscript>
61 </pubdate>
62
63 <pubdate>$Id: user-manual.sgml,v 2.221 2017/05/20 09:27:54 fabiankeil Exp $</pubdate>
64
65 <!--
66
67 Note: the following should generate a separate page, and a live link to it,
68 all nicely done. But it doesn't for some mysterious reason. Please leave
69 commented unless it can be fixed proper. For the time being, the
70 copyright/license declarations will be in their own sgml.
71
72 Hal.
73
74
75 -->
76
77
78 <abstract>
79
80 <![%dummy;[
81  <para>
82  <comment>
83   This is here to keep vim syntax file from breaking :/
84   If I knew enough to fix it, I would.
85   PLEASE DO NOT REMOVE! HB: hal@foobox.net
86  </comment>
87  </para>
88 ]]>
89
90  <para>
91   The <citetitle>Privoxy User Manual</citetitle> gives users information on how to
92   install, configure and use <ulink
93   url="https://www.privoxy.org/">Privoxy</ulink>.
94  </para>
95
96 <!-- Include privoxy.sgml boilerplate: -->
97  &p-intro;
98 <!-- end privoxy.sgml -->
99
100  <para>
101   You can find the latest version of the <citetitle>Privoxy User Manual</citetitle> at  <ulink
102   url="https://www.privoxy.org/user-manual/">https://www.privoxy.org/user-manual/</ulink>.
103   Please see the <link linkend="contact">Contact section</link> on how to
104   contact the developers.
105  </para>
106
107 </abstract>
108
109 </artheader>
110
111 <!--   ~~~~~       New section      ~~~~~     -->
112 <sect1 label="1" id="introduction"><title>Introduction</title>
113 <para>
114  This documentation is included with the current &p-status; version of
115  <application>Privoxy</application>, &p-version;<![%p-not-stable;[,
116  and is mostly complete at this point. The most up to date reference for the
117  time being is still the comments in the source files and in the individual
118  configuration files. Development of a new version is currently nearing
119  completion, and includes significant changes and enhancements over
120  earlier versions]]>.
121 </para>
122
123 <!-- include only in non-stable versions -->
124 <![%p-not-stable;[
125 <para>
126  Since this is a &p-status; version, not all new features are well tested. This
127  documentation may be slightly out of sync as a result (especially with
128  CVS sources). And there <emphasis>may be</emphasis> bugs, though hopefully
129  not many!
130 </para>
131 ]]>
132
133 <!--   ~~~~~       New section      ~~~~~     -->
134 <sect2 id="features"><title>Features</title>
135 <para>
136  In addition to the core
137  features of ad blocking and
138  <ulink url="http://en.wikipedia.org/wiki/Browser_cookie">cookie</ulink> management,
139  <application>Privoxy</application> provides many supplemental
140  features<![%p-not-stable;[, some of them currently under development]]>,
141  that give the end-user more control, more privacy and more freedom:
142 </para>
143 <!-- Include newfeatures.sgml boilerplate here: -->
144  &newfeatures;
145 <!-- end boilerplate -->
146 </sect2>
147
148 </sect1>
149
150 <!--  ~  End section  ~  -->
151
152
153 <!--   ~~~~~       New section      ~~~~~     -->
154 <sect1 id="installation"><title>Installation</title>
155
156 <para>
157  <application>Privoxy</application> is available both in convenient pre-compiled
158  packages for a wide range of operating systems, and as raw source code.
159  For most users, we recommend using the packages, which can be downloaded from our
160  <ulink url="https://sourceforge.net/projects/ijbswa/">Privoxy Project
161  Page</ulink>.
162 </para>
163
164 <para>
165  Note:
166  On some platforms, the installer may remove previously installed versions, if
167  found. (See below for your platform). In any case <emphasis>be sure to backup
168  your old configuration if it is valuable to you.</emphasis> See the <link
169  linkend="upgradersnote">note to upgraders</link> section below.
170 </para>
171
172 <!--   ~~~~~       New section      ~~~~~     -->
173 <sect2 id="installation-packages"><title>Binary Packages</title>
174 <para>
175 How to install the binary packages depends on your operating system:
176 </para>
177
178 <!-- XXX: The installation sections should be sorted -->
179
180 <!--   ~~~~~       New section      ~~~~~     -->
181 <sect3 id="installation-deb"><title>Debian and Ubuntu</title>
182 <para>
183  DEBs can be installed with <literal>apt-get install privoxy</literal>,
184  and will use <filename>/etc/privoxy</filename> for the location of
185  configuration files.
186 </para>
187 </sect3>
188
189 <!--   ~~~~~       New section      ~~~~~     -->
190 <sect3 id="installation-pack-win"><title>Windows</title>
191
192 <para>
193  Just double-click the installer, which will guide you through
194  the installation process. You will find the configuration files
195  in the same directory as you installed <application>Privoxy</application> in.
196 </para>
197 <para>
198  Version 3.0.5 beta introduced full <application>Windows</application> service
199  functionality. On Windows only, the <application>Privoxy</application>
200  program has two new command line arguments to install and uninstall
201  <application>Privoxy</application> as a <emphasis>service</emphasis>.
202 </para>
203  <variablelist>
204   <varlistentry>
205    <term>Arguments:</term>
206    <listitem>
207     <para>
208      <replaceable class="parameter">--install</replaceable>[:<replaceable class="parameter">service_name</replaceable>]
209     </para>
210     <para>
211      <replaceable class="parameter">--uninstall</replaceable>[:<replaceable class="parameter">service_name</replaceable>]
212     </para>
213    </listitem>
214   </varlistentry>
215  </variablelist>
216  <para>
217  After invoking <application>Privoxy</application> with
218  <command>--install</command>, you will need to bring up the
219  <application>Windows</application> service console to assign the user you
220  want <application>Privoxy</application> to run under, and whether or not you
221  want it to run whenever the system starts. You can start the
222  <application>Windows</application> services console with the following
223  command: <command>services.msc</command>.  If you do not take the manual step
224  of modifying <application>Privoxy's</application> service settings, it will
225  not start.  Note too that you will need to give Privoxy a user account that
226  actually exists, or it will not be permitted to
227  write to its log and configuration files.
228 </para>
229
230 </sect3>
231
232 <!--   ~~~~~       New section      ~~~~~     -->
233 <sect3 id="installation-os2"><title>OS/2</title>
234
235 <para>
236  First, make sure that no previous installations of
237  <application>Junkbuster</application> and / or
238  <application>Privoxy</application> are left on your
239  system. Check that no <application>Junkbuster</application>
240  or <application>Privoxy</application> objects are in
241  your startup folder.
242 </para>
243
244 <para>
245  Then, just double-click the WarpIN self-installing archive, which will
246  guide you through the installation process. A shadow of the
247  <application>Privoxy</application> executable will be placed in your
248  startup folder so it will start automatically whenever OS/2 starts.
249 </para>
250
251 <para>
252  The directory you choose to install <application>Privoxy</application>
253  into will contain all of the configuration files.
254 </para>
255 </sect3>
256
257 <!--   ~~~~~       New section      ~~~~~     -->
258 <sect3 id="installation-mac"><title>Mac OS X</title>
259 <para>
260  Installation instructions for the OS X platform depend upon whether
261  you downloaded a ready-built installation package (.pkg or .mpkg) or have
262  downloaded the source code.
263 </para>
264 </sect3>
265 <sect3 renderas="sect4" id="OS-X-install-from-package">
266 <title>Installation from ready-built package</title>
267 <para>
268  The downloaded file will either be a .pkg (for OS X 10.5 upwards) or a bzipped
269  .mpkg file (for OS X 10.4). The former can be double-clicked as is and the
270  installation will start; double-clicking the latter will unzip the .mpkg file
271  which can then be double-clicked to commence the installation.
272 </para>
273 <para>
274  The privoxy service will automatically start after a successful installation
275  (and thereafter every time your computer starts up) however you will need to
276  configure your web browser(s) to use it. To do so, configure them to use a
277  proxy for HTTP and HTTPS at the address 127.0.0.1:8118.
278 </para>
279 <para>
280  To prevent the privoxy service from automatically starting when your computer
281  starts up, remove or rename the file <literal>/Library/LaunchDaemons/org.ijbswa.privoxy.plist</literal>
282  (on OS X 10.5 and higher) or the folder named
283  <literal>/Library/StartupItems/Privoxy</literal> (on OS X 10.4 'Tiger').
284 </para>
285 <para>
286  To manually start or stop the privoxy service, use the scripts startPrivoxy.sh
287  and stopPrivoxy.sh supplied in /Applications/Privoxy. They must be run from an
288  administrator account, using sudo.
289 </para>
290 <para>
291  To uninstall, run /Applications/Privoxy/uninstall.command as sudo from an
292  administrator account.
293 </para>
294 </sect3>
295 <sect3 renderas="sect4" id="OS-X-install-from-source">
296 <title>Installation from source</title>
297 <para>
298  To build and install the Privoxy source code on OS X you will need to obtain
299  the macsetup module from the Privoxy Sourceforge CVS repository (refer to
300  Sourceforge help for details of how to set up a CVS client to have read-only
301  access to the repository). This module contains scripts that leverage the usual
302  open-source tools (available as part of Apple's free of charge Xcode
303  distribution or via the usual open-source software package managers for OS X
304  (MacPorts, Homebrew, Fink etc.) to build and then install the privoxy binary
305  and associated files. The macsetup module's README file contains complete
306  instructions for its use.
307 </para>
308 <para>
309  The privoxy service will automatically start after a successful installation
310  (and thereafter every time your computer starts up) however you will need to
311  configure your web browser(s) to use it. To do so, configure them to use a
312  proxy for HTTP and HTTPS at the address 127.0.0.1:8118.
313 </para>
314 <para>
315  To prevent the privoxy service from automatically starting when your computer
316  starts up, remove or rename the file <literal>/Library/LaunchDaemons/org.ijbswa.privoxy.plist</literal>
317  (on OS X 10.5 and higher) or the folder named
318  <literal>/Library/StartupItems/Privoxy</literal> (on OS X 10.4 'Tiger').
319 </para>
320 <para>
321  To manually start or stop the privoxy service, use the Privoxy Utility
322  for Mac OS X (also part of the macsetup module).  This application can start
323  and stop the privoxy service and display its log and configuration files.
324 </para>
325 <para>
326  To uninstall, run the macsetup module's uninstall.sh as sudo from an
327  administrator account.
328 </para>
329 </sect3>
330
331 <!--   ~~~~~       New section      ~~~~~     -->
332 <sect3 id="installation-freebsd"><title>FreeBSD</title>
333
334 <para>
335  Privoxy is part of FreeBSD's Ports Collection, you can build and install
336  it with <literal>cd /usr/ports/www/privoxy; make install clean</literal>.
337 </para>
338 </sect3>
339
340 </sect2>
341
342 <!--   ~~~~~       New section      ~~~~~     -->
343 <sect2 id="installation-source"><title>Building from Source</title>
344
345 <para>
346  The most convenient way to obtain the <application>Privoxy</application> sources
347  is to download the source tarball from our
348  <ulink url="https://sourceforge.net/projects/ijbswa/files/Sources/">project download
349  page</ulink>.
350 </para>
351
352 <para>
353  If you like to live on the bleeding edge and are not afraid of using
354  possibly unstable development versions, you can check out the up-to-the-minute
355  version directly from <ulink url="https://sourceforge.net/p/ijbswa/code/?source=navbar">the
356  CVS repository</ulink>.
357 <!--
358  deprecated...out of business.
359  or simply download <ulink
360  url="http://cvs.sourceforge.net/cvstarballs/ijbswa-cvsroot.tar.bz2">the nightly CVS
361  tarball.</ulink>
362 -->
363 </para>
364
365 <!-- include buildsource.sgml boilerplate: -->
366 &buildsource;
367 <!-- end boilerplate -->
368
369 </sect2>
370 <!--   ~~~~~       New section      ~~~~~     -->
371 <sect2 id="installation-keepupdated"><title>Keeping your Installation Up-to-Date</title>
372
373 <para>
374  If you wish to receive an email notification whenever we release updates of
375  <application>Privoxy</application> or the actions file, <ulink
376  url="https://lists.privoxy.org/mailman/listinfo/privoxy-announce">subscribe
377  to our announce mailing list</ulink>, privoxy-announce@lists.privoxy.org.
378 </para>
379
380 <para>
381  In order not to lose your personal changes and adjustments when updating
382  to the latest <literal>default.action</literal> file we <emphasis>strongly
383  recommend</emphasis> that you use <literal>user.action</literal> and
384  <literal>user.filter</literal> for your local
385  customizations of <application>Privoxy</application>. See the <link
386  linkend="actions-file">Chapter on actions files</link> for details.
387 </para>
388
389 </sect2>
390
391
392 </sect1>
393
394 <!--  ~  End section  ~  -->
395
396 <!--   ~~~~~       New section      ~~~~~     -->
397 <sect1 id="whatsnew">
398 <title>What's New in this Release</title>
399
400 &changelog;
401
402 <!--   ~~~~~       New section      ~~~~~     -->
403
404 <sect2 id="upgradersnote">
405 <title>Note to Upgraders</title>
406
407 <para>
408  A quick list of things to be aware of before upgrading from earlier
409  versions of <application>Privoxy</application>:
410 </para>
411
412  <itemizedlist>
413
414  <listitem>
415   <para>
416    The recommended way to upgrade &my-app; is to backup your old
417    configuration files, install the new ones, verify that &my-app;
418    is working correctly and finally merge back your changes using
419    <application>diff</application> and maybe <application>patch</application>.
420   </para>
421   <para>
422    There are a number of new features in each &my-app; release and
423    most of them have to be explicitly enabled in the configuration
424    files. Old configuration files obviously don't do that and due
425    to syntax changes using old configuration files with a new
426    &my-app; isn't always possible anyway.
427   </para>
428  </listitem>
429  <listitem>
430   <para>
431     Note that some installers remove earlier versions completely,
432     including configuration files, therefore you should really save
433     any important configuration files!
434   </para>
435  </listitem>
436  <listitem>
437   <para>
438    On the other hand, other installers don't overwrite existing configuration
439    files, thinking you will want to do that yourself.
440   </para>
441  </listitem>
442  <listitem>
443   <para>
444    In the default configuration only fatal errors are logged now.
445    You can change that in the <link linkend="DEBUG">debug section</link>
446    of the configuration file. You may also want to enable more verbose
447    logging until you verified that the new &my-app; version is working
448    as expected.
449   </para>
450  </listitem>
451
452  <listitem>
453     <para>
454      Three other config file settings are now off by default:
455      <link linkend="enable-remote-toggle">enable-remote-toggle</link>,
456      <link linkend="enable-remote-http-toggle">enable-remote-http-toggle</link>,
457      and  <link linkend="enable-edit-actions">enable-edit-actions</link>.
458      If you use or want these, you will need to explicitly enable them, and
459      be aware of the security issues involved.
460     </para>
461   </listitem>
462
463 <!--
464  <listitem>
465   <para>
466    What constitutes a <quote>default</quote> configuration has changed,
467    and you may want to review which actions are <quote>on</quote> by
468    default. This is primarily a matter of emphasis, but some features
469    you may have been used to, may now be <quote>off</quote> by default.
470    There are also a number of new actions and filters you may want to
471    consider, most of which are not fully incorporated into the default
472    settings as yet (see above).
473   </para>
474  </listitem>
475 -->
476 <!--
477   <listitem>
478    <para>
479     The default actions setting is now <literal>Cautious</literal>. Previous
480     releases had a default setting of <literal>Medium</literal>. Experienced
481     users may want to adjust this, as it is fairly conservative by &my-app;
482     standards and past practices. See <ulink
483     url="http://config.privoxy.org/edit-actions-list?f=default">
484     http://config.privoxy.org/edit-actions-list?f=default</ulink>. New users
485     should try the default settings for a while before turning up the volume.
486    </para>
487   </listitem>
488
489   <listitem>
490    <para>
491     The default setting has filtering turned <emphasis>off</emphasis>, which
492     subsequently means that compression is <emphasis>on</emphasis>. Remember
493     that filtering does not work on compressed pages, so if you use, or want to
494     use, filtering, you will need to force compression off. Example:
495    </para>
496  <screen>
497   { +<link linkend="filter">filter</link>{google}  +<link linkend="prevent-compression">prevent-compression</link> }
498    .google.</screen>
499    <para>
500     Or if you use a number of filters, or filter many sites, you may just want
501     to turn off compression for all sites in
502     <filename>default.action</filename> (or
503     <filename>user.action</filename>).
504    </para>
505
506   </listitem>
507
508   <listitem>
509   <para>
510    Also, <link linkend="SESSION-COOKIES-ONLY">session-cookies-only</link> is
511    off by default now. If you've liked this feature in the past, you may want
512    to turn it back on in <filename>user.action</filename> now.
513   </para>
514   </listitem>
515
516
517   <listitem>
518   <para>
519    Some installers may not automatically start
520    <application>Privoxy</application> after installation.
521   </para>
522  </listitem>
523 -->
524
525  </itemizedlist>
526
527 </sect2>
528 </sect1>
529
530 <!--   ~~~~~       New section      ~~~~~     -->
531 <sect1 id="quickstart"><title>Quickstart to Using Privoxy</title>
532
533  <itemizedlist>
534
535  <listitem>
536   <para>
537   Install <application>Privoxy</application>. See the <link
538   linkend="installation">Installation Section</link> below for platform specific
539   information.
540  </para>
541  </listitem>
542
543  <listitem>
544   <para>
545    Advanced users and those who want to offer <application>Privoxy</application>
546    service to more than just their local machine should check the <link
547    linkend="config">main config file</link>, especially the <link
548    linkend="access-control">security-relevant</link> options. These are
549    off by default.
550   </para>
551  </listitem>
552
553  <listitem>
554   <para>
555   Start <application>Privoxy</application>, if the installation program has
556   not done this already (may vary according to platform). See the section
557   <link linkend="startup">Starting <application>Privoxy</application></link>.
558   </para>
559  </listitem>
560
561  <listitem>
562   <para>
563    Set your browser to use <application>Privoxy</application> as HTTP and
564    HTTPS (SSL)  <ulink url="http://en.wikipedia.org/wiki/Proxy_server">proxy</ulink>
565    by setting the proxy configuration for address of
566    <literal>127.0.0.1</literal> and port <literal>8118</literal>.
567    <emphasis>DO NOT</emphasis> activate proxying for <literal>FTP</literal> or
568    any protocols besides HTTP and HTTPS (SSL) unless you intend to prevent your
569    browser from using these protocols.
570   </para>
571  </listitem>
572
573  <listitem>
574   <para>
575     Flush your browser's disk and memory caches, to remove any cached ad images.
576     If using <application>Privoxy</application> to manage
577     <ulink url="http://en.wikipedia.org/wiki/Browser_cookie">cookies</ulink>,
578     you should remove any currently stored cookies too.
579   </para>
580  </listitem>
581
582  <listitem>
583   <para>
584    A default installation should provide a reasonable starting point for
585    most. There will undoubtedly be occasions where you will want to adjust the
586    configuration, but that can be dealt with as the need arises. Little
587    to no initial configuration is required in most cases, you may want
588    to enable the
589    <ulink url="config.html#ENABLE-EDIT-ACTIONS">web-based action editor</ulink> though.
590    Be sure to read the warnings first.
591   </para>
592   <para>
593    See the <link linkend="configuration">Configuration section</link> for more
594    configuration options, and how to customize your installation.
595    You might also want to look at the <link
596    linkend="quickstart-ad-blocking">next section</link> for a quick
597    introduction to how <application>Privoxy</application> blocks ads and
598    banners.
599 </para>
600  </listitem>
601
602  <listitem>
603   <para>
604     If you experience ads that slip through, innocent images that are
605     blocked, or otherwise feel the need to fine-tune
606     <application>Privoxy's</application> behavior, take a look at the <link
607     linkend="actions-file">actions files</link>. As a quick start, you might
608     find the <link linkend="act-examples">richly commented examples</link>
609     helpful. You can also view and edit the actions files through the <ulink
610     url="http://config.privoxy.org">web-based user interface</ulink>. The
611     Appendix <quote><link linkend="actionsanat">Troubleshooting: Anatomy of an
612     Action</link></quote> has hints on how to understand and debug actions that
613     <quote>misbehave</quote>.
614   </para>
615  </listitem>
616
617  <listitem>
618   <para>
619    Please see the section <link linkend="contact">Contacting the
620    Developers</link> on how to report bugs, problems with websites or to get
621    help.
622   </para>
623  </listitem>
624
625  <listitem>
626   <para>
627    Now enjoy surfing with enhanced control, comfort and privacy!
628   </para>
629  </listitem>
630
631  </itemizedlist>
632
633
634 <!--   ~~~~~       New section      ~~~~~     -->
635
636 <sect2 id="quickstart-ad-blocking">
637 <title>Quickstart to Ad Blocking</title>
638 <!--
639  NOTE:  This section is deliberately redundant for those that don't
640  want to read the whole thing (which is getting lengthy).
641 -->
642 <para>
643  Ad blocking is but one of <application>Privoxy's</application>
644  array of features. Many of these features are for the technically minded advanced
645  user. But, ad and banner blocking is surely common ground for everybody.
646 </para>
647 <para>
648  This section will provide a quick summary of ad blocking so
649  you can get up to speed quickly without having to read the more extensive
650  information provided below, though this is highly recommended.
651 </para>
652 <para>
653  First a bit of a warning ... blocking ads is much like blocking SPAM: the
654  more aggressive you are about it, the more likely you are to block
655  things that were not intended. And the more likely that some things
656  may not work as intended. So there is a trade off here. If you want
657  extreme ad free browsing, be prepared to deal with more
658  <quote>problem</quote> sites, and to spend more time adjusting the
659  configuration to solve these unintended consequences. In short, there is
660  not an easy way to eliminate <emphasis>all</emphasis> ads. Either take
661  the easy way and settle for <emphasis>most</emphasis> ads blocked with the
662  default configuration, or jump in and tweak it for your personal surfing
663  habits and preferences.
664 </para>
665 <para>
666  Secondly, a brief explanation of <application>Privoxy's </application>
667  <quote>actions</quote>. <quote>Actions</quote> in this context, are
668  the directives we use to tell <application>Privoxy</application> to perform
669  some task relating to HTTP transactions (i.e. web browsing). We tell
670  <application>Privoxy</application> to take some <quote>action</quote>. Each
671  action has a unique name and function. While there are many potential
672  <application>actions</application> in <application>Privoxy's</application>
673  arsenal, only a few are used for ad blocking. <link
674  linkend="actions">Actions</link>, and <link linkend="actions-file">action
675  configuration files</link>, are explained in depth below.
676 </para>
677 <para>
678  Actions are specified in <application>Privoxy's</application> configuration,
679  followed by one or more URLs to which the action should apply. URLs
680  can actually be URL type <link linkend="af-patterns">patterns</link> that use
681  wildcards so they can apply potentially to a range of similar URLs. The
682  actions, together with the URL patterns are called a section.
683 </para>
684 <para>
685  When you connect to a website, the full URL will either match one or more
686  of the sections as defined in <application>Privoxy's</application> configuration,
687  or not. If so, then <application>Privoxy</application> will perform the
688  respective actions. If not, then nothing special happens. Furthermore, web
689  pages may contain embedded, secondary URLs that your web browser will
690  use to load additional components of the page, as it parses the
691  original page's HTML content. An ad image for instance, is just an URL
692  embedded in the page somewhere. The image itself may be on the same server,
693  or a server somewhere else on the Internet. Complex web pages will have many
694  such embedded URLs. &my-app; can deal with each URL individually, so, for
695  instance, the main page text is not touched, but images from such-and-such
696  server are blocked.
697 </para>
698
699 <para>
700  The most important actions for basic ad blocking are:  <literal><link
701  linkend="block">block</link></literal>, <literal><link
702  linkend="handle-as-image">handle-as-image</link></literal>,
703  <literal><link
704  linkend="handle-as-empty-document">handle-as-empty-document</link></literal>,and
705  <literal><link linkend="set-image-blocker">set-image-blocker</link></literal>:
706 </para>
707
708  <itemizedlist>
709
710  <listitem>
711   <para>
712    <literal><link linkend="block">block</link></literal> - this is perhaps
713    the single most used action, and is particularly important for ad blocking.
714    This action stops any contact between your browser and any URL patterns
715    that match this action's configuration. It can be used for blocking ads,
716    but also anything that is determined to be unwanted. By itself, it simply
717    stops any communication with the remote server and sends
718    <application>Privoxy</application>'s own built-in BLOCKED page instead to
719    let you now what has happened (with some exceptions, see below).
720   </para>
721  </listitem>
722
723  <listitem>
724   <para>
725    <literal><link linkend="handle-as-image">handle-as-image</link></literal> -
726    tells <application>Privoxy</application> to treat this URL as an image.
727    <application>Privoxy</application>'s default configuration already does this
728    for all common image types (e.g. GIF), but there are many situations where this
729    is not so easy to determine. So we'll force it in these cases. This is particularly
730    important for ad blocking, since  only if we know that it's an image of
731    some kind, can we replace it with an image of our choosing, instead of the
732    <application>Privoxy</application> BLOCKED page (which would only result in
733    a <quote>broken image</quote> icon). There are some limitations to this
734    though. For instance, you can't just brute-force an image substitution for
735    an entire HTML page in most situations.
736   </para>
737  </listitem>
738
739  <listitem>
740   <para>
741    <literal><link linkend="handle-as-empty-document">handle-as-empty-document</link></literal> -
742    sends an empty document instead of <application>Privoxy's</application>
743    normal BLOCKED HTML page. This is useful for file types that are neither
744    HTML nor images, such as blocking JavaScript files.
745   </para>
746  </listitem>
747
748  <listitem>
749   <para>
750    <literal><link
751    linkend="set-image-blocker">set-image-blocker</link></literal> - tells
752    <application>Privoxy</application> what to display in place of an ad image that
753    has hit a block rule. For this to come into play, the URL must match a
754    <literal><link linkend="block">block</link></literal> action somewhere in the
755    configuration, <emphasis>and</emphasis>, it must also match an
756    <literal><link linkend="handle-as-image">handle-as-image</link></literal> action.
757   </para>
758   <para>
759    The configuration options on what to display instead of the ad are:
760   </para>
761   <simplelist>
762    <member>
763     &nbsp;&nbsp;&nbsp;<emphasis>pattern</emphasis> - a checkerboard pattern, so that an ad
764     replacement is obvious. This is the default.
765    </member>
766   </simplelist>
767   <simplelist>
768    <member>
769     &nbsp;&nbsp;&nbsp;<emphasis>blank</emphasis> - A very small empty GIF image is displayed.
770     This is the so-called <quote>invisible</quote> configuration option.
771    </member>
772   </simplelist>
773   <simplelist>
774    <member>
775     &nbsp;&nbsp;&nbsp;<emphasis>http://&lt;URL&gt;</emphasis> - A redirect to any image anywhere
776     of the user's choosing (advanced usage).
777    </member>
778   </simplelist>
779   </listitem>
780
781 </itemizedlist>
782
783 <para>
784  Advanced users will eventually want to explore &my-app;
785  <literal><link linkend="filter">filters</link></literal> as well. Filters
786  are very different from <literal><link
787  linkend="block">blocks</link></literal>.
788  A <quote>block</quote> blocks a site, page, or unwanted contented. Filters
789  are a way of filtering or modifying what is actually on the page. An example
790  filter usage: a text replacement of <quote>no-no</quote> for
791  <quote>nasty-word</quote>. That is a very simple example. This process can be
792  used for ad blocking, but it is more in the realm of advanced usage and has
793  some pitfalls to be wary off.
794 </para>
795
796 <para>
797  The quickest way to adjust any of these settings is with your browser through
798  the special <application>Privoxy</application> editor at <ulink
799  url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>
800  (shortcut: <ulink url="http://p.p/">http://p.p/show-status</ulink>). This
801  is an internal page, and does not require Internet access.
802 </para>
803
804 <para>
805  Note that as of <application>Privoxy</application> 3.0.7 beta the
806  action editor is disabled by default. Check the
807  <ulink url="config.html#ENABLE-EDIT-ACTIONS">enable-edit-actions
808   section in the configuration file</ulink> to learn why and in which
809  cases it's safe to enable again.
810 </para>
811
812 <para>
813  If you decided to enable the action editor, select the appropriate
814  <quote>actions</quote> file, and click
815  <quote><guibutton>Edit</guibutton></quote>. It is best to put personal or
816  local preferences in <filename>user.action</filename> since this is not
817  meant to be overwritten during upgrades, and will over-ride the settings in
818  other files. Here you can insert new <quote>actions</quote>, and URLs for ad
819  blocking or other purposes, and make other adjustments to the configuration.
820  <application>Privoxy</application> will detect these changes automatically.
821 </para>
822
823 <para>
824  A quick and simple step by step example:
825 </para>
826
827  <itemizedlist>
828
829   <listitem>
830    <para>
831      Right click on the ad image to be blocked, then select
832      <quote><guimenuitem>Copy Link Location</guimenuitem></quote> from the
833      pop-up menu.
834    </para>
835   </listitem>
836   <listitem>
837    <para>
838     Set your browser to
839     <ulink
840  url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>
841    </para>
842   </listitem>
843   <listitem>
844    <para>
845     Find <filename>user.action</filename> in the top section, and click
846     on <quote><guibutton>Edit</guibutton></quote>:
847    </para>
848
849  <!-- image of editor and actions files selections -->
850   <figure pgwide="0" float="0"><title>Actions Files in Use</title>
851    <mediaobject>
852      <imageobject>
853       <imagedata  fileref="files-in-use.jpg" format="jpg">
854        </imageobject>
855        <textobject>
856         <phrase>[ Screenshot of Actions Files in Use ]</phrase>
857       </textobject>
858    </mediaobject>
859   </figure>
860  </listitem>
861
862  <listitem>
863   <para>
864    You should have a section with only
865    <literal><link linkend="block">block</link></literal> listed under
866    <quote>Actions:</quote>.
867    If not, click a <quote><guibutton>Insert new section below</guibutton></quote>
868    button, and in the new section that just appeared, click the
869    <guibutton>Edit</guibutton> button right under the word <quote>Actions:</quote>.
870    This will bring up a list of all actions. Find
871    <literal><link linkend="block">block</link></literal> near the top, and click
872    in the <quote>Enabled</quote> column, then <quote><guibutton>Submit</guibutton></quote>
873    just below the list.
874   </para>
875  </listitem>
876  <listitem>
877   <para>
878    Now, in the <literal><link linkend="block">block</link></literal> actions section,
879    click the <quote><guibutton>Add</guibutton></quote> button, and paste the URL the
880    browser got from <quote><guimenuitem>Copy Link Location</guimenuitem></quote>.
881    Remove the <literal>http://</literal> at the beginning of the URL. Then, click
882    <quote><guibutton>Submit</guibutton></quote> (or
883    <quote><guibutton>OK</guibutton></quote> if in a pop-up window).
884   </para>
885  </listitem>
886  <listitem>
887   <para>
888    Now go back to the original page, and press <keycap>SHIFT-Reload</keycap>
889    (or flush all browser caches). The image should be gone now.
890   </para>
891  </listitem>
892
893  </itemizedlist>
894
895 <para>
896  This is a very crude and simple example. There might be good reasons to use a
897  wildcard pattern match to include potentially similar images from the same
898  site. For a more extensive explanation of <quote>patterns</quote>, and
899  the entire actions concept, see <link linkend="actions-file">the Actions
900  section</link>.
901 </para>
902
903 <para>
904  For advanced users who want to hand edit their config files, you might want
905  to now go to the <link linkend="act-examples">Actions Files Tutorial</link>.
906  The ideas explained therein also apply to the web-based editor.
907 </para>
908 <para>
909  There are also various
910  <link linkend="filter">filters</link> that can be used for ad blocking
911  (filters are a special subset of actions). These
912  fall into the <quote>advanced</quote> usage category, and are explained in
913  depth in later sections.
914 </para>
915
916 </sect2>
917
918 </sect1>
919
920 <!--  ~  End section  ~  -->
921
922
923 <!--   ~~~~~       New section      ~~~~~     -->
924 <sect1 id="startup">
925 <title>Starting Privoxy</title>
926 <para>
927  Before launching <application>Privoxy</application> for the first time, you
928  will want to configure your browser(s) to use
929  <application>Privoxy</application> as a HTTP and HTTPS (SSL)
930  <ulink url="http://en.wikipedia.org/wiki/Proxy_server">proxy</ulink>. The default is
931  127.0.0.1 (or localhost) for the proxy address, and port 8118 (earlier versions
932  used port 8000). This is the one configuration step <emphasis>that must be done
933 </emphasis>!
934 </para>
935 <para>
936  Please note that <application>Privoxy</application> can only proxy HTTP and
937  HTTPS traffic. It will not work with FTP or other protocols.
938 </para>
939
940  <!-- image of Mozilla Proxy configuration -->
941   <figure pgwide="0" float="0"><title>Proxy Configuration Showing
942   Mozilla/Netscape HTTP and HTTPS (SSL) Settings</title>
943    <mediaobject>
944      <imageobject>
945       <imagedata  fileref="proxy_setup.jpg" format="jpg">
946        </imageobject>
947        <textobject>
948         <phrase>[ Screenshot of Mozilla Proxy Configuration ]</phrase>
949       </textobject>
950    </mediaobject>
951   </figure>
952
953
954 <para>
955  With <application>Firefox</application>, this is typically set under:
956 </para>
957
958 <literallayout>
959  <guibutton>Tools</guibutton> -> <guibutton>Options</guibutton> ->  <guibutton>Advanced</guibutton> -> <guibutton>Network</guibutton> -><guibutton>Connection</guibutton> -> <guibutton>Settings</guibutton>
960 </literallayout>
961
962 <para>
963  Or optionally on some platforms:
964 </para>
965
966 <literallayout>
967  <guibutton>Edit</guibutton> -> <guibutton>Preferences</guibutton> -> <guibutton>General</guibutton> -> <guibutton>Connection Settings</guibutton> -> <guibutton>Manual Proxy Configuration</guibutton>
968 </literallayout>
969
970
971 <para>
972  With <application>Netscape</application> (and
973  <application>Mozilla</application>), this can be set under:
974 </para>
975
976
977 <literallayout>
978 <!-- Mix ascii and gui art, something for everybody -->
979 <!-- spacing on this is tricky -->
980  <guibutton>Edit</guibutton> -> <guibutton>Preferences</guibutton> -> <guibutton>Advanced</guibutton> -> <guibutton>Proxies</guibutton> -> <guibutton>HTTP Proxy</guibutton>
981 </literallayout>
982
983 <para>
984  For <application>Internet Explorer v.5-7</application>:
985 </para>
986
987 <literallayout>
988  <guibutton>Tools</guibutton> -> <guibutton>Internet Options</guibutton> -> <guibutton>Connections</guibutton> -> <guibutton>LAN Settings</guibutton>
989 </literallayout>
990
991 <para>
992  Then, check <quote>Use Proxy</quote> and fill in the appropriate info
993  (Address: 127.0.0.1, Port: 8118). Include HTTPS (SSL), if you want HTTPS
994  proxy support too (sometimes labeled <quote>Secure</quote>). Make sure any
995  checkboxes like <quote>Use the same proxy server for all protocols</quote> is
996  <emphasis>UNCHECKED</emphasis>. You want only HTTP and HTTPS (SSL)!
997 </para>
998
999  <!-- image of IE Proxy configuration -->
1000   <figure pgwide="0" float="0"><title>Proxy Configuration Showing
1001   Internet Explorer HTTP and HTTPS (Secure) Settings</title>
1002    <mediaobject>
1003      <imageobject>
1004       <imagedata  fileref="proxy2.jpg" format="jpg">
1005        </imageobject>
1006        <textobject>
1007         <phrase>[ Screenshot of IE Proxy Configuration ]</phrase>
1008       </textobject>
1009    </mediaobject>
1010   </figure>
1011
1012
1013 <para>
1014  After doing this, flush your browser's disk and memory caches to force a
1015  re-reading of all pages and to get rid of any ads that may be cached. Remove
1016  any <ulink url="http://en.wikipedia.org/wiki/Browser_cookie">cookies</ulink>,
1017  if you want <application>Privoxy</application> to manage that. You are now
1018  ready to start enjoying the benefits of using
1019  <application>Privoxy</application>!
1020 </para>
1021
1022 <para>
1023  <application>Privoxy</application> itself is typically started by specifying the
1024  main configuration file to be used on the command line. If no configuration
1025  file is specified on the command line, <application>Privoxy</application>
1026  will look for a file named <filename>config</filename> in the current
1027  directory. Except on Win32 where it will try <filename>config.txt</filename>.
1028 </para>
1029
1030 <sect2 id="start-debian">
1031 <title>Debian</title>
1032 <para>
1033  We use a script. Note that Debian typically starts &my-app; upon booting per
1034  default.  It will use the file
1035  <filename>/etc/privoxy/config</filename> as its main configuration
1036  file.
1037 </para>
1038  <screen>
1039  # /etc/init.d/privoxy start
1040 </screen>
1041 </sect2>
1042
1043 <sect2 id="start-freebsd">
1044 <title>FreeBSD and ElectroBSD</title>
1045 <para>
1046  To start <application>Privoxy</application> upon booting, add
1047  "privoxy_enable='YES'" to <filename>/etc/rc.conf</filename>.
1048  <application>Privoxy</application> will use
1049  <filename>/usr/local/etc/privoxy/config</filename> as its main
1050  configuration file.
1051 </para>
1052 <para>
1053  If you installed <application>Privoxy</application> into a jail, the
1054  paths above are relative to the jail root.
1055 </para>
1056 <para>
1057  To start <application>Privoxy</application> manually, run:
1058 </para>
1059  <screen>
1060  # service privoxy onestart
1061 </screen>
1062 </sect2>
1063
1064 <sect2 id="start-windows">
1065 <title>Windows</title>
1066 <para>
1067 Click on the &my-app; Icon to start <application>Privoxy</application>. If no configuration file is
1068  specified on the command line, <application>Privoxy</application> will look
1069  for a file named <filename>config.txt</filename>. Note that Windows will
1070  automatically start &my-app; when the system starts if you chose that option
1071  when installing.
1072 </para>
1073 <para>
1074  <application>Privoxy</application> can run with full Windows service functionality.
1075  On Windows only, the &my-app; program has two new command line arguments
1076  to install and uninstall &my-app; as a service. See the
1077  <link linkend="installation-pack-win">Windows Installation
1078  instructions</link> for details.
1079 </para>
1080 </sect2>
1081
1082 <sect2 id="start-unices">
1083 <title>Generic instructions for Unix derivates (Solaris, NetBSD, HP-UX etc.)</title>
1084 <para>
1085 Example Unix startup command:
1086 </para>
1087  <screen>
1088  # /usr/sbin/privoxy --user privoxy /etc/privoxy/config
1089 </screen>
1090 <para>
1091  Note that if you installed <application>Privoxy</application> through
1092  a package manager, the package will probably contain a platform-specific
1093  script or configuration file to start <application>Privoxy</application>
1094  upon boot.
1095 </para>
1096 </sect2>
1097
1098 <sect2 id="start-os2">
1099 <title>OS/2</title>
1100 <para>
1101  During installation, <application>Privoxy</application> is configured to
1102  start automatically when the system restarts. You can start it manually by
1103  double-clicking on the <application>Privoxy</application> icon in the
1104  <application>Privoxy</application> folder.
1105 </para>
1106 </sect2>
1107
1108 <sect2 id="start-macosx">
1109 <title>Mac OS X</title>
1110 <para>
1111  The privoxy service will automatically start after a successful installation
1112  (and thereafter every time your computer starts up) however you will need to
1113  configure your web browser(s) to use it. To do so, configure them to use a
1114  proxy for HTTP and HTTPS at the address 127.0.0.1:8118.
1115 </para>
1116 <para>
1117  To prevent the privoxy service from automatically starting when your computer
1118  starts up, remove or rename the file <literal>/Library/LaunchDaemons/org.ijbswa.privoxy.plist</literal>
1119  (on OS X 10.5 and higher) or the folder named
1120  <literal>/Library/StartupItems/Privoxy</literal> (on OS X 10.4 'Tiger').
1121 </para>
1122 <para>
1123  To manually start or stop the privoxy service, use the scripts startPrivoxy.sh
1124  and stopPrivoxy.sh supplied in /Applications/Privoxy. They must be run from an
1125  administrator account, using sudo.
1126 </para>
1127 </sect2>
1128
1129
1130 <!--
1131
1132 <para>
1133  See the section <link linkend="cmdoptions">Command line options</link> for
1134  further info.
1135 </para>
1136
1137 must find a better place for this paragraph
1138
1139 <para>
1140  The included default configuration files should give a reasonable starting
1141  point. Most of the per site configuration is done in the
1142  <ulink url="actions-file.html"><quote>actions</quote></ulink> files. These are
1143  where various cookie actions are defined, ad and banner blocking, and other
1144  aspects of <application>Privoxy</application> configuration. There are several
1145  such files included, with varying levels of aggressiveness.
1146 </para>
1147
1148 <para>
1149  You will probably want to keep an eye out for sites for which you may prefer
1150  persistent cookies, and add these to your actions configuration as needed. By
1151  default, most of these will be accepted only during the current browser
1152  session (aka <quote>session cookies</quote>), unless you add them to the
1153  configuration. If you want the browser to handle this instead, you will need
1154  to edit <filename>user.action</filename> (or through the web based interface)
1155  and disable this feature. If you use more than one browser, it would make
1156  more sense to let <application>Privoxy</application> handle this. In which
1157  case, the browser(s) should be set to accept all cookies.
1158 </para>
1159
1160 <para>
1161  Another feature where you will probably want to define exceptions for trusted
1162  sites is the popup-killing (through  <ulink
1163  url="actions-file.html#FILTER-POPUPS"><quote>+filter{popups}</quote></ulink>),
1164  because your favorite shopping, banking, or leisure site may need
1165  popups (explained below).
1166 </para>
1167
1168 <para>
1169  <application>Privoxy</application> does not support all of the optional HTTP/1.1
1170  features yet. In the unlikely event that you experience inexplicable problems
1171  with browsers that use HTTP/1.1 per default
1172  (like <application>Mozilla</application> or recent versions of I.E.), you might
1173  try to force HTTP/1.0 compatibility. For Mozilla, look under <literal>Edit -&gt;
1174  Preferences -&gt; Debug -&gt; Networking</literal>.
1175  Alternatively, set the <quote>+downgrade-http-version</quote> config option in
1176  <filename>default.action</filename> which will downgrade your browser's HTTP
1177  requests from HTTP/1.1 to HTTP/1.0 before processing them.
1178 </para>
1179
1180 <para>
1181  After running <application>Privoxy</application> for a while, you can
1182  start to fine tune the configuration to suit your personal, or site,
1183  preferences and requirements. There are many, many aspects that can
1184  be customized. <quote>Actions</quote>
1185  can be adjusted by pointing your browser to
1186  <ulink url="http://config.privoxy.org/">http://config.privoxy.org/</ulink>
1187  (shortcut: <ulink url="http://p.p/">http://p.p/</ulink>),
1188  and then follow the link to <quote>View &#38; Change the Current Configuration</quote>.
1189  (This is an internal page and does not require Internet access.)
1190 </para>
1191
1192 <para>
1193  In fact, various aspects of <application>Privoxy</application>
1194  configuration can be viewed from this page, including
1195  current configuration parameters, source code version numbers,
1196  the browser's request headers, and <quote>actions</quote> that apply
1197  to a given URL. In addition to the actions file
1198  editor mentioned above, <application>Privoxy</application> can also
1199  be turned <quote>on</quote> and <quote>off</quote> (toggled) from this page.
1200 </para>
1201
1202 <para>
1203  If you encounter problems, try loading the page without
1204  <application>Privoxy</application>. If that helps, enter the URL where
1205  you have the problems into <ulink url="http://p.p/show-url-info">the browser
1206  based rule tracing utility</ulink>. See which rules apply and why, and
1207  then try turning them off for that site one after the other, until the problem
1208  is gone. When you have found the culprit, you might want to turn the rest on
1209  again.
1210 </para>
1211
1212 <para>
1213  If the above paragraph sounds gibberish to you, you might want to <link
1214  linkend="actions-file">read more about the actions concept</link>
1215  or even dive deep into the <link linkend="actionsanat">Appendix
1216  on actions</link>.
1217 </para>
1218
1219 <para>
1220  If you can't get rid of the problem at all, think you've found a bug in
1221  Privoxy, want to propose a new feature or smarter rules, please see the
1222  section <link linkend="contact"><quote>Contacting the
1223  Developers</quote></link> below.
1224 </para>
1225
1226 -->
1227
1228 <!--   ~~~~~       New section      ~~~~~     -->
1229 <sect2 id="cmdoptions">
1230 <title>Command Line Options</title>
1231 <para>
1232  <application>Privoxy</application> may be invoked with the following
1233  command-line options:
1234 </para>
1235
1236  <itemizedlist>
1237
1238  <listitem>
1239   <para>
1240    <emphasis>--config-test</emphasis>
1241   </para>
1242   <para>
1243    Exit after loading the configuration files before binding to
1244    the listen address. The exit code signals whether or not the
1245    configuration files have been successfully loaded.
1246   </para>
1247   <para>
1248    If the exit code is 1, at least one of the configuration files
1249    is invalid, if it is 0, all the configuration files have been
1250    successfully loaded (but may still contain errors that can
1251    currently only be detected at run time).
1252   </para>
1253   <para>
1254    This option doesn't affect the log setting, combination with
1255    <emphasis>--no-daemon</emphasis> is recommended if a configured
1256    log file shouldn't be used.
1257   </para>
1258  </listitem>
1259  <listitem>
1260   <para>
1261     <emphasis>--version</emphasis>
1262   </para>
1263   <para>
1264      Print version info and exit. Unix only.
1265   </para>
1266  </listitem>
1267  <listitem>
1268   <para>
1269     <emphasis>--help</emphasis>
1270   </para>
1271   <para>
1272    Print short usage info and exit. Unix only.
1273   </para>
1274  </listitem>
1275  <listitem>
1276   <para>
1277    <emphasis>--no-daemon</emphasis>
1278   </para>
1279   <para>
1280    Don't become a daemon, i.e. don't fork and become process group
1281    leader, and don't detach from controlling tty. Unix only.
1282   </para>
1283  </listitem>
1284  <listitem>
1285   <para>
1286    <emphasis>--pidfile FILE</emphasis>
1287   </para>
1288   <para>
1289    On startup, write the process ID to <emphasis>FILE</emphasis>. Delete the
1290    <emphasis>FILE</emphasis> on exit. Failure to create or delete the
1291    <emphasis>FILE</emphasis> is non-fatal. If no <emphasis>FILE</emphasis>
1292    option is given, no PID file will be used. Unix only.
1293   </para>
1294  </listitem>
1295  <listitem>
1296   <para>
1297    <emphasis>--user USER[.GROUP]</emphasis>
1298   </para>
1299   <para>
1300    After (optionally) writing the PID file, assume the user  ID  of
1301    <emphasis>USER</emphasis>, and if included the GID of GROUP.  Exit if the
1302    privileges are not sufficient to do so. Unix only.
1303   </para>
1304  </listitem>
1305  <listitem>
1306   <para>
1307    <emphasis>--chroot</emphasis>
1308   </para>
1309   <para>
1310    Before changing to the user ID given in the <emphasis>--user</emphasis> option,
1311    chroot to that user's home directory, i.e. make the kernel pretend to the &my-app;
1312    process that the directory tree starts there. If set up carefully, this can limit
1313    the impact of possible vulnerabilities in &my-app; to the files contained in that hierarchy.
1314    Unix only.
1315   </para>
1316  </listitem>
1317  <listitem>
1318   <para>
1319    <emphasis>--pre-chroot-nslookup hostname</emphasis>
1320   </para>
1321   <para>
1322    Specifies a hostname (for example www.privoxy.org) to look up before doing a chroot.
1323    On some systems, initializing the resolver library involves reading config files from
1324    /etc and/or loading additional shared libraries from /lib.
1325    On these systems, doing a hostname lookup before the chroot reduces
1326    the number of files that must be copied into the chroot tree.
1327   </para>
1328   <para>
1329    For fastest startup speed, a good value is a hostname that is not in /etc/hosts but that
1330    your local name server (listed in /etc/resolv.conf) can resolve without recursion
1331    (that is, without having to ask any other name servers). The hostname need not exist,
1332    but if it doesn't, an error message (which can be ignored) will be output.
1333   </para>
1334  </listitem>
1335
1336  <listitem>
1337   <para>
1338     <emphasis>configfile</emphasis>
1339   </para>
1340   <para>
1341     If no <emphasis>configfile</emphasis> is included on the command line,
1342     <application>Privoxy</application> will look for a file named
1343     <quote>config</quote> in the current directory (except on Win32
1344     where it will look for <quote>config.txt</quote> instead). Specify
1345     full path to avoid confusion. If no config file is found,
1346     <application>Privoxy</application> will fail to start.
1347   </para>
1348  </listitem>
1349
1350  </itemizedlist>
1351
1352 <para>
1353  On <application>MS Windows</application> only there are two additional
1354  command-line options to allow <application>Privoxy</application> to install and
1355  run as a <emphasis>service</emphasis>. See the
1356 <link linkend="installation-pack-win">Window Installation section</link>
1357 for details.
1358 </para>
1359
1360 </sect2>
1361
1362 </sect1>
1363
1364 <!--  ~  End section  ~  -->
1365
1366
1367 <!--   ~~~~~       New section      ~~~~~     -->
1368 <sect1 id="configuration"><title>Privoxy Configuration</title>
1369  <para>
1370   All <application>Privoxy</application> configuration is stored
1371   in text files. These files can be edited with a text editor.
1372   Many important aspects of <application>Privoxy</application> can
1373   also be controlled easily with a web browser.
1374  </para>
1375
1376
1377 <!--   ~~~~~       New section      ~~~~~     -->
1378
1379 <sect2 id="control-with-webbrowser">
1380 <title>Controlling Privoxy with Your Web Browser</title>
1381 <para>
1382  <application>Privoxy</application>'s user interface can be reached through the special
1383  URL <ulink url="http://config.privoxy.org/">http://config.privoxy.org/</ulink>
1384  (shortcut: <ulink url="http://p.p/">http://p.p/</ulink>),
1385  which is a built-in page and works without Internet access.
1386  You will see the following section:
1387 </para>
1388
1389 <!-- Needs to be put in a table and colorized  -->
1390 <screen>
1391  <msgtext>
1392  <bridgehead renderas="sect2">&nbsp;&nbsp;&nbsp;&nbsp;Privoxy Menu</bridgehead>
1393
1394  <simplelist>
1395  <member>
1396   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink url="http://config.privoxy.org/show-status">View & change the current configuration</ulink>
1397  </member>
1398  <member>
1399   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink url="http://config.privoxy.org/show-version">View the source code version numbers</ulink>
1400  </member>
1401  <member>
1402   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink url="http://config.privoxy.org/show-request">View the request headers.</ulink>
1403  </member>
1404  <member>
1405   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink url="http://config.privoxy.org/show-url-info">Look up which actions apply to a URL and why</ulink>
1406  </member>
1407  <member>
1408   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink url="http://config.privoxy.org/toggle">Toggle Privoxy on or off</ulink>
1409  </member>
1410  <member>
1411   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&squf;&nbsp;&nbsp;<ulink
1412   url="https://www.privoxy.org/&p-version;/user-manual/">Documentation</ulink>
1413  </member>
1414  </simplelist>
1415  </msgtext>
1416 </screen>
1417
1418
1419 <para>
1420  This should be self-explanatory. Note the first item leads to an editor for the
1421  <link linkend="actions-file">actions files</link>, which is where the ad, banner,
1422  cookie, and URL blocking magic is configured as well as other advanced features of
1423  <application>Privoxy</application>. This is an easy way to adjust various
1424  aspects of <application>Privoxy</application> configuration. The actions
1425  file, and other configuration files, are explained in detail below.
1426 </para>
1427
1428 <para>
1429  <quote>Toggle Privoxy On or Off</quote> is handy for sites that might
1430  have problems with your current actions and filters. You can in fact use
1431  it as a test to see whether it is <application>Privoxy</application>
1432  causing the problem or not. <application>Privoxy</application> continues
1433  to run as a proxy in this case, but all manipulation is disabled, i.e.
1434  <application>Privoxy</application> acts like a normal forwarding proxy.
1435 </para>
1436
1437 <para>
1438  Note that several of the features described above are disabled by default
1439  in <application>Privoxy</application> 3.0.7 beta and later.
1440  Check the
1441  <ulink url="config.html">configuration file</ulink> to learn why
1442  and in which cases it's safe to enable them again.
1443 </para>
1444
1445 </sect2>
1446
1447 <!--  ~  End section  ~  -->
1448
1449
1450
1451
1452 <!--   ~~~~~       New section      ~~~~~     -->
1453
1454 <sect2 id="confoverview">
1455 <title>Configuration Files Overview</title>
1456 <para>
1457  For Unix, *BSD and Linux, all configuration files are located in
1458  <filename>/etc/privoxy/</filename> by default. For MS Windows, OS/2, and
1459  AmigaOS these are all in the same directory as the
1460  <application>Privoxy</application> executable. <![%p-not-stable;[ The name
1461  and number of configuration files has changed from previous versions, and is
1462  subject to change as development progresses.]]>
1463 </para>
1464
1465 <para>
1466  The installed defaults provide a reasonable starting point, though
1467  some settings may be aggressive by some standards. For the time being, the
1468  principle configuration files are:
1469 </para>
1470
1471  <itemizedlist>
1472
1473   <listitem>
1474    <para>
1475      The <link linkend="config">main configuration file</link> is named <filename>config</filename>
1476      on Linux, Unix, BSD, OS/2, and AmigaOS and <filename>config.txt</filename>
1477      on Windows. This is a required file.
1478    </para>
1479   </listitem>
1480
1481   <listitem>
1482    <para>
1483     <filename>match-all.action</filename> is used to define which <quote>actions</quote>
1484     relating to banner-blocking, images, pop-ups, content modification, cookie handling
1485     etc should be applied by default. It should be the first actions file loaded.
1486    </para>
1487    <para>
1488     <filename>default.action</filename> defines many exceptions (both positive and negative)
1489     from the default set of actions that's configured in <filename>match-all.action</filename>.
1490     It should be the second actions file loaded and shouldn't be edited by the user.
1491    </para>
1492    <para>
1493     Multiple actions files may be defined in <filename>config</filename>. These
1494     are processed in the order they are defined. Local customizations and locally
1495     preferred exceptions to the default policies as defined in
1496     <filename>match-all.action</filename> (which you will most probably want
1497     to define sooner or later) are best applied in <filename>user.action</filename>,
1498     where you can preserve them across upgrades. The file isn't installed by all
1499     installers, but you can easily create it yourself with a text editor.
1500    </para>
1501    <para>
1502     There is also a web based editor that can be accessed from
1503     <ulink
1504     url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>
1505     (Shortcut: <ulink
1506     url="http://p.p/show-status">http://p.p/show-status</ulink>) for the
1507     various actions files.
1508    </para>
1509   </listitem>
1510
1511   <listitem>
1512    <para>
1513     <quote>Filter files</quote> (the <link linkend="filter-file">filter
1514     file</link>) can be used to re-write the raw page content, including
1515     viewable text as well as embedded HTML and JavaScript, and whatever else
1516     lurks on any given web page. The filtering jobs are only pre-defined here;
1517     whether to apply them or not is up to the actions files.
1518     <filename>default.filter</filename> includes various filters made
1519     available for use by the developers. Some are much more intrusive than
1520     others, and all should be used with caution. You may define additional
1521     filter files in <filename>config</filename> as you can with
1522     actions files. We suggest <filename>user.filter</filename> for any
1523     locally defined filters or customizations.
1524    </para>
1525   </listitem>
1526
1527  </itemizedlist>
1528
1529 <para>
1530  The syntax of the configuration and filter files may change between different
1531  Privoxy versions, unfortunately some enhancements cost backwards compatibility.
1532  <!-- Add link to documentation-->
1533 </para>
1534
1535 <para>
1536  All files use the <quote><literal>#</literal></quote> character to denote a
1537  comment (the rest of the line will be ignored) and understand line continuation
1538  through placing a backslash ("<literal>\</literal>") as the very last character
1539  in a line. If the <literal>#</literal> is preceded by a backslash, it looses
1540  its special function. Placing a <literal>#</literal> in front of an otherwise
1541  valid configuration line to prevent it from being interpreted is called "commenting
1542  out" that line. Blank lines are ignored.
1543 </para>
1544
1545 <para>
1546  The actions files and filter files
1547  can use Perl style <link linkend="regex">regular expressions</link> for
1548  maximum flexibility.
1549 </para>
1550
1551 <para>
1552  After making any changes, there is no need to restart
1553  <application>Privoxy</application> in order for the changes to take
1554  effect. <application>Privoxy</application> detects such changes
1555  automatically. Note, however, that it may take one or two additional
1556  requests for the change to take effect. When changing the listening address
1557  of <application>Privoxy</application>, these <quote>wake up</quote> requests
1558  must obviously be sent to the <emphasis>old</emphasis> listening address.
1559 </para>
1560
1561 <![%p-not-stable;[
1562 <para>
1563  While under development, the configuration content is subject to change.
1564  The below documentation may not be accurate by the time you read this.
1565  Also, what constitutes a <quote>default</quote> setting, may change, so
1566  please check all your configuration files on important issues.
1567 </para>
1568 ]]>
1569
1570 </sect2>
1571 </sect1>
1572 <!--  ~  End section  ~  -->
1573
1574
1575 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
1576
1577 <!-- **************************************************** -->
1578 <!-- Include config.sgml here -->
1579 <!-- This is where the entire config file is detailed. -->
1580  &config;
1581 <!-- end include  -->
1582
1583
1584 <!--  ~  End section  ~  -->
1585
1586
1587
1588 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
1589
1590 <sect1 id="actions-file"><title>Actions Files</title>
1591
1592
1593 <!--
1594   XXX: similar descriptions are in the Configuration Files sections.
1595   We should only describe them at one place.
1596 -->
1597 <para>
1598  The actions files are used to define what <emphasis>actions</emphasis>
1599  <application>Privoxy</application> takes for which URLs, and thus determines
1600  how ad images, cookies and various other aspects of HTTP content and
1601  transactions are handled, and on which sites (or even parts thereof).
1602  There are a number of such actions, with a wide range of functionality.
1603  Each action does something a little different.
1604  These actions give us a veritable arsenal of tools with which to exert
1605  our control, preferences and independence. Actions can be combined so that
1606  their effects are aggregated when applied against a given set of URLs.
1607 </para>
1608 <para>
1609  There
1610  are three action files included with <application>Privoxy</application> with
1611  differing purposes:
1612 </para>
1613  <itemizedlist>
1614   <listitem>
1615    <para>
1616     <filename>match-all.action</filename> - is used to define which
1617     <quote>actions</quote> relating to banner-blocking, images, pop-ups,
1618     content modification, cookie handling etc should be applied by default.
1619     It should be the first actions file loaded
1620    </para>
1621   </listitem>
1622   <listitem>
1623    <para>
1624     <filename>default.action</filename> - defines many exceptions (both
1625     positive and negative) from the default set of actions that's configured
1626     in <filename>match-all.action</filename>. It is a set of rules that should
1627     work reasonably well as-is for most users. This file is only supposed to
1628     be edited by the developers. It should be the second actions file loaded.
1629    </para>
1630   </listitem>
1631   <listitem>
1632    <para>
1633     <filename>user.action</filename> - is intended to be for local site
1634     preferences and exceptions. As an example, if your ISP or your bank
1635     has specific requirements, and need special handling, this kind of
1636     thing should go here. This file will not be upgraded.
1637    </para>
1638   </listitem>
1639   <listitem>
1640    <para>
1641     <guibutton>Edit</guibutton>  <guibutton>Set to Cautious</guibutton> <guibutton>Set to Medium</guibutton>  <guibutton>Set to Advanced</guibutton>
1642    </para>
1643    <para>
1644     These have increasing levels of aggressiveness <emphasis>and have no
1645     influence on your browsing unless you select them explicitly in the
1646     editor</emphasis>. A default installation should be pre-set to
1647     <literal>Cautious</literal>. New users should try this for a while before
1648     adjusting the settings to more aggressive levels. The more aggressive
1649     the settings, then the more likelihood there is of problems such as sites
1650     not working as they should.
1651    </para>
1652    <para>
1653     The <guibutton>Edit</guibutton> button allows you to turn each
1654     action on/off individually for fine-tuning. The <guibutton>Cautious</guibutton>
1655     button changes the actions list to low/safe settings which will activate
1656     ad blocking and a minimal set of &my-app;'s features, and subsequently
1657     there will be less of a chance for accidental problems. The
1658     <guibutton>Medium</guibutton> button sets the list to a medium level of
1659     other features and a low level set of privacy features. The
1660     <guibutton>Advanced</guibutton> button sets the list to a high level of
1661     ad blocking and medium level of privacy. See the chart below. The latter
1662     three buttons over-ride any changes via with the
1663     <guibutton>Edit</guibutton> button. More fine-tuning can be done in the
1664     lower sections of this internal page.
1665    </para>
1666    <para>
1667     While the actions file editor allows to enable these settings in all
1668     actions files, they are only supposed to be enabled in the first one
1669     to make sure you don't unintentionally overrule earlier rules.
1670    </para>
1671    <para>
1672     The default profiles, and their associated actions, as pre-defined in
1673     <filename>default.action</filename> are:
1674    </para>
1675     <table frame=all><title>Default Configurations</title>
1676     <tgroup cols=4 align=left colsep=1 rowsep=1>
1677     <colspec colname=c1>
1678     <colspec colname=c2>
1679     <colspec colname=c3>
1680     <colspec colname=c4>
1681     <thead>
1682     <row>
1683       <entry>Feature</entry>
1684       <entry>Cautious</entry>
1685       <entry>Medium</entry>
1686       <entry>Advanced</entry>
1687     </row>
1688     </thead>
1689     <!--  <tfoot> -->
1690     <!--  <row> -->
1691     <!--    <entry>f1</entry> -->
1692     <!--    <entry>f2</entry> -->
1693     <!--    <entry>f3</entry> -->
1694     <!--    <entry>f4</entry> -->
1695     <!--  </row> -->
1696     <!--  </tfoot> -->
1697     <tbody>
1698
1699     <row>
1700       <entry>Ad-blocking Aggressiveness</entry>
1701       <entry>medium</entry>
1702       <entry>high</entry>
1703       <entry>high</entry>
1704     </row>
1705
1706     <row>
1707       <entry>Ad-filtering by size</entry>
1708       <entry>no</entry>
1709       <entry>yes</entry>
1710       <entry>yes</entry>
1711     </row>
1712
1713     <row>
1714       <entry>Ad-filtering by link</entry>
1715       <entry>no</entry>
1716       <entry>no</entry>
1717       <entry>yes</entry>
1718     </row>
1719     <row>
1720       <entry>Pop-up killing</entry>
1721       <entry>blocks only</entry>
1722       <entry>blocks only</entry>
1723       <entry>blocks only</entry>
1724     </row>
1725
1726     <row>
1727       <entry>Privacy Features</entry>
1728       <entry>low</entry>
1729       <entry>medium</entry>
1730       <entry>medium/high</entry>
1731     </row>
1732
1733     <row>
1734       <entry>Cookie handling</entry>
1735       <entry>none</entry>
1736       <entry>session-only</entry>
1737       <entry>kill</entry>
1738     </row>
1739
1740     <row>
1741       <entry>Referer forging</entry>
1742       <entry>no</entry>
1743       <entry>yes</entry>
1744       <entry>yes</entry>
1745     </row>
1746
1747     <row>
1748       <entry>GIF de-animation</entry>
1749       <entry>no</entry>
1750       <entry>yes</entry>
1751       <entry>yes</entry>
1752     </row>
1753
1754     <row>
1755       <entry>Fast redirects</entry>
1756       <entry>no</entry>
1757       <entry>no</entry>
1758       <entry>yes</entry>
1759     </row>
1760
1761     <row>
1762       <entry>HTML taming</entry>
1763       <entry>no</entry>
1764       <entry>no</entry>
1765       <entry>yes</entry>
1766     </row>
1767
1768     <row>
1769       <entry>JavaScript taming</entry>
1770       <entry>no</entry>
1771       <entry>no</entry>
1772       <entry>yes</entry>
1773     </row>
1774
1775     <row>
1776       <entry>Web-bug killing</entry>
1777       <entry>no</entry>
1778       <entry>yes</entry>
1779       <entry>yes</entry>
1780     </row>
1781
1782     <row>
1783       <entry>Image tag reordering</entry>
1784       <entry>no</entry>
1785       <entry>yes</entry>
1786       <entry>yes</entry>
1787     </row>
1788
1789     </tbody>
1790     </tgroup>
1791     </table>
1792
1793   </listitem>
1794  </itemizedlist>
1795
1796 <para>
1797  The list of actions files to be used are defined in the main configuration
1798  file, and are processed in the order they are defined (e.g.
1799  <filename>default.action</filename> is typically processed before
1800  <filename>user.action</filename>). The content of these can all be viewed and
1801  edited from <ulink
1802  url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>.
1803  The over-riding principle when applying actions, is that the last action that
1804  matches a given URL wins. The broadest, most general rules go first
1805  (defined in <filename>default.action</filename>),
1806  followed by any exceptions (typically also in
1807  <filename>default.action</filename>), which are then followed lastly by any
1808  local preferences (typically in <emphasis>user</emphasis><filename>.action</filename>).
1809  Generally, <filename>user.action</filename> has the last word.
1810  </para>
1811
1812 <para>
1813  An actions file typically has multiple sections. If you want to use
1814  <quote>aliases</quote> in an actions file, you have to place the (optional)
1815  <link linkend="aliases">alias section</link> at the top of that file.
1816  Then comes the default set of rules which will apply universally to all
1817  sites and pages (be <emphasis>very careful</emphasis> with using such a
1818  universal set in <filename>user.action</filename> or any other actions file after
1819  <filename>default.action</filename>, because it will override the result
1820  from consulting any previous file). And then below that,
1821  exceptions to the defined universal policies. You can regard
1822  <filename>user.action</filename> as an appendix to <filename>default.action</filename>,
1823  with the advantage that it is a separate file, which makes preserving your
1824  personal settings across <application>Privoxy</application> upgrades easier.
1825 </para>
1826
1827 <para>
1828  Actions can be used to block anything you want, including ads, banners, or
1829  just some obnoxious URL whose content you would rather not see. Cookies can be accepted
1830  or rejected, or accepted only during the current browser session (i.e. not
1831  written to disk), content can be modified, some JavaScripts tamed, user-tracking
1832  fooled, and much more. See below for a <link linkend="actions">complete list
1833  of actions</link>.
1834 </para>
1835
1836 <!--   ~~~~~       New section      ~~~~~     -->
1837 <sect2 id="right-mix">
1838 <title>Finding the Right Mix</title>
1839 <para>
1840  Note that some <link linkend="actions">actions</link>, like cookie suppression
1841  or script disabling, may render some sites unusable that rely on these
1842  techniques to work properly. Finding the right mix of actions is not always easy and
1843  certainly a matter of personal taste. And, things can always change, requiring
1844  refinements in the configuration. In general, it can be said that the more
1845  <quote>aggressive</quote> your default settings (in the top section of the
1846  actions file) are, the more exceptions for <quote>trusted</quote> sites you
1847  will have to make later. If, for example, you want to crunch all cookies per
1848  default, you'll have to make exceptions from that rule for sites that you
1849  regularly use and that require cookies for actually useful purposes, like maybe
1850  your bank, favorite shop, or newspaper.
1851 </para>
1852
1853 <para>
1854  We have tried to provide you with reasonable rules to start from in the
1855  distribution actions files. But there is no general rule of thumb on these
1856  things. There just are too many variables, and sites are constantly changing.
1857  Sooner or later you will want to change the rules (and read this chapter again :).
1858 </para>
1859 </sect2>
1860
1861 <!--   ~~~~~       New section      ~~~~~     -->
1862 <sect2 id="how-to-edit">
1863 <title>How to Edit</title>
1864 <para>
1865  The easiest way to edit the actions files is with a browser by
1866  using our browser-based editor, which can be reached from <ulink
1867  url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>.
1868  Note: the config file option <link
1869  linkend="enable-edit-actions">enable-edit-actions</link> must be enabled for
1870  this to work. The editor allows both fine-grained control over every single
1871  feature on a per-URL basis, and easy choosing from wholesale sets of defaults
1872  like <quote>Cautious</quote>, <quote>Medium</quote> or
1873  <quote>Advanced</quote>. Warning: the <quote>Advanced</quote> setting is more
1874  aggressive, and will be more likely to cause problems for some sites.
1875  Experienced users only!
1876  </para>
1877
1878 <para>
1879  If you prefer plain text editing to GUIs, you can of course also directly edit the
1880  the actions files with your favorite text editor. Look at
1881  <filename>default.action</filename> which is richly commented with many
1882  good examples.
1883 </para>
1884 </sect2>
1885
1886
1887 <sect2 id="actions-apply">
1888 <title>How Actions are Applied to Requests</title>
1889 <para>
1890  Actions files are divided into sections. There are special sections,
1891  like the <quote><link linkend="aliases">alias</link></quote> sections which will
1892  be discussed later. For now let's concentrate on regular sections: They have a
1893  heading line (often split up to multiple lines for readability) which consist
1894  of a list of actions, separated by whitespace and enclosed in curly braces.
1895  Below that, there is a list of URL and tag patterns, each on a separate line.
1896 </para>
1897
1898 <para>
1899  To determine which actions apply to a request, the URL of the request is
1900  compared to all URL patterns in each <quote>action file</quote>.
1901  Every time it matches, the list of applicable actions for the request is
1902  incrementally updated, using the heading of the section in which the
1903  pattern is located. The same is done again for tags and tag patterns later on.
1904 </para>
1905
1906 <para>
1907  If multiple applying sections set the same action differently,
1908  the last match wins. If not, the effects are aggregated.
1909  E.g. a URL might match a regular section with a heading line of <literal>{
1910  +<link linkend="handle-as-image">handle-as-image</link> }</literal>,
1911  then later another one with just <literal>{
1912  +<link linkend="block">block</link> }</literal>, resulting
1913  in <emphasis>both</emphasis> actions to apply. And there may well be
1914  cases where you will want to combine actions together. Such a section then
1915  might look like:
1916 </para>
1917
1918  <screen>
1919   { +<literal>handle-as-image</literal>  +<literal>block{Banner ads.}</literal> }
1920   # Block these as if they were images. Send no block page.
1921    banners.example.com
1922    media.example.com/.*banners
1923    .example.com/images/ads/</screen>
1924
1925 <para>
1926  You can trace this process for URL patterns and any given URL by visiting <ulink
1927  url="http://config.privoxy.org/show-url-info">http://config.privoxy.org/show-url-info</ulink>.
1928 </para>
1929
1930 <para>
1931  Examples and more detail on this is provided in the Appendix, <link linkend="ACTIONSANAT">
1932  Troubleshooting: Anatomy of an Action</link> section.
1933 </para>
1934 </sect2>
1935
1936 <!--   ~~~~~       New section      ~~~~~     -->
1937 <sect2 id="af-patterns">
1938 <title>Patterns</title>
1939 <para>
1940  As mentioned, <application>Privoxy</application> uses <quote>patterns</quote>
1941  to determine what <emphasis>actions</emphasis> might apply to which sites and
1942  pages your browser attempts to access. These <quote>patterns</quote> use wild
1943  card type <emphasis>pattern</emphasis> matching to achieve a high degree of
1944  flexibility. This allows one expression to be expanded and potentially match
1945  against many similar patterns.
1946 </para>
1947
1948 <para>
1949  Generally, an URL pattern has the form
1950  <literal>&lt;host&gt;&lt;port&gt;/&lt;path&gt;</literal>, where the
1951  <literal>&lt;host&gt;</literal>, the <literal>&lt;port&gt;</literal>
1952  and the <literal>&lt;path&gt;</literal> are optional. (This is why the special
1953  <literal>/</literal> pattern matches all URLs). Note that the protocol
1954  portion of the URL pattern (e.g. <literal>http://</literal>) should
1955  <emphasis>not</emphasis> be included in the pattern. This is assumed already!
1956 </para>
1957 <para>
1958  The pattern matching syntax is different for the host and path parts of
1959  the URL. The host part uses a simple globbing type matching technique,
1960  while the path part uses more flexible
1961  <ulink url="http://en.wikipedia.org/wiki/Regular_expressions"><quote>Regular
1962   Expressions</quote></ulink> (POSIX 1003.2).
1963 </para>
1964 <para>
1965  The port part of a pattern is a decimal port number preceded by a colon
1966  (<literal>:</literal>). If the host part contains a numerical IPv6 address,
1967  it has to be put into angle brackets
1968  (<literal>&lt;</literal>, <literal>&gt;</literal>).
1969 </para>
1970
1971 <variablelist>
1972  <varlistentry>
1973   <term><literal>www.example.com/</literal></term>
1974   <listitem>
1975    <para>
1976     is a host-only pattern and will match any request to <literal>www.example.com</literal>,
1977     regardless of which document on that server is requested. So ALL pages in
1978     this domain would be covered by the scope of this action. Note that a
1979     simple <literal>example.com</literal> is different and would NOT match.
1980    </para>
1981   </listitem>
1982  </varlistentry>
1983  <varlistentry>
1984   <term><literal>www.example.com</literal></term>
1985   <listitem>
1986    <para>
1987     means exactly the same. For host-only patterns, the trailing <literal>/</literal> may
1988     be omitted.
1989    </para>
1990   </listitem>
1991  </varlistentry>
1992  <varlistentry>
1993   <term><literal>www.example.com/index.html</literal></term>
1994   <listitem>
1995    <para>
1996     matches all the documents on <literal>www.example.com</literal>
1997     whose name starts with <literal>/index.html</literal>.
1998    </para>
1999   </listitem>
2000  </varlistentry>
2001  <varlistentry>
2002   <term><literal>www.example.com/index.html$</literal></term>
2003   <listitem>
2004    <para>
2005     matches only the single document <literal>/index.html</literal>
2006     on <literal>www.example.com</literal>.
2007    </para>
2008   </listitem>
2009  </varlistentry>
2010  <varlistentry>
2011   <term><literal>/index.html$</literal></term>
2012   <listitem>
2013    <para>
2014     matches the document <literal>/index.html</literal>, regardless of the domain,
2015     i.e. on <emphasis>any</emphasis> web server anywhere.
2016    </para>
2017   </listitem>
2018  </varlistentry>
2019  <varlistentry>
2020   <term><literal>/</literal></term>
2021   <listitem>
2022    <para>
2023     Matches any URL because there's no requirement for either the
2024     domain or the path to match anything.
2025    </para>
2026   </listitem>
2027  </varlistentry>
2028  <varlistentry>
2029   <term><literal>:8000/</literal></term>
2030   <listitem>
2031    <para>
2032     Matches any URL pointing to TCP port 8000.
2033    </para>
2034   </listitem>
2035  </varlistentry>
2036  <varlistentry>
2037   <term><literal>10.0.0.1/</literal></term>
2038   <listitem>
2039    <para>
2040     Matches any URL with the host address <literal>10.0.0.1</literal>.
2041     (Note that the real URL uses plain brackets, not angle brackets.)
2042    </para>
2043   </listitem>
2044  </varlistentry>
2045  <varlistentry>
2046   <term><literal>&lt;2001:db8::1&gt;/</literal></term>
2047   <listitem>
2048    <para>
2049     Matches any URL with the host address <literal>2001:db8::1</literal>.
2050     (Note that the real URL uses plain brackets, not angle brackets.)
2051    </para>
2052   </listitem>
2053  </varlistentry>
2054  <varlistentry>
2055   <term><literal>index.html</literal></term>
2056   <listitem>
2057    <para>
2058     matches nothing, since it would be interpreted as a domain name and
2059     there is no top-level domain called <literal>.html</literal>. So its
2060     a mistake.
2061    </para>
2062   </listitem>
2063  </varlistentry>
2064 </variablelist>
2065
2066
2067 <!--   ~~~~~       New section      ~~~~~     -->
2068 <sect3 id="host-pattern"><title>The Host Pattern</title>
2069
2070 <para>
2071  The matching of the host part offers some flexible options: if the
2072  host pattern starts or ends with a dot, it becomes unanchored at that end.
2073  The host pattern is often referred to as domain pattern as it is usually
2074  used to match domain names and not IP addresses.
2075  For example:
2076 </para>
2077
2078 <variablelist>
2079  <varlistentry>
2080   <term><literal>.example.com</literal></term>
2081   <listitem>
2082    <para>
2083     matches any domain with first-level domain <literal>com</literal>
2084     and second-level domain <literal>example</literal>.
2085     For example <literal>www.example.com</literal>,
2086     <literal>example.com</literal> and <literal>foo.bar.baz.example.com</literal>.
2087     Note that it wouldn't match if the second-level domain was <literal>another-example</literal>.
2088    </para>
2089   </listitem>
2090  </varlistentry>
2091  <varlistentry>
2092   <term><literal>www.</literal></term>
2093   <listitem>
2094    <para>
2095     matches any domain that <emphasis>STARTS</emphasis> with
2096     <literal>www.</literal> (It also matches the domain
2097     <literal>www</literal> but most of the time that doesn't matter.)
2098    </para>
2099   </listitem>
2100  </varlistentry>
2101  <varlistentry>
2102   <term><literal>.example.</literal></term>
2103   <listitem>
2104    <para>
2105     matches any domain that <emphasis>CONTAINS</emphasis> <literal>.example.</literal>.
2106     And, by the way, also included would be any files or documents that exist
2107     within that domain since no path limitations are specified. (Correctly
2108     speaking: It matches any FQDN that contains <literal>example</literal> as
2109     a domain.) This might be <literal>www.example.com</literal>,
2110     <literal>news.example.de</literal>, or
2111     <literal>www.example.net/cgi/testing.pl</literal> for instance. All these
2112     cases are matched.
2113    </para>
2114   </listitem>
2115  </varlistentry>
2116 </variablelist>
2117
2118 <para>
2119  Additionally, there are wild-cards that you can use in the domain names
2120  themselves. These work similarly to shell globbing type wild-cards:
2121  <quote>*</quote> represents zero or more arbitrary characters (this is
2122  equivalent to the
2123  <ulink url="http://en.wikipedia.org/wiki/Regular_expressions"><quote>Regular
2124  Expression</quote></ulink> based syntax of <quote>.*</quote>),
2125  <quote>?</quote>  represents any single character (this is equivalent to the
2126  regular expression syntax of a simple <quote>.</quote>), and you can define
2127  <quote>character classes</quote> in square brackets which is similar to
2128  the same regular expression technique. All of this can be freely mixed:
2129 </para>
2130
2131 <variablelist>
2132  <varlistentry>
2133   <term><literal>ad*.example.com</literal></term>
2134   <listitem>
2135    <para>
2136     matches <quote>adserver.example.com</quote>,
2137     <quote>ads.example.com</quote>, etc but not <quote>sfads.example.com</quote>
2138    </para>
2139   </listitem>
2140  </varlistentry>
2141  <varlistentry>
2142   <term><literal>*ad*.example.com</literal></term>
2143   <listitem>
2144    <para>
2145     matches all of the above, and then some.
2146    </para>
2147   </listitem>
2148  </varlistentry>
2149  <varlistentry>
2150   <term><literal>.?pix.com</literal></term>
2151   <listitem>
2152    <para>
2153     matches <literal>www.ipix.com</literal>,
2154     <literal>pictures.epix.com</literal>, <literal>a.b.c.d.e.upix.com</literal> etc.
2155    </para>
2156   </listitem>
2157  </varlistentry>
2158  <varlistentry>
2159   <term><literal>www[1-9a-ez].example.c*</literal></term>
2160   <listitem>
2161    <para>
2162      matches <literal>www1.example.com</literal>,
2163      <literal>www4.example.cc</literal>, <literal>wwwd.example.cy</literal>,
2164      <literal>wwwz.example.com</literal> etc., but <emphasis>not</emphasis>
2165      <literal>wwww.example.com</literal>.
2166    </para>
2167   </listitem>
2168  </varlistentry>
2169 </variablelist>
2170
2171 <para>
2172  While flexible, this is not the sophistication of full regular expression based syntax.
2173 </para>
2174
2175 </sect3>
2176
2177 <!--  ~  End section  ~  -->
2178
2179
2180 <!--   ~~~~~       New section      ~~~~~     -->
2181 <sect3 id="path-pattern"><title>The Path Pattern</title>
2182
2183 <para>
2184  <application>Privoxy</application> uses <quote>modern</quote> POSIX 1003.2
2185   <ulink url="http://en.wikipedia.org/wiki/Regular_expressions"><quote>Regular
2186   Expressions</quote></ulink> for matching the path portion (after the slash),
2187   and is thus more flexible.
2188 </para>
2189
2190 <para>
2191  There is an <link linkend="regex">Appendix</link> with a brief quick-start into regular
2192  expressions, you also might want to have a look at your operating system's documentation
2193  on regular expressions (try <literal>man re_format</literal>).
2194 </para>
2195
2196 <para>
2197  Note that the path pattern is automatically left-anchored at the <quote>/</quote>,
2198  i.e. it matches as if it would start with a <quote>^</quote> (regular expression speak
2199  for the beginning of a line).
2200 </para>
2201
2202 <para>
2203  Please also note that matching in the path is <emphasis>CASE INSENSITIVE</emphasis>
2204  by default, but you can switch to case sensitive at any point in the pattern by using the
2205  <quote>(?-i)</quote> switch: <literal>www.example.com/(?-i)PaTtErN.*</literal> will match
2206  only documents whose path starts with <literal>PaTtErN</literal> in
2207  <emphasis>exactly</emphasis> this capitalization.
2208 </para>
2209
2210 <variablelist>
2211  <varlistentry>
2212   <term><literal>.example.com/.*</literal></term>
2213   <listitem>
2214    <para>
2215      Is equivalent to just <quote>.example.com</quote>, since any documents
2216      within that domain are matched with or without the <quote>.*</quote>
2217      regular expression. This is redundant
2218    </para>
2219   </listitem>
2220  </varlistentry>
2221  <varlistentry>
2222   <term><literal>.example.com/.*/index.html$</literal></term>
2223   <listitem>
2224    <para>
2225     Will match any page in the domain of <quote>example.com</quote> that is
2226     named <quote>index.html</quote>, and that is part of some path. For
2227     example, it matches <quote>www.example.com/testing/index.html</quote> but
2228     NOT <quote>www.example.com/index.html</quote> because the regular
2229     expression called for at least two <quote>/'s</quote>, thus the path
2230     requirement. It also would match
2231     <quote>www.example.com/testing/index_html</quote>, because of the
2232     special meta-character <quote>.</quote>.
2233    </para>
2234   </listitem>
2235  </varlistentry>
2236  <varlistentry>
2237   <term><literal>.example.com/(.*/)?index\.html$</literal></term>
2238   <listitem>
2239    <para>
2240     This regular expression is conditional so it will match any page
2241     named <quote>index.html</quote> regardless of path which in this case can
2242     have one or more <quote>/'s</quote>. And this one must contain exactly
2243     <quote>.html</quote> (and end with that!).
2244    </para>
2245   </listitem>
2246  </varlistentry>
2247  <varlistentry>
2248   <term><literal>.example.com/(.*/)(ads|banners?|junk)</literal></term>
2249   <listitem>
2250    <para>
2251     This regular expression will match any path of <quote>example.com</quote>
2252     that contains any of the words <quote>ads</quote>, <quote>banner</quote>,
2253     <quote>banners</quote> (because of the <quote>?</quote>) or <quote>junk</quote>.
2254     The path does not have to end in these words, just contain them.
2255     The path has to contain at least two slashes (including the one at the beginning).
2256    </para>
2257   </listitem>
2258  </varlistentry>
2259  <varlistentry>
2260   <term><literal>.example.com/(.*/)(ads|banners?|junk)/.*\.(jpe?g|gif|png)$</literal></term>
2261   <listitem>
2262    <para>
2263     This is very much the same as above, except now it must end in either
2264     <quote>.jpg</quote>, <quote>.jpeg</quote>, <quote>.gif</quote> or <quote>.png</quote>. So this
2265     one is limited to common image formats.
2266    </para>
2267   </listitem>
2268  </varlistentry>
2269
2270 </variablelist>
2271 <para>
2272  There are many, many good examples to be found in <filename>default.action</filename>,
2273  and more tutorials below in <link linkend="regex">Appendix on regular expressions</link>.
2274 </para>
2275
2276 </sect3>
2277
2278 <!--  ~  End section  ~  -->
2279
2280
2281 <!--   ~~~~~       New section      ~~~~~     -->
2282 <sect3 id="tag-pattern"><title>The Request Tag Pattern</title>
2283
2284 <para>
2285  Request tag patterns are used to change the applying actions based on the
2286  request's tags. Tags can be created based on HTTP headers with either
2287  the <link linkend="CLIENT-HEADER-TAGGER">client-header-tagger</link>
2288  or the  <link linkend="SERVER-HEADER-TAGGER">server-header-tagger</link> action.
2289 </para>
2290
2291 <para>
2292  Request tag patterns have to start with <quote>TAG:</quote>, so &my-app;
2293  can tell them apart from other patterns. Everything after the colon
2294  including white space, is interpreted as a regular expression with
2295  path pattern syntax, except that tag patterns aren't left-anchored
2296  automatically (&my-app; doesn't silently add a <quote>^</quote>,
2297  you have to do it yourself if you need it).
2298 </para>
2299
2300 <para>
2301  To match all requests that are tagged with <quote>foo</quote>
2302  your pattern line should be <quote>TAG:^foo$</quote>,
2303  <quote>TAG:foo</quote> would work as well, but it would also
2304  match requests whose tags contain <quote>foo</quote> somewhere.
2305  <quote>TAG: foo</quote> wouldn't work as it requires white space.
2306 </para>
2307
2308 <para>
2309  Sections can contain URL and request tag patterns at the same time,
2310  but request tag patterns are checked after the URL patterns and thus
2311  always overrule them, even if they are located before the URL patterns.
2312 </para>
2313
2314 <para>
2315  Once a new request tag is added, Privoxy checks right away if it's matched by one
2316  of the request tag patterns and updates the action settings accordingly. As a result
2317  request tags can be used to activate other tagger actions, as long as these other
2318  taggers look for headers that haven't already be parsed.
2319 </para>
2320
2321 <para>
2322  For example you could tag client requests which use the
2323  <literal>POST</literal> method,
2324  then use this tag to activate another tagger that adds a tag if cookies
2325  are sent, and then use a block action based on the cookie tag. This allows
2326  the outcome of one action, to be input into a subsequent action. However if
2327  you'd reverse the position of the described taggers, and activated the
2328  method tagger based on the cookie tagger, no method tags would be created.
2329  The method tagger would look for the request line, but at the time
2330  the cookie tag is created, the request line has already been parsed.
2331 </para>
2332
2333 <para>
2334  While this is a limitation you should be aware of, this kind of
2335  indirection is seldom needed anyway and even the example doesn't
2336  make too much sense.
2337 </para>
2338
2339 </sect3>
2340
2341 <!--   ~~~~~       New section      ~~~~~     -->
2342 <sect3 id="negative-tag-patterns"><title>The Negative Request Tag Patterns</title>
2343
2344 <para>
2345  To match requests that do not have a certain request tag, specify a negative tag pattern
2346  by prefixing the tag pattern line with either <quote>NO-REQUEST-TAG:</quote>
2347  or <quote>NO-RESPONSE-TAG:</quote> instead of <quote>TAG:</quote>.
2348 </para>
2349
2350 <para>
2351  Negative request tag patterns created with <quote>NO-REQUEST-TAG:</quote> are checked
2352  after all client headers are scanned, the ones created with <quote>NO-RESPONSE-TAG:</quote>
2353  are checked after all server headers are scanned. In both cases all the created
2354  tags are considered.
2355 </para>
2356 </sect3>
2357
2358 <!--   ~~~~~       New section      ~~~~~     -->
2359 <sect3 id="client-tag-pattern"><title>The Client Tag Pattern</title>
2360
2361 <!-- XXX: This section contains duplicates content from the
2362           client-specific-tag documentation. -->
2363
2364 <warning>
2365 <para>
2366  This is an experimental feature. The syntax is likely to change in future versions.
2367 </para>
2368 </warning>
2369
2370 <para>
2371  Client tag patterns are not set based on HTTP headers but based on
2372  the client's IP address. Users can enable them themselves, but the
2373  Privoxy admin controls which tags are available and what their effect
2374  is.
2375 </para>
2376
2377 <para>
2378  After a client-specific tag has been defined with the
2379  <link linkend="client-specific-tag">client-specific-tag</link>,
2380  directive, action sections can be activated based on the tag by using a
2381  CLIENT-TAG pattern. The CLIENT-TAG pattern is evaluated at the same priority
2382  as URL patterns, as a result the last matching pattern wins. Tags that
2383  are created based on client or server headers are evaluated later on
2384  and can overrule CLIENT-TAG and URL patterns!
2385 </para>
2386 <para>
2387  The tag is set for all requests that come from clients that requested
2388  it to be set. Note that "clients" are  differentiated by IP address,
2389  if the IP address changes the tag has to be requested again.
2390 </para>
2391 <para>
2392  Clients can request tags to be set by using the CGI interface <ulink
2393   url="http://config.privoxy.org/client-tags">http://config.privoxy.org/client-tags</ulink>.
2394 </para>
2395
2396 <para>
2397  Example:
2398 </para>
2399
2400  <screen>
2401 # If the admin defined the client-specific-tag circumvent-blocks,
2402 # and the request comes from a client that previously requested
2403 # the tag to be set, overrule all previous +block actions that
2404 # are enabled based on URL to CLIENT-TAG patterns.
2405 {-block}
2406 CLIENT-TAG:^circumvent-blocks$
2407
2408 # This section is not overruled because it's located after
2409 # the previous one.
2410 {+block{Nobody is supposed to request this.}}
2411 example.org/blocked-example-page</screen>
2412
2413 </sect3>
2414
2415 </sect2>
2416
2417 <!--  ~  End section  ~  -->
2418
2419
2420 <!--   ~~~~~       New section      ~~~~~     -->
2421
2422 <sect2 id="actions">
2423 <title>Actions</title>
2424 <para>
2425  All actions are disabled by default, until they are explicitly enabled
2426  somewhere in an actions file. Actions are turned on if preceded with a
2427  <quote>+</quote>, and turned off if preceded with a <quote>-</quote>. So a
2428  <literal>+action</literal> means <quote>do that action</quote>, e.g.
2429  <literal>+block</literal> means <quote>please block URLs that match the
2430  following patterns</quote>, and <literal>-block</literal> means <quote>don't
2431  block URLs that match the following patterns, even if <literal>+block</literal>
2432  previously applied.</quote>
2433 </para>
2434
2435 <para>
2436  Again, actions are invoked by placing them on a line, enclosed in curly braces and
2437  separated by whitespace, like in
2438  <literal>{+some-action -some-other-action{some-parameter}}</literal>,
2439  followed by a list of URL patterns, one per line, to which they apply.
2440  Together, the actions line and the following pattern lines make up a section
2441  of the actions file.
2442 </para>
2443
2444 <para>
2445  Actions fall into three categories:
2446 </para>
2447
2448  <itemizedlist>
2449  <listitem>
2450   <para>
2451    Boolean, i.e the action can only be <quote>enabled</quote> or
2452    <quote>disabled</quote>. Syntax:
2453   </para>
2454    <screen>
2455   +<replaceable class="function">name</replaceable>        # enable action <replaceable class="parameter">name</replaceable>
2456   -<replaceable class="function">name</replaceable>        # disable action <replaceable class="parameter">name</replaceable></screen>
2457   <para>
2458    Example: <literal>+handle-as-image</literal>
2459   </para>
2460  </listitem>
2461
2462
2463  <listitem>
2464   <para>
2465    Parameterized, where some value is required in order to enable this type of action.
2466    Syntax:
2467   </para>
2468    <screen>
2469   +<replaceable class="function">name</replaceable>{<replaceable class="parameter">param</replaceable>}  # enable action and set parameter to <replaceable class="parameter">param</replaceable>,
2470                # overwriting parameter from previous match if necessary
2471   -<replaceable class="function">name</replaceable>         # disable action. The parameter can be omitted</screen>
2472   <para>
2473    Note that if the URL matches multiple positive forms of a parameterized action,
2474    the last match wins, i.e. the params from earlier matches are simply ignored.
2475   </para>
2476   <para>
2477    Example: <literal>+hide-user-agent{Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4}</literal>
2478   </para>
2479  </listitem>
2480
2481  <listitem>
2482   <para>
2483    Multi-value. These look exactly like parameterized actions,
2484    but they behave differently: If the action applies multiple times to the
2485    same URL, but with different parameters, <emphasis>all</emphasis> the parameters
2486    from <emphasis>all</emphasis> matches are remembered. This is used for actions
2487    that can be executed for the same request repeatedly, like adding multiple
2488    headers, or filtering through multiple filters. Syntax:
2489   </para>
2490    <screen>
2491   +<replaceable class="function">name</replaceable>{<replaceable class="parameter">param</replaceable>}   # enable action and add <replaceable class="parameter">param</replaceable> to the list of parameters
2492   -<replaceable class="function">name</replaceable>{<replaceable class="parameter">param</replaceable>}   # remove the parameter <replaceable class="parameter">param</replaceable> from the list of parameters
2493                 # If it was the last one left, disable the action.
2494   <replaceable class="parameter">-name</replaceable>          # disable this action completely and remove all parameters from the list</screen>
2495   <para>
2496    Examples: <literal>+add-header{X-Fun-Header: Some text}</literal> and
2497    <literal>+filter{html-annoyances}</literal>
2498   </para>
2499  </listitem>
2500
2501  </itemizedlist>
2502
2503 <para>
2504  If nothing is specified in any actions file, no <quote>actions</quote> are
2505  taken. So in this case <application>Privoxy</application> would just be a
2506  normal, non-blocking, non-filtering proxy. You must specifically enable the
2507  privacy and blocking features you need (although the provided default actions
2508  files will give a good starting point).
2509 </para>
2510
2511 <para>
2512  Later defined action sections always over-ride earlier ones of the same type.
2513  So exceptions to any rules you make, should come in the latter part of the file (or
2514  in a file that is processed later when using multiple actions files such
2515  as <filename>user.action</filename>). For multi-valued actions, the actions
2516  are applied in the order they are specified. Actions files are processed in
2517  the order they are defined in <filename>config</filename> (the default
2518  installation has three actions files). It also quite possible for any given
2519  URL to match more than one <quote>pattern</quote> (because of wildcards and
2520  regular expressions), and thus to trigger more than one set of actions! Last
2521  match wins.
2522 </para>
2523
2524 <!-- start actions listing -->
2525 <para>
2526  The list of valid <application>Privoxy</application> actions are:
2527 </para>
2528
2529
2530 <!-- ********************************************************** -->
2531 <!-- Please note the below defined actions use id's that are    -->
2532 <!-- probably linked from other places, so please don't change. -->
2533 <!--                                                            -->
2534 <!-- ********************************************************** -->
2535
2536
2537 <!--   ~~~~~       New section      ~~~~~     -->
2538
2539 <sect3 renderas="sect4" id="add-header">
2540 <title>add-header</title>
2541
2542 <variablelist>
2543  <varlistentry>
2544   <term>Typical use:</term>
2545   <listitem>
2546    <para>Confuse log analysis, custom applications</para>
2547   </listitem>
2548  </varlistentry>
2549
2550  <varlistentry>
2551   <term>Effect:</term>
2552   <listitem>
2553    <para>
2554     Sends a user defined HTTP header to the web server.
2555    </para>
2556   </listitem>
2557  </varlistentry>
2558
2559  <varlistentry>
2560   <term>Type:</term>
2561   <!-- boolean, parameterized, Multi-value -->
2562   <listitem>
2563    <para>Multi-value.</para>
2564   </listitem>
2565  </varlistentry>
2566
2567  <varlistentry>
2568   <term>Parameter:</term>
2569   <listitem>
2570    <para>
2571     Any string value is possible. Validity of the defined HTTP headers is not checked.
2572     It is recommended that you use the <quote><literal>X-</literal></quote> prefix
2573     for custom headers.
2574    </para>
2575   </listitem>
2576  </varlistentry>
2577
2578 <varlistentry>
2579   <term>Notes:</term>
2580   <listitem>
2581    <para>
2582     This action may be specified multiple times, in order to define multiple
2583     headers. This is rarely needed for the typical user. If you don't know what
2584     <quote>HTTP headers</quote> are, you definitely don't need to worry about this
2585     one.
2586    </para>
2587    <para>
2588     Headers added by this action are not modified by other actions.
2589    </para>
2590   </listitem>
2591  </varlistentry>
2592
2593  <varlistentry>
2594   <term>Example usage:</term>
2595   <listitem>
2596      <screen># Add a DNT ("Do not track") header to all requests,
2597 # event to those that already have one.
2598 #
2599 # This is just an example, not a recommendation.
2600 #
2601 # There is no reason to believe that user-tracking websites care
2602 # about the DNT header and depending on the User-Agent, adding the
2603 # header may make user-tracking easier.
2604 {+add-header{DNT: 1}}
2605 /</screen>
2606   </listitem>
2607  </varlistentry>
2608 </variablelist>
2609 </sect3>
2610
2611
2612 <!--   ~~~~~       New section      ~~~~~     -->
2613 <sect3 renderas="sect4" id="block">
2614 <title>block</title>
2615
2616 <variablelist>
2617  <varlistentry>
2618   <term>Typical use:</term>
2619   <listitem>
2620    <para>Block ads or other unwanted content</para>
2621   </listitem>
2622  </varlistentry>
2623
2624  <varlistentry>
2625   <term>Effect:</term>
2626   <listitem>
2627    <para>
2628     Requests for URLs to which this action applies are blocked, i.e. the
2629     requests are trapped by &my-app; and the requested URL is never retrieved,
2630     but is answered locally with a substitute page or image, as determined by
2631     the <literal><link
2632     linkend="handle-as-image">handle-as-image</link></literal>,
2633     <literal><link
2634     linkend="set-image-blocker">set-image-blocker</link></literal>, and
2635     <literal><link
2636     linkend="handle-as-empty-document">handle-as-empty-document</link></literal> actions.
2637
2638    </para>
2639   </listitem>
2640  </varlistentry>
2641
2642  <varlistentry>
2643   <term>Type:</term>
2644   <!-- boolean, parameterized, Multi-value -->
2645   <listitem>
2646    <para>Parameterized.</para>
2647   </listitem>
2648  </varlistentry>
2649
2650  <varlistentry>
2651   <term>Parameter:</term>
2652   <listitem>
2653    <para>A block reason that should be given to the user.</para>
2654   </listitem>
2655  </varlistentry>
2656
2657 <varlistentry>
2658   <term>Notes:</term>
2659   <listitem>
2660    <para>
2661     <application>Privoxy</application> sends a special <quote>BLOCKED</quote> page
2662     for requests to blocked pages. This page contains the block reason given as
2663     parameter, a link to find out why the block action applies, and a click-through
2664     to the blocked content (the latter only if the force feature is available and
2665     enabled).
2666    </para>
2667    <para>
2668     A very important exception occurs if <emphasis>both</emphasis>
2669     <literal>block</literal> and <literal><link linkend="handle-as-image">handle-as-image</link></literal>,
2670     apply to the same request: it will then be replaced by an image. If
2671     <literal><link linkend="set-image-blocker">set-image-blocker</link></literal>
2672     (see below) also applies, the type of image will be determined by its parameter,
2673     if not, the standard checkerboard pattern is sent.
2674    </para>
2675    <para>
2676     It is important to understand this process, in order
2677     to understand how <application>Privoxy</application> deals with
2678     ads and other unwanted content. Blocking is a core feature, and one
2679     upon which various other features depend.
2680    </para>
2681    <para>
2682     The <literal><link linkend="filter">filter</link></literal>
2683     action can perform a very similar task, by <quote>blocking</quote>
2684     banner images and other content through rewriting the relevant URLs in the
2685     document's HTML source, so they don't get requested in the first place.
2686     Note that this is a totally different technique, and it's easy to confuse the two.
2687    </para>
2688   </listitem>
2689  </varlistentry>
2690
2691  <varlistentry>
2692   <term>Example usage (section):</term>
2693   <listitem>
2694      <screen>{+block{No nasty stuff for you.}}
2695 # Block and replace with "blocked" page
2696  .nasty-stuff.example.com
2697
2698 {+block{Doubleclick banners.} +handle-as-image}
2699 # Block and replace with image
2700  .ad.doubleclick.net
2701  .ads.r.us/banners/
2702
2703 {+block{Layered ads.} +handle-as-empty-document}
2704 # Block and then ignore
2705  adserver.example.net/.*\.js$</screen>
2706   </listitem>
2707  </varlistentry>
2708
2709
2710 </variablelist>
2711 </sect3>
2712
2713
2714 <!--   ~~~~~       New section      ~~~~~     -->
2715 <sect3 renderas="sect4" id="change-x-forwarded-for">
2716 <title>change-x-forwarded-for</title>
2717
2718 <variablelist>
2719  <varlistentry>
2720   <term>Typical use:</term>
2721   <listitem>
2722    <para>Improve privacy by not forwarding the source of the request in the HTTP headers.</para>
2723   </listitem>
2724  </varlistentry>
2725
2726  <varlistentry>
2727   <term>Effect:</term>
2728   <listitem>
2729    <para>
2730     Deletes the <quote>X-Forwarded-For:</quote> HTTP header from the client request,
2731     or adds a new one.
2732    </para>
2733   </listitem>
2734  </varlistentry>
2735
2736  <varlistentry>
2737   <term>Type:</term>
2738   <!-- Boolean, Parameterized, Multi-value -->
2739   <listitem>
2740    <para>Parameterized.</para>
2741   </listitem>
2742  </varlistentry>
2743
2744  <varlistentry>
2745   <term>Parameter:</term>
2746   <listitem>
2747    <itemizedlist>
2748     <listitem>
2749      <para><quote>block</quote> to delete the header.</para>
2750     </listitem>
2751     <listitem>
2752      <para>
2753        <quote>add</quote> to create the header (or append
2754        the client's IP address to an already existing one).
2755      </para>
2756     </listitem>
2757    </itemizedlist>
2758   </listitem>
2759  </varlistentry>
2760
2761  <varlistentry>
2762   <term>Notes:</term>
2763   <listitem>
2764    <para>
2765     It is safe and recommended to use <literal>block</literal>.
2766    </para>
2767    <para>
2768     Forwarding the source address of the request may make
2769     sense in some multi-user setups but is also a privacy risk.
2770    </para>
2771   </listitem>
2772  </varlistentry>
2773  <varlistentry>
2774   <term>Example usage:</term>
2775   <listitem>
2776      <screen>+change-x-forwarded-for{block}</screen>
2777   </listitem>
2778  </varlistentry>
2779 </variablelist>
2780 </sect3>
2781
2782 <!--   ~~~~~       New section      ~~~~~     -->
2783 <sect3 renderas="sect4" id="client-header-filter">
2784 <title>client-header-filter</title>
2785
2786 <variablelist>
2787  <varlistentry>
2788   <term>Typical use:</term>
2789   <listitem>
2790    <para>
2791    Rewrite or remove single client headers.
2792    </para>
2793   </listitem>
2794  </varlistentry>
2795
2796  <varlistentry>
2797   <term>Effect:</term>
2798   <listitem>
2799    <para>
2800     All client headers to which this action applies are filtered on-the-fly through
2801     the specified regular expression based substitutions.
2802    </para>
2803   </listitem>
2804  </varlistentry>
2805
2806  <varlistentry>
2807   <term>Type:</term>
2808   <!-- boolean, parameterized, Multi-value -->
2809   <listitem>
2810    <para>Multi-value.</para>
2811   </listitem>
2812  </varlistentry>
2813
2814  <varlistentry>
2815   <term>Parameter:</term>
2816   <listitem>
2817    <para>
2818     The name of a client-header filter, as defined in one of the
2819     <link linkend="filter-file">filter files</link>.
2820    </para>
2821   </listitem>
2822  </varlistentry>
2823
2824  <varlistentry>
2825   <term>Notes:</term>
2826   <listitem>
2827    <para>
2828     Client-header filters are applied to each header on its own, not to
2829     all at once. This makes it easier to diagnose problems, but on the downside
2830     you can't write filters that only change header x if header y's value is z.
2831     You can do that by using tags though.
2832    </para>
2833    <para>
2834     Client-header filters are executed after the other header actions have finished
2835     and use their output as input.
2836    </para>
2837    <para>
2838     If the request URI gets changed, &my-app; will detect that and use the new
2839     one. This can be used to rewrite the request destination behind the client's
2840     back, for example to specify a Tor exit relay for certain requests.
2841    </para>
2842    <para>
2843     Please refer to the <link linkend="filter-file">filter file chapter</link>
2844     to learn which client-header filters are available by default, and how to
2845     create your own.
2846    </para>
2847
2848   </listitem>
2849  </varlistentry>
2850
2851  <varlistentry>
2852   <term>Example usage (section):</term>
2853   <listitem>
2854      <screen>
2855 # Hide Tor exit notation in Host and Referer Headers
2856 {+client-header-filter{hide-tor-exit-notation}}
2857 /
2858 </screen>
2859   </listitem>
2860  </varlistentry>
2861
2862 </variablelist>
2863 </sect3>
2864
2865
2866 <!--   ~~~~~       New section      ~~~~~     -->
2867 <sect3 renderas="sect4" id="client-header-tagger">
2868 <title>client-header-tagger</title>
2869
2870 <variablelist>
2871  <varlistentry>
2872   <term>Typical use:</term>
2873   <listitem>
2874    <para>
2875    Block requests based on their headers.
2876    </para>
2877   </listitem>
2878  </varlistentry>
2879
2880  <varlistentry>
2881   <term>Effect:</term>
2882   <listitem>
2883    <para>
2884     Client headers to which this action applies are filtered on-the-fly through
2885     the specified regular expression based substitutions, the result is used as
2886     tag.
2887    </para>
2888   </listitem>
2889  </varlistentry>
2890
2891  <varlistentry>
2892   <term>Type:</term>
2893   <!-- boolean, parameterized, Multi-value -->
2894   <listitem>
2895    <para>Multi-value.</para>
2896   </listitem>
2897  </varlistentry>
2898
2899  <varlistentry>
2900   <term>Parameter:</term>
2901   <listitem>
2902    <para>
2903     The name of a client-header tagger, as defined in one of the
2904     <link linkend="filter-file">filter files</link>.
2905    </para>
2906   </listitem>
2907  </varlistentry>
2908
2909  <varlistentry>
2910   <term>Notes:</term>
2911   <listitem>
2912    <para>
2913     Client-header taggers are applied to each header on its own,
2914     and as the header isn't modified, each tagger <quote>sees</quote>
2915     the original.
2916    </para>
2917    <para>
2918     Client-header taggers are the first actions that are executed
2919     and their tags can be used to control every other action.
2920    </para>
2921  </listitem>
2922  </varlistentry>
2923
2924  <varlistentry>
2925   <term>Example usage (section):</term>
2926   <listitem>
2927      <screen>
2928 # Tag every request with the User-Agent header
2929 {+client-header-tagger{user-agent}}
2930 /
2931
2932 # Tagging itself doesn't change the action
2933 # settings, sections with TAG patterns do:
2934 #
2935 # If it's a download agent, use a different forwarding proxy,
2936 # show the real User-Agent and make sure resume works.
2937 {+forward-override{forward-socks5 10.0.0.2:2222 .} \
2938  -hide-if-modified-since      \
2939  -overwrite-last-modified     \
2940  -hide-user-agent             \
2941  -filter                      \
2942  -deanimate-gifs              \
2943 }
2944 TAG:^User-Agent: NetBSD-ftp/
2945 TAG:^User-Agent: Novell ZYPP Installer
2946 TAG:^User-Agent: RPM APT-HTTP/
2947 TAG:^User-Agent: fetch libfetch/
2948 TAG:^User-Agent: Ubuntu APT-HTTP/
2949 TAG:^User-Agent: MPlayer/
2950     </screen>
2951
2952      <screen>
2953 # Tag all requests with the Range header set
2954 {+client-header-tagger{range-requests}}
2955 /
2956
2957 # Disable filtering for the tagged requests.
2958 #
2959 # With filtering enabled Privoxy would remove the Range headers
2960 # to be able to filter the whole response. The downside is that
2961 # it prevents clients from resuming downloads or skipping over
2962 # parts of multimedia files.
2963 {-filter -deanimate-gifs}
2964 TAG:^RANGE-REQUEST$
2965     </screen>
2966
2967      <screen>
2968 # Tag all requests with the client IP address
2969 #
2970 # (Technically the client IP address isn't included in the
2971 # client headers but client-header taggers can set it anyway.
2972 # For details see the tagger in default.filter)
2973 {+client-header-tagger{client-ip-address}}
2974 /
2975
2976 # Change forwarding settings for requests coming from address 10.0.0.1
2977 {+forward-override{forward-socks5 127.0.1.2:2222 .}}
2978 TAG:^IP-ADDRESS: 10\.0\.0\.1$
2979      </screen>
2980   </listitem>
2981  </varlistentry>
2982
2983 </variablelist>
2984 </sect3>
2985
2986
2987 <!--   ~~~~~       New section      ~~~~~     -->
2988 <sect3 renderas="sect4" id="content-type-overwrite">
2989 <title>content-type-overwrite</title>
2990
2991 <variablelist>
2992  <varlistentry>
2993   <term>Typical use:</term>
2994   <listitem>
2995    <para>Stop useless download menus from popping up, or change the browser's rendering mode</para>
2996   </listitem>
2997  </varlistentry>
2998
2999  <varlistentry>
3000   <term>Effect:</term>
3001   <listitem>
3002    <para>
3003     Replaces the <quote>Content-Type:</quote> HTTP server header.
3004    </para>
3005   </listitem>
3006  </varlistentry>
3007
3008  <varlistentry>
3009   <term>Type:</term>
3010   <!-- Boolean, Parameterized, Multi-value -->
3011   <listitem>
3012    <para>Parameterized.</para>
3013   </listitem>
3014  </varlistentry>
3015
3016  <varlistentry>
3017   <term>Parameter:</term>
3018   <listitem>
3019    <para>
3020     Any string.
3021    </para>
3022   </listitem>
3023  </varlistentry>
3024
3025  <varlistentry>
3026   <term>Notes:</term>
3027   <listitem>
3028    <para>
3029     The <quote>Content-Type:</quote> HTTP server header is used by the
3030     browser to decide what to do with the document. The value of this
3031     header can cause the browser to open a download menu instead of
3032     displaying the document by itself, even if the document's format is
3033     supported by the browser.
3034    </para>
3035    <para>
3036     The declared content type can also affect which rendering mode
3037     the browser chooses. If XHTML is delivered as <quote>text/html</quote>,
3038     many browsers treat it as yet another broken HTML document.
3039     If it is send as <quote>application/xml</quote>, browsers with
3040     XHTML support will only display it, if the syntax is correct.
3041    </para>
3042    <para>
3043     If you see a web site that proudly uses XHTML buttons, but sets
3044     <quote>Content-Type: text/html</quote>, you can use &my-app;
3045     to overwrite it with <quote>application/xml</quote> and validate
3046     the web master's claim inside your XHTML-supporting browser.
3047     If the syntax is incorrect, the browser will complain loudly.
3048    </para>
3049    <para>
3050     You can also go the opposite direction: if your browser prints
3051     error messages instead of rendering a document falsely declared
3052     as XHTML, you can overwrite the content type with
3053     <quote>text/html</quote> and have it rendered as broken HTML document.
3054    </para>
3055    <para>
3056     By default <literal>content-type-overwrite</literal> only replaces
3057     <quote>Content-Type:</quote> headers that look like some kind of text.
3058     If you want to overwrite it unconditionally, you have to combine it with
3059     <literal><link linkend="force-text-mode">force-text-mode</link></literal>.
3060     This limitation exists for a reason, think twice before circumventing it.
3061    </para>
3062    <para>
3063     Most of the time it's easier to replace this action with a custom
3064     <literal><link linkend="server-header-filter">server-header filter</link></literal>.
3065     It allows you to activate it for every document of a certain site and it will still
3066     only replace the content types you aimed at.
3067    </para>
3068    <para>
3069     Of course you can apply <literal>content-type-overwrite</literal>
3070     to a whole site and then make URL based exceptions, but it's a lot
3071     more work to get the same precision.
3072    </para>
3073   </listitem>
3074  </varlistentry>
3075
3076  <varlistentry>
3077   <term>Example usage (sections):</term>
3078   <listitem>
3079      <screen># Check if www.example.net/ really uses valid XHTML
3080 { +content-type-overwrite{application/xml} }
3081 www.example.net/
3082
3083 # but leave the content type unmodified if the URL looks like a style sheet
3084 {-content-type-overwrite}
3085 www.example.net/.*\.css$
3086 www.example.net/.*style
3087 </screen>
3088   </listitem>
3089  </varlistentry>
3090 </variablelist>
3091 </sect3>
3092
3093
3094 <!--   ~~~~~       New section      ~~~~~     -->
3095 <sect3 renderas="sect4" id="crunch-client-header">
3096 <!--
3097 new action
3098 -->
3099 <title>crunch-client-header</title>
3100
3101 <variablelist>
3102  <varlistentry>
3103   <term>Typical use:</term>
3104   <listitem>
3105    <para>Remove a client header <application>Privoxy</application> has no dedicated action for.</para>
3106   </listitem>
3107  </varlistentry>
3108
3109  <varlistentry>
3110   <term>Effect:</term>
3111   <listitem>
3112    <para>
3113     Deletes every header sent by the client that contains the string the user supplied as parameter.
3114    </para>
3115   </listitem>
3116  </varlistentry>
3117
3118  <varlistentry>
3119   <term>Type:</term>
3120   <!-- Boolean, Parameterized, Multi-value -->
3121   <listitem>
3122    <para>Parameterized.</para>
3123   </listitem>
3124  </varlistentry>
3125
3126  <varlistentry>
3127   <term>Parameter:</term>
3128   <listitem>
3129    <para>
3130     Any string.
3131    </para>
3132   </listitem>
3133  </varlistentry>
3134
3135  <varlistentry>
3136   <term>Notes:</term>
3137   <listitem>
3138    <para>
3139     This action allows you to block client headers for which no dedicated
3140     <application>Privoxy</application> action exists.
3141     <application>Privoxy</application> will remove every client header that
3142     contains the string you supplied as parameter.
3143    </para>
3144    <para>
3145     Regular expressions are <emphasis>not supported</emphasis> and you can't
3146     use this action to block different headers in the same request, unless
3147     they contain the same string.
3148    </para>
3149    <para>
3150     <literal>crunch-client-header</literal> is only meant for quick tests.
3151     If you have to block several different headers, or only want to modify
3152     parts of them, you should use a
3153     <literal><link linkend="client-header-filter">client-header filter</link></literal>.
3154    </para>
3155     <warning>
3156      <para>
3157       Don't block any header without understanding the consequences.
3158      </para>
3159     </warning>
3160   </listitem>
3161  </varlistentry>
3162
3163  <varlistentry>
3164   <term>Example usage (section):</term>
3165   <listitem>
3166      <screen># Block the non-existent "Privacy-Violation:" client header
3167 { +crunch-client-header{Privacy-Violation:} }
3168 /
3169     </screen>
3170   </listitem>
3171  </varlistentry>
3172 </variablelist>
3173 </sect3>
3174
3175
3176 <!--   ~~~~~       New section      ~~~~~     -->
3177 <sect3 renderas="sect4" id="crunch-if-none-match">
3178 <title>crunch-if-none-match</title>
3179 <!--
3180 new action
3181 -->
3182 <variablelist>
3183  <varlistentry>
3184   <term>Typical use:</term>
3185   <listitem>
3186    <para>Prevent yet another way to track the user's steps between sessions.</para>
3187   </listitem>
3188  </varlistentry>
3189
3190  <varlistentry>
3191   <term>Effect:</term>
3192   <listitem>
3193    <para>
3194     Deletes the <quote>If-None-Match:</quote> HTTP client header.
3195    </para>
3196   </listitem>
3197  </varlistentry>
3198
3199  <varlistentry>
3200   <term>Type:</term>
3201   <!-- Boolean, Parameterized, Multi-value -->
3202   <listitem>
3203    <para>Boolean.</para>
3204   </listitem>
3205  </varlistentry>
3206
3207  <varlistentry>
3208   <term>Parameter:</term>
3209   <listitem>
3210    <para>
3211     N/A
3212    </para>
3213   </listitem>
3214  </varlistentry>
3215
3216  <varlistentry>
3217   <term>Notes:</term>
3218   <listitem>
3219    <para>
3220     Removing the <quote>If-None-Match:</quote> HTTP client header
3221     is useful for filter testing, where you want to force a real
3222     reload instead of getting status code <quote>304</quote> which
3223     would cause the browser to use a cached copy of the page.
3224    </para>
3225    <para>
3226     It is also useful to make sure the header isn't used as a cookie
3227     replacement (unlikely but possible).
3228    </para>
3229    <para>
3230     Blocking the <quote>If-None-Match:</quote> header shouldn't cause any
3231     caching problems, as long as the <quote>If-Modified-Since:</quote> header
3232     isn't blocked or missing as well.
3233    </para>
3234    <para>
3235     It is recommended to use this action together with
3236     <literal><link linkend="hide-if-modified-since">hide-if-modified-since</link></literal>
3237     and
3238     <literal><link linkend="overwrite-last-modified">overwrite-last-modified</link></literal>.
3239    </para>
3240   </listitem>
3241  </varlistentry>
3242
3243  <varlistentry>
3244   <term>Example usage (section):</term>
3245   <listitem>
3246      <screen># Let the browser revalidate cached documents but don't
3247 # allow the server to use the revalidation headers for user tracking.
3248 {+hide-if-modified-since{-60} \
3249  +overwrite-last-modified{randomize} \
3250  +crunch-if-none-match}
3251 /   </screen>
3252   </listitem>
3253  </varlistentry>
3254 </variablelist>
3255 </sect3>
3256
3257
3258 <!--   ~~~~~       New section      ~~~~~     -->
3259 <sect3 renderas="sect4" id="crunch-incoming-cookies">
3260 <title>crunch-incoming-cookies</title>
3261
3262 <variablelist>
3263  <varlistentry>
3264   <term>Typical use:</term>
3265   <listitem>
3266    <para>
3267     Prevent the web server from setting HTTP cookies on your system
3268    </para>
3269   </listitem>
3270  </varlistentry>
3271
3272  <varlistentry>
3273   <term>Effect:</term>
3274   <listitem>
3275    <para>
3276     Deletes any <quote>Set-Cookie:</quote> HTTP headers from server replies.
3277    </para>
3278   </listitem>
3279  </varlistentry>
3280
3281  <varlistentry>
3282   <term>Type:</term>
3283   <!-- Boolean, Parameterized, Multi-value -->
3284   <listitem>
3285    <para>Boolean.</para>
3286   </listitem>
3287  </varlistentry>
3288
3289  <varlistentry>
3290   <term>Parameter:</term>
3291   <listitem>
3292    <para>
3293     N/A
3294    </para>
3295   </listitem>
3296  </varlistentry>
3297
3298  <varlistentry>
3299   <term>Notes:</term>
3300   <listitem>
3301    <para>
3302     This action is only concerned with <emphasis>incoming</emphasis> HTTP cookies. For
3303     <emphasis>outgoing</emphasis> HTTP cookies, use
3304     <literal><link linkend="crunch-outgoing-cookies">crunch-outgoing-cookies</link></literal>.
3305     Use <emphasis>both</emphasis> to disable HTTP cookies completely.
3306    </para>
3307    <para>
3308     It makes <emphasis>no sense at all</emphasis> to use this action in conjunction
3309     with the <literal><link linkend="session-cookies-only">session-cookies-only</link></literal> action,
3310     since it would prevent the session cookies from being set. See also
3311     <literal><link linkend="filter-content-cookies">filter-content-cookies</link></literal>.
3312    </para>
3313   </listitem>
3314  </varlistentry>
3315
3316  <varlistentry>
3317   <term>Example usage:</term>
3318   <listitem>
3319     <screen>+crunch-incoming-cookies</screen>
3320   </listitem>
3321  </varlistentry>
3322 </variablelist>
3323 </sect3>
3324
3325
3326 <!--   ~~~~~       New section      ~~~~~     -->
3327 <sect3 renderas="sect4" id="crunch-server-header">
3328 <title>crunch-server-header</title>
3329 <!--
3330 new action
3331 -->
3332 <variablelist>
3333  <varlistentry>
3334   <term>Typical use:</term>
3335   <listitem>
3336    <para>Remove a server header <application>Privoxy</application> has no dedicated action for.</para>
3337   </listitem>
3338  </varlistentry>
3339
3340  <varlistentry>
3341   <term>Effect:</term>
3342   <listitem>
3343    <para>
3344     Deletes every header sent by the server that contains the string the user supplied as parameter.
3345    </para>
3346   </listitem>
3347  </varlistentry>
3348
3349  <varlistentry>
3350   <term>Type:</term>
3351   <!-- Boolean, Parameterized, Multi-value -->
3352   <listitem>
3353    <para>Parameterized.</para>
3354   </listitem>
3355  </varlistentry>
3356
3357  <varlistentry>
3358   <term>Parameter:</term>
3359   <listitem>
3360    <para>
3361     Any string.
3362    </para>
3363   </listitem>
3364  </varlistentry>
3365
3366  <varlistentry>
3367   <term>Notes:</term>
3368   <listitem>
3369    <para>
3370     This action allows you to block server headers for which no dedicated
3371     <application>Privoxy</application> action exists. <application>Privoxy</application>
3372     will remove every server header that contains the string you supplied as parameter.
3373    </para>
3374    <para>
3375     Regular expressions are <emphasis>not supported</emphasis> and you can't
3376     use this action to block different headers in the same request, unless
3377     they contain the same string.
3378    </para>
3379    <para>
3380     <literal>crunch-server-header</literal> is only meant for quick tests.
3381     If you have to block several different headers, or only want to modify
3382     parts of them, you should use a custom
3383     <literal><link linkend="server-header-filter">server-header filter</link></literal>.
3384    </para>
3385     <warning>
3386      <para>
3387      Don't block any header without understanding the consequences.
3388      </para>
3389     </warning>
3390   </listitem>
3391  </varlistentry>
3392
3393  <varlistentry>
3394   <term>Example usage (section):</term>
3395   <listitem>
3396      <screen># Crunch server headers that try to prevent caching
3397 { +crunch-server-header{no-cache} }
3398 /   </screen>
3399   </listitem>
3400  </varlistentry>
3401 </variablelist>
3402 </sect3>
3403
3404
3405 <!--   ~~~~~       New section      ~~~~~     -->
3406 <sect3 renderas="sect4" id="crunch-outgoing-cookies">
3407 <title>crunch-outgoing-cookies</title>
3408
3409 <variablelist>
3410  <varlistentry>
3411   <term>Typical use:</term>
3412   <listitem>
3413    <para>
3414     Prevent the web server from reading any HTTP cookies from your system
3415    </para>
3416   </listitem>
3417  </varlistentry>
3418
3419  <varlistentry>
3420   <term>Effect:</term>
3421   <listitem>
3422    <para>
3423     Deletes any <quote>Cookie:</quote> HTTP headers from client requests.
3424    </para>
3425   </listitem>
3426  </varlistentry>
3427
3428  <varlistentry>
3429   <term>Type:</term>
3430   <!-- Boolean, Parameterized, Multi-value -->
3431   <listitem>
3432    <para>Boolean.</para>
3433   </listitem>
3434  </varlistentry>
3435
3436  <varlistentry>
3437   <term>Parameter:</term>
3438   <listitem>
3439    <para>
3440     N/A
3441    </para>
3442   </listitem>
3443  </varlistentry>
3444
3445  <varlistentry>
3446   <term>Notes:</term>
3447   <listitem>
3448    <para>
3449     This action is only concerned with <emphasis>outgoing</emphasis> HTTP cookies. For
3450     <emphasis>incoming</emphasis> HTTP cookies, use
3451     <literal><link linkend="crunch-incoming-cookies">crunch-incoming-cookies</link></literal>.
3452     Use <emphasis>both</emphasis> to disable HTTP cookies completely.
3453    </para>
3454    <para>
3455     It makes <emphasis>no sense at all</emphasis> to use this action in conjunction
3456     with the <literal><link linkend="session-cookies-only">session-cookies-only</link></literal> action,
3457     since it would prevent the session cookies from being read.
3458    </para>
3459   </listitem>
3460  </varlistentry>
3461
3462  <varlistentry>
3463   <term>Example usage:</term>
3464   <listitem>
3465     <screen>+crunch-outgoing-cookies</screen>
3466   </listitem>
3467  </varlistentry>
3468
3469 </variablelist>
3470 </sect3>
3471
3472
3473 <!--   ~~~~~       New section      ~~~~~     -->
3474 <sect3 renderas="sect4" id="deanimate-gifs">
3475 <title>deanimate-gifs</title>
3476
3477 <variablelist>
3478  <varlistentry>
3479   <term>Typical use:</term>
3480   <listitem>
3481    <para>Stop those annoying, distracting animated GIF images.</para>
3482   </listitem>
3483  </varlistentry>
3484
3485  <varlistentry>
3486   <term>Effect:</term>
3487   <listitem>
3488    <para>
3489     De-animate GIF animations, i.e. reduce them to their first or last image.
3490    </para>
3491   </listitem>
3492  </varlistentry>
3493
3494  <varlistentry>
3495   <term>Type:</term>
3496   <!-- boolean, parameterized, Multi-value -->
3497   <listitem>
3498    <para>Parameterized.</para>
3499   </listitem>
3500  </varlistentry>
3501
3502  <varlistentry>
3503   <term>Parameter:</term>
3504   <listitem>
3505    <para>
3506     <quote>last</quote> or <quote>first</quote>
3507    </para>
3508   </listitem>
3509  </varlistentry>
3510
3511  <varlistentry>
3512   <term>Notes:</term>
3513   <listitem>
3514    <para>
3515     This will also shrink the images considerably (in bytes, not pixels!). If
3516     the option <quote>first</quote> is given, the first frame of the animation
3517     is used as the replacement. If <quote>last</quote> is given, the last
3518     frame of the animation is used instead, which probably makes more sense for
3519     most banner animations, but also has the risk of not showing the entire
3520     last frame (if it is only a delta to an earlier frame).
3521    </para>
3522    <para>
3523     You can safely use this action with patterns that will also match non-GIF
3524     objects, because no attempt will be made at anything that doesn't look like
3525     a GIF.
3526    </para>
3527   </listitem>
3528  </varlistentry>
3529
3530  <varlistentry>
3531   <term>Example usage:</term>
3532   <listitem>
3533       <screen>+deanimate-gifs{last}</screen>
3534   </listitem>
3535  </varlistentry>
3536 </variablelist>
3537 </sect3>
3538
3539 <!--   ~~~~~       New section      ~~~~~     -->
3540 <sect3 renderas="sect4" id="downgrade-http-version">
3541 <title>downgrade-http-version</title>
3542
3543 <variablelist>
3544  <varlistentry>
3545   <term>Typical use:</term>
3546   <listitem>
3547    <para>Work around (very rare) problems with HTTP/1.1</para>
3548   </listitem>
3549  </varlistentry>
3550
3551  <varlistentry>
3552   <term>Effect:</term>
3553   <listitem>
3554    <para>
3555     Downgrades HTTP/1.1 client requests and server replies to HTTP/1.0.
3556    </para>
3557   </listitem>
3558  </varlistentry>
3559
3560  <varlistentry>
3561   <term>Type:</term>
3562   <!-- boolean, parameterized, Multi-value -->
3563   <listitem>
3564    <para>Boolean.</para>
3565   </listitem>
3566  </varlistentry>
3567
3568  <varlistentry>
3569   <term>Parameter:</term>
3570   <listitem>
3571    <para>
3572     N/A
3573    </para>
3574   </listitem>
3575  </varlistentry>
3576
3577 <varlistentry>
3578   <term>Notes:</term>
3579   <listitem>
3580    <para>
3581     This is a left-over from the time when <application>Privoxy</application>
3582     didn't support important HTTP/1.1 features well. It is left here for the
3583     unlikely case that you experience HTTP/1.1-related problems with some server
3584     out there.
3585    </para>
3586    <para>
3587     Note that enabling this action is only a workaround. It should not
3588     be enabled for sites that work without it. While it shouldn't break
3589     any pages, it has an (usually negative) performance impact.
3590   </para>
3591   <para>
3592     If you come across a site where enabling this action helps, please report it,
3593     so the cause of the problem can be analyzed. If the problem turns out to be
3594     caused by a bug in  <application>Privoxy</application> it should be
3595     fixed so the following release works without the work around.
3596    </para>
3597   </listitem>
3598  </varlistentry>
3599
3600  <varlistentry>
3601   <term>Example usage (section):</term>
3602   <listitem>
3603      <screen>{+downgrade-http-version}
3604 problem-host.example.com</screen>
3605   </listitem>
3606  </varlistentry>
3607
3608 </variablelist>
3609 </sect3>
3610
3611 <!--   ~~~~~       New section      ~~~~~     -->
3612 <sect3 renderas="sect4" id="external-filter">
3613 <title>external-filter</title>
3614
3615 <variablelist>
3616  <varlistentry>
3617   <term>Typical use:</term>
3618   <listitem>
3619    <para>Modify content using a programming language of your choice.</para>
3620   </listitem>
3621  </varlistentry>
3622
3623  <varlistentry>
3624   <term>Effect:</term>
3625   <listitem>
3626    <para>
3627     All instances of text-based type, most notably HTML and JavaScript, to which
3628     this action applies, can be filtered on-the-fly through the specified external
3629     filter.
3630     By default plain text documents are exempted from filtering, because web
3631     servers often use the <literal>text/plain</literal> MIME type for all files
3632     whose type they don't know.)
3633    </para>
3634   </listitem>
3635  </varlistentry>
3636
3637  <varlistentry>
3638   <term>Type:</term>
3639   <!-- boolean, parameterized, Multi-value -->
3640   <listitem>
3641    <para>Multi-value.</para>
3642   </listitem>
3643  </varlistentry>
3644
3645  <varlistentry>
3646   <term>Parameter:</term>
3647   <listitem>
3648    <para>
3649     The name of an external content filter, as defined in the
3650     <link linkend="filter-file">filter file</link>.
3651     External filters can be defined in one or more files as defined by the
3652     <literal><link linkend="filterfile">filterfile</link></literal>
3653     option in the <link linkend="config">config file</link>.
3654    </para>
3655    <para>
3656     When used in its negative form,
3657     and without parameters, <emphasis>all</emphasis> filtering with external
3658     filters is completely disabled.
3659   </para>
3660   </listitem>
3661  </varlistentry>
3662
3663  <varlistentry>
3664   <term>Notes:</term>
3665   <listitem>
3666    <para>
3667     External filters are scripts or programs that can modify the content in
3668     case common <literal><link linkend="filter">filters</link></literal>
3669     aren't powerful enough. With the exception that this action doesn't
3670     use pcrs-based filters, the notes in the
3671     <literal><link linkend="filter">filter</link></literal> section apply.
3672    </para>
3673    <warning>
3674     <para>
3675      Currently external filters are executed with &my-app;'s privileges.
3676      Only use external filters you understand and trust.
3677     </para>
3678    </warning>
3679    <para>
3680     This feature is experimental, the <literal><link
3681     linkend="external-filter-syntax">syntax</link></literal>
3682     may change in the future.
3683    </para>
3684
3685   </listitem>
3686  </varlistentry>
3687
3688  <varlistentry>
3689   <term>Example usage:</term>
3690   <listitem>
3691     <screen>+external-filter{fancy-filter}</screen>
3692   </listitem>
3693  </varlistentry>
3694 </variablelist>
3695 </sect3>
3696
3697 <!--   ~~~~~       New section      ~~~~~     -->
3698 <sect3 renderas="sect4" id="fast-redirects">
3699 <title>fast-redirects</title>
3700
3701 <variablelist>
3702  <varlistentry>
3703   <term>Typical use:</term>
3704   <listitem>
3705    <para>Fool some click-tracking scripts and speed up indirect links.</para>
3706   </listitem>
3707  </varlistentry>
3708
3709  <varlistentry>
3710   <term>Effect:</term>
3711   <listitem>
3712    <para>
3713     Detects redirection URLs and redirects the browser without contacting
3714     the redirection server first.
3715    </para>
3716   </listitem>
3717  </varlistentry>
3718
3719  <varlistentry>
3720   <term>Type:</term>
3721   <!-- boolean, parameterized, Multi-value -->
3722   <listitem>
3723    <para>Parameterized.</para>
3724   </listitem>
3725  </varlistentry>
3726
3727  <varlistentry>
3728   <term>Parameter:</term>
3729   <listitem>
3730    <itemizedlist>
3731     <listitem>
3732      <para>
3733       <quote>simple-check</quote> to just search for the string <quote>http://</quote>
3734       to detect redirection URLs.
3735      </para>
3736     </listitem>
3737     <listitem>
3738      <para>
3739       <quote>check-decoded-url</quote> to decode URLs (if necessary) before searching
3740       for redirection URLs.
3741      </para>
3742     </listitem>
3743    </itemizedlist>
3744   </listitem>
3745  </varlistentry>
3746
3747  <varlistentry>
3748   <term>Notes:</term>
3749   <listitem>
3750    <para>
3751     Many sites, like yahoo.com, don't just link to other sites. Instead, they
3752     will link to some script on their own servers, giving the destination as a
3753     parameter, which will then redirect you to the final target. URLs
3754     resulting from this scheme typically look like:
3755     <quote>http://www.example.org/click-tracker.cgi?target=http%3a//www.example.net/</quote>.
3756   </para>
3757    <para>
3758     Sometimes, there are even multiple consecutive redirects encoded in the
3759     URL. These redirections via scripts make your web browsing more traceable,
3760     since the server from which you follow such a link can see where you go
3761     to. Apart from that, valuable bandwidth and time is wasted, while your
3762     browser asks the server for one redirect after the other. Plus, it feeds
3763     the advertisers.
3764    </para>
3765    <para>
3766     This feature is currently not very smart and is scheduled for improvement.
3767     If it is enabled by default, you will have to create some exceptions to
3768     this action. It can lead to failures in several ways:
3769    </para>
3770    <para>
3771     Not every URLs with other URLs as parameters is evil.
3772     Some sites offer a real service that requires this information to work.
3773     For example a validation service needs to know, which document to validate.
3774     <literal>fast-redirects</literal> assumes that every URL parameter that
3775     looks like another URL is a redirection target, and will always redirect to
3776     the last one. Most of the time the assumption is correct, but if it isn't,
3777     the user gets redirected anyway.
3778    </para>
3779    <para>
3780     Another failure occurs if the URL contains other parameters after the URL parameter.
3781     The URL:
3782     <quote>http://www.example.org/?redirect=http%3a//www.example.net/&amp;foo=bar</quote>.
3783     contains the redirection URL <quote>http://www.example.net/</quote>,
3784     followed by another parameter. <literal>fast-redirects</literal> doesn't know that
3785     and will cause a redirect to <quote>http://www.example.net/&amp;foo=bar</quote>.
3786     Depending on the target server configuration, the parameter will be silently ignored
3787     or lead to a <quote>page not found</quote> error. You can prevent this problem by
3788     first using the <literal><link linkend="redirect">redirect</link></literal> action
3789     to remove the last part of the URL, but it requires a little effort.
3790    </para>
3791    <para>
3792     To detect a redirection URL, <literal>fast-redirects</literal> only
3793     looks for the string <quote>http://</quote>, either in plain text
3794     (invalid but often used) or encoded as <quote>http%3a//</quote>.
3795     Some sites use their own URL encoding scheme, encrypt the address
3796     of the target server or replace it with a database id. In theses cases
3797     <literal>fast-redirects</literal> is fooled and the request reaches the
3798     redirection server where it probably gets logged.
3799    </para>
3800   </listitem>
3801  </varlistentry>
3802
3803  <varlistentry>
3804   <term>Example usage:</term>
3805   <listitem>
3806      <screen>
3807  { +fast-redirects{simple-check} }
3808    one.example.com
3809
3810  { +fast-redirects{check-decoded-url} }
3811    another.example.com/testing</screen>
3812   </listitem>
3813  </varlistentry>
3814
3815 </variablelist>
3816 </sect3>
3817
3818
3819 <!--   ~~~~~       New section      ~~~~~     -->
3820 <sect3 renderas="sect4" id="filter">
3821 <title>filter</title>
3822
3823 <variablelist>
3824  <varlistentry>
3825   <term>Typical use:</term>
3826   <listitem>
3827    <para>Get rid of HTML and JavaScript annoyances, banner advertisements (by size),
3828          do fun text replacements, add personalized effects, etc.</para>
3829   </listitem>
3830  </varlistentry>
3831
3832  <varlistentry>
3833   <term>Effect:</term>
3834   <listitem>
3835    <para>
3836     All instances of text-based type, most notably HTML and JavaScript, to which
3837     this action applies, can be filtered on-the-fly through the specified regular
3838     expression based substitutions. (Note: as of version 3.0.3 plain text documents
3839     are exempted from filtering, because web servers often use the
3840    <literal>text/plain</literal> MIME type for all files whose type they don't know.)
3841    </para>
3842   </listitem>
3843  </varlistentry>
3844
3845  <varlistentry>
3846   <term>Type:</term>
3847   <!-- boolean, parameterized, Multi-value -->
3848   <listitem>
3849    <para>Multi-value.</para>
3850   </listitem>
3851  </varlistentry>
3852
3853  <varlistentry>
3854   <term>Parameter:</term>
3855   <listitem>
3856    <para>
3857     The name of a content filter, as defined in the <link linkend="filter-file">filter file</link>.
3858     Filters can be defined in one or more  files as defined by the
3859     <literal><link linkend="filterfile">filterfile</link></literal>
3860     option in the <link linkend="config">config file</link>.
3861     <filename>default.filter</filename> is the collection of filters
3862     supplied by the developers. Locally defined filters should go
3863     in their own file, such as <filename>user.filter</filename>.
3864    </para>
3865    <para>
3866      When used in its negative form,
3867      and without parameters, <emphasis>all</emphasis> filtering is completely disabled.
3868   </para>
3869   </listitem>
3870  </varlistentry>
3871
3872  <varlistentry>
3873   <term>Notes:</term>
3874   <listitem>
3875    <para>
3876     For your convenience, there are a number of pre-defined filters available
3877     in the distribution filter file that you can use. See the examples below for
3878     a list.
3879    </para>
3880    <para>
3881     Filtering requires buffering the page content, which may appear to
3882     slow down page rendering since nothing is displayed until all content has
3883     passed the filters. (The total time until the page is completely rendered
3884     doesn't change much, but it may be perceived as slower since the page is
3885     not incrementally displayed.)
3886     This effect will be more noticeable on slower connections.
3887    </para>
3888    <para>
3889    <quote>Rolling your own</quote>
3890     filters requires a knowledge of
3891      <ulink url="http://en.wikipedia.org/wiki/Regular_expressions"><quote>Regular
3892      Expressions</quote></ulink> and
3893       <ulink url="http://en.wikipedia.org/wiki/Html"><quote>HTML</quote></ulink>.
3894     This is very powerful feature, and potentially very intrusive.
3895     Filters should be used with caution, and where an equivalent
3896     <quote>action</quote> is not available.
3897    </para>
3898    <para>
3899     The amount of data that can be filtered is limited to the
3900     <literal><link linkend="buffer-limit">buffer-limit</link></literal>
3901     option in the main <link linkend="config">config file</link>. The
3902     default is 4096 KB (4 Megs). Once this limit is exceeded, the buffered
3903     data, and all pending data, is passed through unfiltered.
3904    </para>
3905    <para>
3906     Inappropriate MIME types, such as zipped files, are not filtered at all.
3907     (Again, only text-based types except plain text). Encrypted SSL data
3908     (from HTTPS servers) cannot be filtered either, since this would violate
3909     the integrity of the secure transaction. In some situations it might
3910     be necessary to protect certain text, like source code, from filtering
3911     by defining appropriate <literal>-filter</literal> exceptions.
3912    </para>
3913    <para>
3914     Compressed content can't be filtered either, but if &my-app;
3915     is compiled with zlib support and a supported compression algorithm
3916     is used (gzip or deflate), &my-app; can first decompress the content
3917     and then filter it.
3918    </para>
3919    <para>
3920     If you use a &my-app; version without zlib support, but want filtering to work on
3921     as much documents as possible, even those that would normally be sent compressed,
3922     you must use the <literal><link linkend="prevent-compression">prevent-compression</link></literal>
3923     action in conjunction with <literal>filter</literal>.
3924    </para>
3925    <para>
3926     Content filtering can achieve some of the same effects as the
3927     <literal><link linkend="block">block</link></literal>
3928     action, i.e. it can be used to block ads and banners. But the mechanism
3929     works quite differently. One effective use, is to block ad banners
3930     based on their size (see below), since many of these seem to be somewhat
3931     standardized.
3932    </para>
3933    <para>
3934     <link linkend="contact">Feedback</link> with suggestions for new or
3935     improved filters is particularly welcome!
3936    </para>
3937    <para>
3938     The below list has only the names and a one-line description of each
3939     predefined filter. There are <link linkend="predefined-filters">more
3940     verbose explanations</link> of what these filters do in the <link
3941     linkend="filter-file">filter file chapter</link>.
3942    </para>
3943   </listitem>
3944  </varlistentry>
3945
3946  <varlistentry>
3947   <term>Example usage (with filters from the distribution <filename>default.filter</filename> file).
3948   See <link linkend="PREDEFINED-FILTERS">the Predefined Filters section</link> for
3949   more explanation on each:</term>
3950   <listitem>
3951    <para>
3952     <anchor id="filter-js-annoyances">
3953    </para>
3954     <screen>+filter{js-annoyances}       # Get rid of particularly annoying JavaScript abuse.</screen>
3955    <para>
3956     <anchor id="filter-js-events">
3957    </para>
3958     <screen>+filter{js-events}           # Kill JavaScript event bindings and timers (Radically destructive! Only for extra nasty sites).</screen>
3959    <para>
3960     <anchor id="filter-html-annoyances">
3961    </para>
3962     <screen>+filter{html-annoyances}     # Get rid of particularly annoying HTML abuse.</screen>
3963    <para>
3964     <anchor id="filter-content-cookies">
3965    </para>
3966     <screen>+filter{content-cookies}     # Kill cookies that come in the HTML or JS content.</screen>
3967    <para>
3968     <anchor id="filter-refresh-tags">
3969    </para>
3970     <screen>+filter{refresh-tags}        # Kill automatic refresh tags if refresh time is larger than 9 seconds.</screen>
3971    <para>
3972     <anchor id="filter-unsolicited-popups">
3973    </para>
3974     <screen>+filter{unsolicited-popups}  # Disable only unsolicited pop-up windows.</screen>
3975    <para>
3976     <anchor id="filter-all-popups">
3977    </para>
3978     <screen>+filter{all-popups}          # Kill all popups in JavaScript and HTML.</screen>
3979    <para>
3980     <anchor id="filter-img-reorder">
3981    </para>
3982     <screen>+filter{img-reorder}         # Reorder attributes in &lt;img&gt; tags to make the banners-by-* filters more effective.</screen>
3983    <para>
3984     <anchor id="filter-banners-by-size">
3985    </para>
3986     <screen>+filter{banners-by-size}     # Kill banners by size.</screen>
3987    <para>
3988     <anchor id="filter-banners-by-link">
3989    </para>
3990     <screen>+filter{banners-by-link}     # Kill banners by their links to known clicktrackers.</screen>
3991    <para>
3992     <anchor id="filter-webbugs">
3993    </para>
3994     <screen>+filter{webbugs}             # Squish WebBugs (1x1 invisible GIFs used for user tracking).</screen>
3995    <para>
3996     <anchor id="filter-tiny-textforms">
3997    </para>
3998     <screen>+filter{tiny-textforms}      # Extend those tiny textareas up to 40x80 and kill the hard wrap.</screen>
3999    <para>
4000     <anchor id="filter-jumping-windows">
4001    </para>
4002     <screen>+filter{jumping-windows}     # Prevent windows from resizing and moving themselves.</screen>
4003    <para>
4004     <anchor id="filter-frameset-borders">
4005    </para>
4006     <screen>+filter{frameset-borders}    # Give frames a border and make them resizable.</screen>
4007    <para>
4008     <anchor id="filter-iframes">
4009    </para>
4010     <screen>+filter{iframes}             # Removes all detected iframes. Should only be enabled for individual sites.</screen>
4011    <para>
4012     <anchor id="filter-demoronizer">
4013    </para>
4014     <screen>+filter{demoronizer}         # Fix MS's non-standard use of standard charsets.</screen>
4015    <para>
4016     <anchor id="filter-shockwave-flash">
4017    </para>
4018     <screen>+filter{shockwave-flash}     # Kill embedded Shockwave Flash objects.</screen>
4019    <para>
4020     <anchor id="filter-quicktime-kioskmode">
4021    </para>
4022     <screen>+filter{quicktime-kioskmode} # Make Quicktime movies saveable.</screen>
4023    <para>
4024     <anchor id="filter-fun">
4025    </para>
4026     <screen>+filter{fun}                 # Text replacements for subversive browsing fun!</screen>
4027    <para>
4028     <anchor id="filter-crude-parental">
4029    </para>
4030     <screen>+filter{crude-parental}      # Crude parental filtering. Note that this filter doesn't work reliably.</screen>
4031    <para>
4032     <anchor id="filter-ie-exploits">
4033    </para>
4034     <screen>+filter{ie-exploits}         # Disable some known Internet Explorer bug exploits.</screen>
4035    <para>
4036     <anchor id="filter-site-specifics">
4037    </para>
4038     <screen>+filter{site-specifics}      # Cure for site-specific problems. Don't apply generally!</screen>
4039    <para>
4040     <anchor id="filter-no-ping">
4041    </para>
4042     <screen>+filter{no-ping}             # Removes non-standard ping attributes in &lt;a&gt; and &lt;area&gt; tags.</screen>
4043    <para>
4044     <anchor id="filter-google">
4045    </para>
4046     <screen>+filter{google}              # CSS-based block for Google text ads. Also removes a width limitation and the toolbar advertisement.</screen>
4047    <para>
4048     <anchor id="filter-yahoo">
4049    </para>
4050     <screen>+filter{yahoo}               # CSS-based block for Yahoo text ads. Also removes a width limitation.</screen>
4051    <para>
4052     <anchor id="filter-msn">
4053    </para>
4054     <screen>+filter{msn}                 # CSS-based block for MSN text ads. Also removes tracking URLs and a width limitation.</screen>
4055    <para>
4056     <anchor id="filter-blogspot">
4057    </para>
4058     <screen>+filter{blogspot}            # Cleans up some Blogspot blogs. Read the fine print before using this.</screen>
4059   </listitem>
4060  </varlistentry>
4061 </variablelist>
4062 </sect3>
4063
4064
4065 <!--   ~~~~~       New section      ~~~~~     -->
4066 <sect3 renderas="sect4" id="force-text-mode">
4067 <title>force-text-mode</title>
4068 <!--
4069 new action
4070 -->
4071 <variablelist>
4072  <varlistentry>
4073   <term>Typical use:</term>
4074   <listitem>
4075    <para>Force <application>Privoxy</application> to treat a document as if it was in some kind of <emphasis>text</emphasis> format.   </para>
4076   </listitem>
4077  </varlistentry>
4078
4079  <varlistentry>
4080   <term>Effect:</term>
4081   <listitem>
4082    <para>
4083     Declares a document as text, even if the <quote>Content-Type:</quote> isn't detected as such.
4084    </para>
4085   </listitem>
4086  </varlistentry>
4087
4088  <varlistentry>
4089   <term>Type:</term>
4090   <!-- Boolean, Parameterized, Multi-value -->
4091   <listitem>
4092    <para>Boolean.</para>
4093   </listitem>
4094  </varlistentry>
4095
4096  <varlistentry>
4097   <term>Parameter:</term>
4098   <listitem>
4099    <para>
4100     N/A
4101    </para>
4102   </listitem>
4103  </varlistentry>
4104
4105  <varlistentry>
4106   <term>Notes:</term>
4107   <listitem>
4108    <para>
4109     As explained <literal><link linkend="filter">above</link></literal>,
4110     <application>Privoxy</application> tries to only filter files that are
4111     in some kind of text format. The same restrictions apply to
4112     <literal><link linkend="content-type-overwrite">content-type-overwrite</link></literal>.
4113     <literal>force-text-mode</literal> declares a document as text,
4114     without looking at the <quote>Content-Type:</quote> first.
4115    </para>
4116    <warning>
4117     <para>
4118      Think twice before activating this action. Filtering binary data
4119      with regular expressions can cause file damage.
4120     </para>
4121    </warning>
4122   </listitem>
4123  </varlistentry>
4124
4125  <varlistentry>
4126   <term>Example usage:</term>
4127   <listitem>
4128      <screen>
4129 +force-text-mode
4130      </screen>
4131   </listitem>
4132  </varlistentry>
4133 </variablelist>
4134 </sect3>
4135
4136
4137 <!--   ~~~~~       New section      ~~~~~     -->
4138 <sect3 renderas="sect4" id="forward-override">
4139 <title>forward-override</title>
4140 <!--
4141 new action
4142 -->
4143 <variablelist>
4144  <varlistentry>
4145   <term>Typical use:</term>
4146   <listitem>
4147    <para>Change the forwarding settings based on User-Agent or request origin</para>
4148   </listitem>
4149  </varlistentry>
4150
4151  <varlistentry>
4152   <term>Effect:</term>
4153   <listitem>
4154    <para>
4155     Overrules the forward directives in the configuration file.
4156    </para>
4157   </listitem>
4158  </varlistentry>
4159
4160  <varlistentry>
4161   <term>Type:</term>
4162   <!-- Boolean, Parameterized, Multi-value -->
4163   <listitem>
4164    <para>Parameterized.</para>
4165   </listitem>
4166  </varlistentry>
4167
4168  <varlistentry>
4169   <term>Parameter:</term>
4170   <listitem>
4171    <itemizedlist>
4172     <listitem>
4173      <para><quote>forward .</quote> to use a direct connection without any additional proxies.</para>
4174     </listitem>
4175     <listitem>
4176      <para>
4177       <quote>forward 127.0.0.1:8123</quote> to use the HTTP proxy listening at 127.0.0.1 port 8123.
4178      </para>
4179     </listitem>
4180     <listitem>
4181      <para>
4182       <quote>forward-socks4a 127.0.0.1:9050 .</quote> to use the socks4a proxy listening at
4183       127.0.0.1 port 9050. Replace <quote>forward-socks4a</quote> with <quote>forward-socks4</quote>
4184       to use a socks4 connection  (with local DNS resolution) instead, use <quote>forward-socks5</quote>
4185       for socks5 connections (with remote DNS resolution).
4186      </para>
4187     </listitem>
4188     <listitem>
4189      <para>
4190       <quote>forward-socks4a 127.0.0.1:9050 proxy.example.org:8000</quote> to use the socks4a proxy
4191       listening at 127.0.0.1 port 9050 to reach the HTTP proxy listening at proxy.example.org port 8000.
4192       Replace <quote>forward-socks4a</quote> with <quote>forward-socks4</quote> to use a socks4 connection
4193       (with local DNS resolution) instead, use <quote>forward-socks5</quote>
4194       for socks5 connections (with remote DNS resolution).
4195      </para>
4196     </listitem>
4197     <listitem>
4198      <para>
4199       <quote>forward-webserver 127.0.0.1:80</quote> to use the HTTP
4200       server listening at 127.0.0.1 port 80 without adjusting the
4201       request headers.
4202      </para>
4203      <para>
4204       This makes it more convenient to use Privoxy to make
4205       existing websites available as onion services as well.
4206      </para>
4207      <para>
4208       Many websites serve content with hardcoded URLs and
4209       can't be easily adjusted to change the domain based
4210       on the one used by the client.
4211      </para>
4212      <para>
4213       Putting Privoxy between Tor and the webserver (or an stunnel
4214       that forwards to the webserver) allows to rewrite headers and
4215       content to make client and server happy at the same time.
4216      </para>
4217      <para>
4218       Using Privoxy for webservers that are only reachable through
4219       onion addresses and whose location is supposed to be secret
4220       is not recommended and should not be necessary anyway.
4221      </para>
4222     </listitem>
4223    </itemizedlist>
4224   </listitem>
4225  </varlistentry>
4226
4227  <varlistentry>
4228   <term>Notes:</term>
4229   <listitem>
4230    <para>
4231     This action takes parameters similar to the
4232     <link linkend="forwarding">forward</link> directives in the configuration
4233     file, but without the URL pattern. It can be used as replacement, but normally it's only
4234     used in cases where matching based on the request URL isn't sufficient.
4235    </para>
4236    <warning>
4237     <para>
4238      Please read the description for the <link linkend="forwarding">forward</link> directives before
4239      using this action. Forwarding to the wrong people will reduce your privacy and increase the
4240      chances of man-in-the-middle attacks.
4241     </para>
4242     <para>
4243      If the ports are missing or invalid, default values will be used. This might change
4244      in the future and you shouldn't rely on it. Otherwise incorrect syntax causes Privoxy
4245      to exit. Due to design limitations, invalid parameter syntax isn't detected until the
4246      action is used the first time.
4247     </para>
4248     <para>
4249      Use the <ulink url="http://config.privoxy.org/show-url-info">show-url-info CGI page</ulink>
4250      to verify that your forward settings do what you thought the do.
4251     </para>
4252    </warning>
4253   </listitem>
4254  </varlistentry>
4255
4256  <varlistentry>
4257   <term>Example usage:</term>
4258   <listitem>
4259      <screen>
4260 # Use an ssh tunnel for requests previously tagged as
4261 # <quote>User-Agent: fetch libfetch/2.0</quote> and make sure
4262 # resuming downloads continues to work.
4263 #
4264 # This way you can continue to use Tor for your normal browsing,
4265 # without overloading the Tor network with your FreeBSD ports updates
4266 # or downloads of bigger files like ISOs.
4267 #
4268 # Note that HTTP headers are easy to fake and therefore their
4269 # values are as (un)trustworthy as your clients and users.
4270 {+forward-override{forward-socks5 10.0.0.2:2222 .} \
4271  -hide-if-modified-since      \
4272  -overwrite-last-modified     \
4273 }
4274 TAG:^User-Agent: fetch libfetch/2\.0$
4275      </screen>
4276   </listitem>
4277  </varlistentry>
4278 </variablelist>
4279 </sect3>
4280
4281
4282 <!--   ~~~~~       New section      ~~~~~     -->
4283 <sect3 renderas="sect4" id="handle-as-empty-document">
4284 <title>handle-as-empty-document</title>
4285 <!--
4286 new action
4287 -->
4288 <variablelist>
4289  <varlistentry>
4290   <term>Typical use:</term>
4291   <listitem>
4292    <para>Mark URLs that should be replaced by empty documents <emphasis>if they get blocked</emphasis></para>
4293   </listitem>
4294  </varlistentry>
4295
4296  <varlistentry>
4297   <term>Effect:</term>
4298   <listitem>
4299    <para>
4300     This action alone doesn't do anything noticeable. It just marks URLs.
4301     If the <literal><link linkend="block">block</link></literal> action <emphasis>also applies</emphasis>,
4302     the presence or absence of this mark decides whether an HTML <quote>BLOCKED</quote>
4303     page, or an empty document will be sent to the client as a substitute for the blocked content.
4304     The <emphasis>empty</emphasis> document isn't literally empty, but actually contains a single space.
4305    </para>
4306   </listitem>
4307  </varlistentry>
4308
4309  <varlistentry>
4310   <term>Type:</term>
4311   <!-- Boolean, Parameterized, Multi-value -->
4312   <listitem>
4313    <para>Boolean.</para>
4314   </listitem>
4315  </varlistentry>
4316
4317  <varlistentry>
4318   <term>Parameter:</term>
4319   <listitem>
4320    <para>
4321     N/A
4322    </para>
4323   </listitem>
4324  </varlistentry>
4325
4326  <varlistentry>
4327   <term>Notes:</term>
4328   <listitem>
4329    <para>
4330     Some browsers complain about syntax errors if JavaScript documents
4331     are blocked with <application>Privoxy's</application>
4332     default HTML page; this option can be used to silence them.
4333     And of course this action can also be used to eliminate the &my-app;
4334     BLOCKED message in frames.
4335    </para>
4336    <para>
4337     The content type for the empty document can be specified with
4338     <literal><link linkend="content-type-overwrite">content-type-overwrite{}</link></literal>,
4339     but usually this isn't necessary.
4340    </para>
4341   </listitem>
4342  </varlistentry>
4343
4344  <varlistentry>
4345   <term>Example usage:</term>
4346   <listitem>
4347      <screen># Block all documents on example.org that end with ".js",
4348 # but send an empty document instead of the usual HTML message.
4349 {+block{Blocked JavaScript} +handle-as-empty-document}
4350 example.org/.*\.js$
4351      </screen>
4352   </listitem>
4353  </varlistentry>
4354 </variablelist>
4355 </sect3>
4356
4357
4358 <!--   ~~~~~       New section      ~~~~~     -->
4359 <sect3 renderas="sect4" id="handle-as-image">
4360 <title>handle-as-image</title>
4361
4362 <variablelist>
4363  <varlistentry>
4364   <term>Typical use:</term>
4365   <listitem>
4366    <para>Mark URLs as belonging to images (so they'll be replaced by images <emphasis>if they do get blocked</emphasis>, rather than HTML pages)</para>
4367   </listitem>
4368  </varlistentry>
4369
4370  <varlistentry>
4371   <term>Effect:</term>
4372   <listitem>
4373    <para>
4374     This action alone doesn't do anything noticeable. It just marks URLs as images.
4375     If the <literal><link linkend="block">block</link></literal> action <emphasis>also applies</emphasis>,
4376     the presence or absence of this mark decides whether an HTML <quote>blocked</quote>
4377     page, or a replacement image (as determined by the <literal><link
4378     linkend="set-image-blocker">set-image-blocker</link></literal> action) will be sent to the
4379     client as a substitute for the blocked content.
4380    </para>
4381   </listitem>
4382  </varlistentry>
4383
4384  <varlistentry>
4385   <term>Type:</term>
4386   <!-- Boolean, Parameterized, Multi-value -->
4387   <listitem>
4388    <para>Boolean.</para>
4389   </listitem>
4390  </varlistentry>
4391
4392  <varlistentry>
4393   <term>Parameter:</term>
4394   <listitem>
4395    <para>
4396     N/A
4397    </para>
4398   </listitem>
4399  </varlistentry>
4400
4401  <varlistentry>
4402   <term>Notes:</term>
4403   <listitem>
4404    <para>
4405     The below generic example section is actually part of <filename>default.action</filename>.
4406     It marks all URLs with well-known image file name extensions as images and should
4407     be left intact.
4408    </para>
4409    <para>
4410     Users will probably only want to use the handle-as-image action in conjunction with
4411     <literal><link linkend="block">block</link></literal>, to block sources of banners, whose URLs don't
4412     reflect the file type, like in the second example section.
4413    </para>
4414    <para>
4415     Note that you cannot treat HTML pages as images in most cases. For instance, (in-line) ad
4416     frames require an HTML page to be sent, or they won't display properly.
4417     Forcing <literal>handle-as-image</literal> in this situation will not replace the
4418     ad frame with an image, but lead to error messages.
4419    </para>
4420   </listitem>
4421  </varlistentry>
4422
4423  <varlistentry>
4424   <term>Example usage (sections):</term>
4425   <listitem>
4426      <screen># Generic image extensions:
4427 #
4428 {+handle-as-image}
4429 /.*\.(gif|jpg|jpeg|png|bmp|ico)$
4430
4431 # These don't look like images, but they're banners and should be
4432 # blocked as images:
4433 #
4434 {+block{Nasty banners.} +handle-as-image}
4435 nasty-banner-server.example.com/junk.cgi\?output=trash
4436 </screen>
4437   </listitem>
4438  </varlistentry>
4439 </variablelist>
4440 </sect3>
4441
4442
4443 <!--   ~~~~~       New section      ~~~~~     -->
4444 <sect3 renderas="sect4" id="hide-accept-language">
4445 <title>hide-accept-language</title>
4446 <!--
4447 new action
4448 -->
4449 <variablelist>
4450  <varlistentry>
4451   <term>Typical use:</term>
4452   <listitem>
4453    <para>Pretend to use different language settings.</para>
4454   </listitem>
4455  </varlistentry>
4456
4457  <varlistentry>
4458   <term>Effect:</term>
4459   <listitem>
4460    <para>
4461     Deletes or replaces the <quote>Accept-Language:</quote> HTTP header in client requests.
4462    </para>
4463   </listitem>
4464  </varlistentry>
4465
4466  <varlistentry>
4467   <term>Type:</term>
4468   <!-- Boolean, Parameterized, Multi-value -->
4469   <listitem>
4470    <para>Parameterized.</para>
4471   </listitem>
4472  </varlistentry>
4473
4474  <varlistentry>
4475   <term>Parameter:</term>
4476   <listitem>
4477    <para>
4478     Keyword: <quote>block</quote>, or any user defined value.
4479    </para>
4480   </listitem>
4481  </varlistentry>
4482
4483  <varlistentry>
4484   <term>Notes:</term>
4485   <listitem>
4486    <para>
4487     Faking the browser's language settings can be useful to make a
4488     foreign User-Agent set with
4489     <literal><link linkend="hide-user-agent">hide-user-agent</link></literal>
4490     more believable.
4491    </para>
4492    <para>
4493     However some sites with content in different languages check the
4494     <quote>Accept-Language:</quote> to decide which one to take by default.
4495     Sometimes it isn't possible to later switch to another language without
4496     changing the <quote>Accept-Language:</quote> header first.
4497    </para>
4498    <para>
4499     Therefore it's a good idea to either only change the
4500     <quote>Accept-Language:</quote> header to languages you understand,
4501     or to languages that aren't wide spread.
4502    </para>
4503    <para>
4504     Before setting the <quote>Accept-Language:</quote> header
4505     to a rare language, you should consider that it helps to
4506     make your requests unique and thus easier to trace.
4507     If you don't plan to change this header frequently,
4508     you should stick to a common language.
4509    </para>
4510   </listitem>
4511  </varlistentry>
4512
4513  <varlistentry>
4514   <term>Example usage (section):</term>
4515   <listitem>
4516      <screen># Pretend to use Canadian language settings.
4517 {+hide-accept-language{en-ca} \
4518 +hide-user-agent{Mozilla/5.0 (X11; U; OpenBSD i386; en-CA; rv:1.8.0.4) Gecko/20060628 Firefox/1.5.0.4} \
4519 }
4520 /   </screen>
4521   </listitem>
4522  </varlistentry>
4523 </variablelist>
4524 </sect3>
4525
4526
4527 <!--   ~~~~~       New section      ~~~~~     -->
4528 <sect3 renderas="sect4" id="hide-content-disposition">
4529 <title>hide-content-disposition</title>
4530 <!--
4531 new action
4532 -->
4533 <variablelist>
4534  <varlistentry>
4535   <term>Typical use:</term>
4536   <listitem>
4537    <para>Prevent download menus for content you prefer to view inside the browser.</para>
4538   </listitem>
4539  </varlistentry>
4540
4541  <varlistentry>
4542   <term>Effect:</term>
4543   <listitem>
4544    <para>
4545     Deletes or replaces the <quote>Content-Disposition:</quote> HTTP header set by some servers.
4546    </para>
4547   </listitem>
4548  </varlistentry>
4549
4550  <varlistentry>
4551   <term>Type:</term>
4552   <!-- Boolean, Parameterized, Multi-value -->
4553   <listitem>
4554    <para>Parameterized.</para>
4555   </listitem>
4556  </varlistentry>
4557
4558  <varlistentry>
4559   <term>Parameter:</term>
4560   <listitem>
4561    <para>
4562     Keyword: <quote>block</quote>, or any user defined value.
4563    </para>
4564   </listitem>
4565  </varlistentry>
4566
4567  <varlistentry>
4568   <term>Notes:</term>
4569   <listitem>
4570    <para>
4571     Some servers set the <quote>Content-Disposition:</quote> HTTP header for
4572     documents they assume you want to save locally before viewing them.
4573     The <quote>Content-Disposition:</quote> header contains the file name
4574     the browser is supposed to use by default.
4575    </para>
4576    <para>
4577     In most browsers that understand this header, it makes it impossible to
4578     <emphasis>just view</emphasis> the document, without downloading it first,
4579     even if it's just a simple text file or an image.
4580    </para>
4581    <para>
4582     Removing the <quote>Content-Disposition:</quote> header helps
4583     to prevent this annoyance, but some browsers additionally check the
4584     <quote>Content-Type:</quote> header, before they decide if they can
4585     display a document without saving it first. In these cases, you have
4586     to change this header as well, before the browser stops displaying
4587     download menus.
4588    </para>
4589    <para>
4590     It is also possible to change the server's file name suggestion
4591     to another one, but in most cases it isn't worth the time to set
4592     it up.
4593    </para>
4594    <para>
4595     This action will probably be removed in the future,
4596     use server-header filters instead.
4597    </para>
4598   </listitem>
4599  </varlistentry>
4600
4601  <varlistentry>
4602   <term>Example usage:</term>
4603   <listitem>
4604      <screen># Disarm the download link in Sourceforge's patch tracker
4605 { -filter \
4606  +content-type-overwrite{text/plain}\
4607  +hide-content-disposition{block} }
4608  .sourceforge.net/tracker/download\.php</screen>
4609   </listitem>
4610  </varlistentry>
4611 </variablelist>
4612 </sect3>
4613
4614
4615 <!--   ~~~~~       New section      ~~~~~     -->
4616 <sect3 renderas="sect4" id="hide-if-modified-since">
4617 <title>hide-if-modified-since</title>
4618 <!--
4619 new action
4620 -->
4621 <variablelist>
4622  <varlistentry>
4623   <term>Typical use:</term>
4624   <listitem>
4625    <para>Prevent yet another way to track the user's steps between sessions.</para>
4626   </listitem>
4627  </varlistentry>
4628
4629  <varlistentry>
4630   <term>Effect:</term>
4631   <listitem>
4632    <para>
4633     Deletes the <quote>If-Modified-Since:</quote> HTTP client header or modifies its value.
4634    </para>
4635   </listitem>
4636  </varlistentry>
4637
4638  <varlistentry>
4639   <term>Type:</term>
4640   <!-- Boolean, Parameterized, Multi-value -->
4641   <listitem>
4642    <para>Parameterized.</para>
4643   </listitem>
4644  </varlistentry>
4645
4646  <varlistentry>
4647   <term>Parameter:</term>
4648   <listitem>
4649    <para>
4650     Keyword: <quote>block</quote>, or a user defined value that specifies a range of hours.
4651    </para>
4652   </listitem>
4653  </varlistentry>
4654
4655  <varlistentry>
4656   <term>Notes:</term>
4657   <listitem>
4658    <para>
4659     Removing this header is useful for filter testing, where you want to force a real
4660     reload instead of getting status code <quote>304</quote>, which would cause the
4661     browser to use a cached copy of the page.
4662    </para>
4663    <para>
4664     Instead of removing the header, <literal>hide-if-modified-since</literal> can
4665     also add or subtract a random amount of time to/from the header's value.
4666     You specify a range of minutes where the random factor should be chosen from and
4667     <application>Privoxy</application> does the rest. A negative value means
4668     subtracting, a positive value adding.
4669    </para>
4670    <para>
4671     Randomizing the value of the <quote>If-Modified-Since:</quote> makes
4672     it less likely that the server can use the time as a cookie replacement,
4673     but you will run into caching problems if the random range is too high.
4674    </para>
4675    <para>
4676     It is a good idea to only use a small negative value and let
4677     <literal><link linkend="overwrite-last-modified">overwrite-last-modified</link></literal>
4678     handle the greater changes.
4679    </para>
4680    <para>
4681     It is also recommended to use this action together with
4682     <literal><link linkend="crunch-if-none-match">crunch-if-none-match</link></literal>,
4683     otherwise it's more or less pointless.
4684    </para>
4685   </listitem>
4686  </varlistentry>
4687
4688  <varlistentry>
4689   <term>Example usage (section):</term>
4690   <listitem>
4691      <screen># Let the browser revalidate but make tracking based on the time less likely.
4692 {+hide-if-modified-since{-60} \
4693  +overwrite-last-modified{randomize} \
4694  +crunch-if-none-match}
4695 /</screen>
4696   </listitem>
4697  </varlistentry>
4698 </variablelist>
4699 </sect3>
4700
4701
4702 <!--   ~~~~~       New section      ~~~~~     -->
4703 <sect3 renderas="sect4" id="hide-from-header">
4704 <title>hide-from-header</title>
4705
4706 <variablelist>
4707  <varlistentry>
4708   <term>Typical use:</term>
4709   <listitem>
4710    <para>Keep your (old and ill) browser from telling web servers your email address</para>
4711   </listitem>
4712  </varlistentry>
4713
4714  <varlistentry>
4715   <term>Effect:</term>
4716   <listitem>
4717    <para>
4718     Deletes any existing <quote>From:</quote> HTTP header, or replaces it with the
4719     specified string.
4720    </para>
4721   </listitem>
4722  </varlistentry>
4723
4724  <varlistentry>
4725   <term>Type:</term>
4726   <!-- Boolean, Parameterized, Multi-value -->
4727   <listitem>
4728    <para>Parameterized.</para>
4729   </listitem>
4730  </varlistentry>
4731
4732  <varlistentry>
4733   <term>Parameter:</term>
4734   <listitem>
4735    <para>
4736     Keyword: <quote>block</quote>, or any user defined value.
4737    </para>
4738   </listitem>
4739  </varlistentry>
4740
4741  <varlistentry>
4742   <term>Notes:</term>
4743   <listitem>
4744    <para>
4745     The keyword <quote>block</quote> will completely remove the header
4746     (not to be confused with the <literal><link linkend="block">block</link></literal>
4747     action).
4748    </para>
4749    <para>
4750     Alternately, you can specify any value you prefer to be sent to the web
4751     server. If you do, it is a matter of fairness not to use any address that
4752     is actually used by a real person.
4753    </para>
4754    <para>
4755     This action is rarely needed, as modern web browsers don't send
4756     <quote>From:</quote> headers anymore.
4757    </para>
4758   </listitem>
4759  </varlistentry>
4760
4761  <varlistentry>
4762   <term>Example usage:</term>
4763   <listitem>
4764     <screen>+hide-from-header{block}</screen>
4765     <para>or</para>
4766     <screen>+hide-from-header{spam-me-senseless@sittingduck.example.com}</screen>
4767   </listitem>
4768  </varlistentry>
4769 </variablelist>
4770 </sect3>
4771
4772
4773 <!--   ~~~~~       New section      ~~~~~     -->
4774 <sect3 renderas="sect4" id="hide-referrer">
4775 <title>hide-referrer</title>
4776 <anchor id="hide-referer">
4777 <variablelist>
4778  <varlistentry>
4779   <term>Typical use:</term>
4780   <listitem>
4781    <para>Conceal which link you followed to get to a particular site</para>
4782   </listitem>
4783  </varlistentry>
4784
4785  <varlistentry>
4786   <term>Effect:</term>
4787   <listitem>
4788    <para>
4789     Deletes the <quote>Referer:</quote> (sic) HTTP header from the client request,
4790     or replaces it with a forged one.
4791    </para>
4792   </listitem>
4793  </varlistentry>
4794
4795  <varlistentry>
4796   <term>Type:</term>
4797   <!-- Boolean, Parameterized, Multi-value -->
4798   <listitem>
4799    <para>Parameterized.</para>
4800   </listitem>
4801  </varlistentry>
4802
4803  <varlistentry>
4804   <term>Parameter:</term>
4805   <listitem>
4806    <itemizedlist>
4807     <listitem>
4808      <para><quote>conditional-block</quote> to delete the header completely if the host has changed.</para>
4809     </listitem>
4810     <listitem>
4811      <para><quote>conditional-forge</quote> to forge the header if the host has changed.</para>
4812     </listitem>
4813     <listitem>
4814      <para><quote>block</quote> to delete the header unconditionally.</para>
4815     </listitem>
4816     <listitem>
4817      <para><quote>forge</quote> to pretend to be coming from the homepage of the server we are talking to.</para>
4818     </listitem>
4819     <listitem>
4820      <para>Any other string to set a user defined referrer.</para>
4821     </listitem>
4822    </itemizedlist>
4823   </listitem>
4824  </varlistentry>
4825
4826  <varlistentry>
4827   <term>Notes:</term>
4828   <listitem>
4829    <para>
4830     <literal>conditional-block</literal> is the only parameter,
4831     that isn't easily detected in the server's log file. If it blocks the
4832     referrer, the request will look like the visitor used a bookmark or
4833     typed in the address directly.
4834    </para>
4835    <para>
4836     Leaving the referrer unmodified for requests on the same host
4837     allows the server owner to see the visitor's <quote>click path</quote>,
4838     but in most cases she could also get that information by comparing
4839     other parts of the log file: for example the User-Agent if it isn't
4840     a very common one, or the user's IP address if it doesn't change between
4841     different requests.
4842    </para>
4843    <para>
4844     Always blocking the referrer, or using a custom one, can lead to
4845     failures on servers that check the referrer before they answer any
4846     requests, in an attempt to prevent their content from being
4847     embedded or linked to elsewhere.
4848    </para>
4849    <para>
4850     Both <literal>conditional-block</literal> and <literal>forge</literal>
4851     will work with referrer checks, as long as content and valid referring page
4852     are on the same host. Most of the time that's the case.
4853    </para>
4854    <para>
4855     <literal>hide-referer</literal> is an alternate spelling of
4856     <literal>hide-referrer</literal> and the two can be can be freely
4857     substituted with each other. (<quote>referrer</quote> is the
4858     correct English spelling, however the HTTP specification has a bug - it
4859     requires it to be spelled as <quote>referer</quote>.)
4860    </para>
4861   </listitem>
4862  </varlistentry>
4863
4864  <varlistentry>
4865   <term>Example usage:</term>
4866   <listitem>
4867      <screen>+hide-referrer{forge}</screen>
4868      <para>or</para>
4869      <screen>+hide-referrer{http://www.yahoo.com/}</screen>
4870   </listitem>
4871  </varlistentry>
4872 </variablelist>
4873 </sect3>
4874
4875
4876 <!--   ~~~~~       New section      ~~~~~     -->
4877 <sect3 renderas="sect4" id="hide-user-agent">
4878 <title>hide-user-agent</title>
4879
4880 <variablelist>
4881  <varlistentry>
4882   <term>Typical use:</term>
4883   <listitem>
4884    <para>Try to conceal your type of browser and client operating system</para>
4885   </listitem>
4886  </varlistentry>
4887
4888  <varlistentry>
4889   <term>Effect:</term>
4890   <listitem>
4891    <para>
4892     Replaces the value of the <quote>User-Agent:</quote> HTTP header
4893     in client requests with the specified value.
4894    </para>
4895   </listitem>
4896  </varlistentry>
4897
4898  <varlistentry>
4899   <term>Type:</term>
4900   <!-- Boolean, Parameterized, Multi-value -->
4901   <listitem>
4902    <para>Parameterized.</para>
4903   </listitem>
4904  </varlistentry>
4905
4906  <varlistentry>
4907   <term>Parameter:</term>
4908   <listitem>
4909    <para>
4910     Any user-defined string.
4911    </para>
4912   </listitem>
4913  </varlistentry>
4914
4915  <varlistentry>
4916   <term>Notes:</term>
4917   <listitem>
4918    <warning>
4919     <para>
4920      This can lead to problems on web sites that depend on looking at this header in
4921      order to customize their content for different browsers (which, by the
4922      way, is <emphasis>NOT</emphasis> the right thing to do: good web sites
4923      work browser-independently).
4924     </para>
4925    </warning>
4926    <para>
4927     Using this action in multi-user setups or wherever different types of
4928     browsers will access the same <application>Privoxy</application> is
4929     <emphasis>not recommended</emphasis>. In single-user, single-browser
4930     setups, you might use it to delete your OS version information from
4931     the headers, because it is an invitation to exploit known bugs for your
4932     OS. It is also occasionally useful to forge this in order to access
4933     sites that won't let you in otherwise (though there may be a good
4934     reason in some cases).
4935    </para>
4936    <para>
4937      More information on known user-agent strings can be found at
4938      <ulink url="http://www.user-agents.org/">http://www.user-agents.org/</ulink>
4939      and
4940      <ulink url="http://en.wikipedia.org/wiki/User_agent">http://en.wikipedia.org/wiki/User_agent</ulink>.
4941    </para>
4942    </listitem>
4943  </varlistentry>
4944
4945  <varlistentry>
4946   <term>Example usage:</term>
4947   <listitem>
4948      <screen>+hide-user-agent{Netscape 6.1 (X11; I; Linux 2.4.18 i686)}</screen>
4949   </listitem>
4950  </varlistentry>
4951 </variablelist>
4952 </sect3>
4953
4954
4955 <!--   ~~~~~       New section      ~~~~~     -->
4956 <sect3 renderas="sect4" id="limit-connect">
4957 <title>limit-connect</title>
4958
4959 <variablelist>
4960  <varlistentry>
4961   <term>Typical use:</term>
4962   <listitem>
4963    <para>Prevent abuse of <application>Privoxy</application> as a TCP proxy relay or disable SSL for untrusted sites</para>
4964   </listitem>
4965  </varlistentry>
4966
4967  <varlistentry>
4968   <term>Effect:</term>
4969   <listitem>
4970    <para>
4971     Specifies to which ports HTTP CONNECT requests are allowable.
4972    </para>
4973   </listitem>
4974  </varlistentry>
4975
4976  <varlistentry>
4977   <term>Type:</term>
4978   <!-- Boolean, Parameterized, Multi-value -->
4979   <listitem>
4980    <para>Parameterized.</para>
4981   </listitem>
4982  </varlistentry>
4983
4984  <varlistentry>
4985   <term>Parameter:</term>
4986   <listitem>
4987    <para>
4988     A comma-separated list of ports or port ranges (the latter using dashes, with the minimum
4989     defaulting to 0 and the maximum to 65K).
4990    </para>
4991   </listitem>
4992  </varlistentry>
4993
4994  <varlistentry>
4995   <term>Notes:</term>
4996   <listitem>
4997    <para>
4998     By default, i.e. if no <literal>limit-connect</literal> action applies,
4999     <application>Privoxy</application> allows HTTP CONNECT requests to all
5000     ports. Use <literal>limit-connect</literal> if fine-grained control
5001     is desired for some or all destinations.
5002    </para>
5003    <para>
5004     The CONNECT methods exists in HTTP to allow access to secure websites
5005     (<quote>https://</quote> URLs) through proxies. It works very simply:
5006     the proxy connects to the server on the specified port, and then
5007     short-circuits its connections to the client and to the remote server.
5008     This means CONNECT-enabled proxies can be used as TCP relays very easily.
5009   </para>
5010   <para>
5011    <application>Privoxy</application> relays HTTPS traffic without seeing
5012    the decoded content. Websites can leverage this limitation to circumvent &my-app;'s
5013    filters. By specifying an invalid port range you can disable HTTPS entirely.
5014   </para>
5015   </listitem>
5016  </varlistentry>
5017
5018  <varlistentry>
5019   <term>Example usages:</term>
5020   <listitem>
5021    <!-- I had trouble getting the spacing to look right in my browser -->
5022    <!-- I probably have the wrong font setup, bollocks. -->
5023    <!-- Apparently the emphasis tag uses a proportional font no matter what -->
5024      <screen>+limit-connect{443}                   # Port 443 is OK.
5025 +limit-connect{80,443}                # Ports 80 and 443 are OK.
5026 +limit-connect{-3, 7, 20-100, 500-}   # Ports less than 3, 7, 20 to 100 and above 500 are OK.
5027 +limit-connect{-}                     # All ports are OK
5028 +limit-connect{,}                     # No HTTPS/SSL traffic is allowed</screen>
5029   </listitem>
5030  </varlistentry>
5031 </variablelist>
5032 </sect3>
5033
5034
5035 <!--   ~~~~~       New section      ~~~~~     -->
5036 <sect3 renderas="sect4" id="limit-cookie-lifetime">
5037 <title>limit-cookie-lifetime</title>
5038
5039 <variablelist>
5040  <varlistentry>
5041   <term>Typical use:</term>
5042   <listitem>
5043    <para>Limit the lifetime of HTTP cookies to a couple of minutes or hours.</para>
5044   </listitem>
5045  </varlistentry>
5046
5047  <varlistentry>
5048   <term>Effect:</term>
5049   <listitem>
5050    <para>
5051     Overwrites the expires field in Set-Cookie server headers if it's above the specified limit.
5052    </para>
5053   </listitem>
5054  </varlistentry>
5055
5056  <varlistentry>
5057   <term>Type:</term>
5058   <!-- Boolean, Parameterized, Multi-value -->
5059   <listitem>
5060    <para>Parameterized.</para>
5061   </listitem>
5062  </varlistentry>
5063
5064  <varlistentry>
5065   <term>Parameter:</term>
5066   <listitem>
5067    <para>
5068     The lifetime limit in minutes, or 0.
5069    </para>
5070   </listitem>
5071  </varlistentry>
5072
5073  <varlistentry>
5074   <term>Notes:</term>
5075   <listitem>
5076    <para>
5077     This action reduces the lifetime of HTTP cookies coming from the
5078     server to the specified number of minutes, starting from the time
5079     the cookie passes Privoxy.
5080    </para>
5081    <para>
5082     Cookies with a lifetime below the limit are not modified.
5083     The lifetime of session cookies is set to the specified limit.
5084    </para>
5085    <para>
5086     The effect of this action depends on the server.
5087    </para>
5088    <para>
5089     In case of servers which refresh their cookies with each response
5090     (or at least frequently), the lifetime limit set by this action
5091     is updated as well.
5092     Thus, a session associated with the cookie continues to work with
5093     this action enabled, as long as a new request is made before the
5094     last limit set is reached.
5095    </para>
5096    <para>
5097     However, some servers send their cookies once, with a lifetime of several
5098     years (the year 2037 is a popular choice), and do not refresh them
5099     until a certain event in the future, for example the user logging out.
5100     In this case this action may limit the absolute lifetime of the session,
5101     even if requests are made frequently.
5102    </para>
5103    <para>
5104     If the parameter is <quote>0</quote>, this action behaves like
5105     <literal><link linkend="session-cookies-only">session-cookies-only</link></literal>.
5106    </para>
5107   </listitem>
5108  </varlistentry>
5109
5110  <varlistentry>
5111   <term>Example usages:</term>
5112   <listitem>
5113      <screen>+limit-cookie-lifetime{60}</screen>
5114   </listitem>
5115  </varlistentry>
5116 </variablelist>
5117 </sect3>
5118
5119 <!--   ~~~~~       New section      ~~~~~     -->
5120 <sect3 renderas="sect4" id="prevent-compression">
5121 <title>prevent-compression</title>
5122
5123 <variablelist>
5124  <varlistentry>
5125   <term>Typical use:</term>
5126   <listitem>
5127    <para>
5128     Ensure that servers send the content uncompressed, so it can be
5129     passed through <literal><link linkend="filter">filter</link></literal>s.
5130    </para>
5131   </listitem>
5132  </varlistentry>
5133
5134  <varlistentry>
5135   <term>Effect:</term>
5136   <listitem>
5137    <para>
5138     Removes the Accept-Encoding header which can be used to ask for compressed transfer.
5139    </para>
5140   </listitem>
5141  </varlistentry>
5142
5143  <varlistentry>
5144   <term>Type:</term>
5145   <!-- Boolean, Parameterized, Multi-value -->
5146   <listitem>
5147    <para>Boolean.</para>
5148   </listitem>
5149  </varlistentry>
5150
5151  <varlistentry>
5152   <term>Parameter:</term>
5153   <listitem>
5154    <para>
5155     N/A
5156    </para>
5157   </listitem>
5158  </varlistentry>
5159
5160  <varlistentry>
5161   <term>Notes:</term>
5162   <listitem>
5163    <para>
5164     More and more websites send their content compressed by default, which
5165     is generally a good idea and saves bandwidth. But the <literal><link
5166     linkend="filter">filter</link></literal> and
5167     <literal><link linkend="deanimate-gifs">deanimate-gifs</link></literal>
5168     actions need access to the uncompressed data.
5169    </para>
5170    <para>
5171     When compiled with zlib support (available since &my-app; 3.0.7), content that should be
5172     filtered is decompressed on-the-fly and you don't have to worry about this action.
5173     If you are using an older &my-app; version, or one that hasn't been compiled with zlib
5174     support, this action can be used to convince the server to send the content uncompressed.
5175    </para>
5176    <para>
5177     Most text-based instances compress very well, the size is seldom decreased by less than 50%,
5178     for markup-heavy instances like news feeds saving more than 90% of the original size isn't
5179     unusual.
5180    </para>
5181    <para>
5182     Not using compression will therefore slow down the transfer, and you should only
5183     enable this action if you really need it. As of &my-app; 3.0.7 it's disabled in all
5184     predefined action settings.
5185    </para>
5186    <para>
5187     Note that some (rare) ill-configured sites don't handle requests for uncompressed
5188     documents correctly. Broken PHP applications tend to send an empty document body,
5189     some IIS versions only send the beginning of the content. If you enable
5190     <literal>prevent-compression</literal> per default, you might want to add
5191     exceptions for those sites. See the example for how to do that.
5192    </para>
5193   </listitem>
5194  </varlistentry>
5195
5196  <varlistentry>
5197   <term>Example usage (sections):</term>
5198   <listitem>
5199     <screen>
5200 # Selectively turn off compression, and enable a filter
5201 #
5202 { +filter{tiny-textforms} +prevent-compression }
5203 # Match only these sites
5204  .google.
5205  sourceforge.net
5206  sf.net
5207
5208 # Or instead, we could set a universal default:
5209 #
5210 { +prevent-compression }
5211  / # Match all sites
5212
5213 # Then maybe make exceptions for broken sites:
5214 #
5215 { -prevent-compression }
5216 .compusa.com/</screen>
5217   </listitem>
5218  </varlistentry>
5219
5220 </variablelist>
5221 </sect3>
5222
5223
5224 <!--   ~~~~~       New section      ~~~~~     -->
5225 <sect3 renderas="sect4" id="overwrite-last-modified">
5226 <title>overwrite-last-modified</title>
5227 <!--
5228 new action
5229 -->
5230 <variablelist>
5231  <varlistentry>
5232   <term>Typical use:</term>
5233   <listitem>
5234    <para>Prevent yet another way to track the user's steps between sessions.</para>
5235   </listitem>
5236  </varlistentry>
5237
5238  <varlistentry>
5239   <term>Effect:</term>
5240   <listitem>
5241    <para>
5242     Deletes the <quote>Last-Modified:</quote> HTTP server header or modifies its value.
5243    </para>
5244   </listitem>
5245  </varlistentry>
5246
5247  <varlistentry>
5248   <term>Type:</term>
5249   <!-- Boolean, Parameterized, Multi-value -->
5250   <listitem>
5251    <para>Parameterized.</para>
5252   </listitem>
5253  </varlistentry>
5254
5255  <varlistentry>
5256   <term>Parameter:</term>
5257   <listitem>
5258    <para>
5259     One of the keywords: <quote>block</quote>, <quote>reset-to-request-time</quote>
5260     and <quote>randomize</quote>
5261    </para>
5262   </listitem>
5263  </varlistentry>
5264
5265  <varlistentry>
5266   <term>Notes:</term>
5267   <listitem>
5268    <para>
5269     Removing the <quote>Last-Modified:</quote> header is useful for filter
5270     testing, where you want to force a real reload instead of getting status
5271     code <quote>304</quote>, which would cause the browser to reuse the old
5272     version of the page.
5273    </para>
5274    <para>
5275     The <quote>randomize</quote> option overwrites the value of the
5276     <quote>Last-Modified:</quote> header with a randomly chosen time
5277     between the original value and the current time. In theory the server
5278     could send each document with a different <quote>Last-Modified:</quote>
5279     header to track visits without using cookies. <quote>Randomize</quote>
5280     makes it impossible and the browser can still revalidate cached documents.
5281    </para>
5282    <para>
5283     <quote>reset-to-request-time</quote> overwrites the value of the
5284     <quote>Last-Modified:</quote> header with the current time. You could use
5285     this option together with
5286     <literal><link linkend="hide-if-modified-since">hide-if-modified-since</link></literal>
5287     to further customize your random range.
5288    </para>
5289    <para>
5290     The preferred parameter here is <quote>randomize</quote>. It is safe
5291     to use, as long as the time settings are more or less correct.
5292     If the server sets the <quote>Last-Modified:</quote> header to the time
5293     of the request, the random range becomes zero and the value stays the same.
5294     Therefore you should later randomize it a second time with
5295     <literal><link linkend="hide-if-modified-since">hided-if-modified-since</link></literal>,
5296     just to be sure.
5297    </para>
5298    <para>
5299     It is also recommended to use this action together with
5300     <literal><link linkend="crunch-if-none-match">crunch-if-none-match</link></literal>.
5301    </para>
5302   </listitem>
5303  </varlistentry>
5304
5305  <varlistentry>
5306   <term>Example usage:</term>
5307   <listitem>
5308      <screen># Let the browser revalidate without being tracked across sessions
5309 { +hide-if-modified-since{-60} \
5310  +overwrite-last-modified{randomize} \
5311  +crunch-if-none-match}
5312 /</screen>
5313   </listitem>
5314  </varlistentry>
5315 </variablelist>
5316 </sect3>
5317
5318
5319 <!--   ~~~~~       New section      ~~~~~     -->
5320 <sect3 renderas="sect4" id="redirect">
5321 <title>redirect</title>
5322 <!--
5323 new action
5324 -->
5325 <variablelist>
5326  <varlistentry>
5327   <term>Typical use:</term>
5328   <listitem>
5329    <para>
5330     Redirect requests to other sites.
5331    </para>
5332   </listitem>
5333  </varlistentry>
5334
5335  <varlistentry>
5336   <term>Effect:</term>
5337   <listitem>
5338    <para>
5339     Convinces the browser that the requested document has been moved
5340     to another location and the browser should get it from there.
5341    </para>
5342   </listitem>
5343  </varlistentry>
5344
5345  <varlistentry>
5346   <term>Type:</term>
5347   <!-- Boolean, Parameterized, Multi-value -->
5348   <listitem>
5349    <para>Parameterized</para>
5350   </listitem>
5351  </varlistentry>
5352
5353  <varlistentry>
5354   <term>Parameter:</term>
5355   <listitem>
5356    <para>
5357     An absolute URL or a single pcrs command.
5358    </para>
5359   </listitem>
5360  </varlistentry>
5361
5362  <varlistentry>
5363   <term>Notes:</term>
5364   <listitem>
5365    <para>
5366     Requests to which this action applies are answered with a
5367     HTTP redirect to URLs of your choosing. The new URL is
5368     either provided as parameter, or derived by applying a
5369     single pcrs command to the original URL.
5370    </para>
5371    <para>
5372     The syntax for pcrs commands is documented in the
5373     <link linkend="filter-file">filter file</link> section.
5374    </para>
5375    <para>
5376     Requests can't be blocked and redirected at the same time,
5377     applying this action together with
5378     <literal><link linkend="block">block</link></literal>
5379     is a configuration error. Currently the request is blocked
5380     and an error message logged, the behavior may change in the
5381     future and result in Privoxy rejecting the action file.
5382    </para>
5383    <para>
5384     This action can be combined with
5385     <literal><link linkend="fast-redirects">fast-redirects{check-decoded-url}</link></literal>
5386     to redirect to a decoded version of a rewritten URL.
5387    </para>
5388    <para>
5389     Use this action carefully, make sure not to create redirection loops
5390     and be aware that using your own redirects might make it
5391     possible to fingerprint your requests.
5392    </para>
5393    <para>
5394     In case of problems with your redirects, or simply to watch
5395     them working, enable <link linkend="DEBUG">debug 128</link>.
5396    </para>
5397   </listitem>
5398  </varlistentry>
5399
5400  <varlistentry>
5401   <term>Example usages:</term>
5402   <listitem>
5403     <screen># Replace example.com's style sheet with another one
5404 { +redirect{http://localhost/css-replacements/example.com.css} }
5405  example.com/stylesheet\.css
5406
5407 # Create a short, easy to remember nickname for a favorite site
5408 # (relies on the browser to accept and forward invalid URLs to &my-app;)
5409 { +redirect{https://www.privoxy.org/user-manual/actions-file.html} }
5410  a
5411
5412 # Always use the expanded view for Undeadly.org articles
5413 # (Note the $ at the end of the URL pattern to make sure
5414 # the request for the rewritten URL isn't redirected as well)
5415 {+redirect{s@$@&amp;mode=expanded@}}
5416 undeadly.org/cgi\?action=article&amp;sid=\d*$
5417
5418 # Redirect Google search requests to MSN
5419 {+redirect{s@^http://[^/]*/search\?q=([^&amp;]*).*@http://search.msn.com/results.aspx?q=$1@}}
5420 .google.com/search
5421
5422 # Redirect MSN search requests to Yahoo
5423 {+redirect{s@^http://[^/]*/results\.aspx\?q=([^&amp;]*).*@http://search.yahoo.com/search?p=$1@}}
5424 search.msn.com//results\.aspx\?q=
5425
5426 # Redirect http://example.com/&amp;bla=fasel&amp;toChange=foo (and any other value but "bar")
5427 # to       http://example.com/&amp;bla=fasel&amp;toChange=bar
5428 #
5429 # The URL pattern makes sure that the following request isn't redirected again.
5430 {+redirect{s@toChange=[^&amp;]+@toChange=bar@}}
5431 example.com/.*toChange=(?!bar)
5432
5433 # Add a shortcut to look up illumos bugs
5434 {+redirect{s@^http://i([0-9]+)/.*@https://www.illumos.org/issues/$1@}}
5435 # Redirected URL = http://i4974/
5436 # Redirect Destination = https://www.illumos.org/issues/4974
5437 i[0-9][0-9][0-9][0-9]*/
5438
5439 # Redirect remote requests for this manual
5440 # to the local version delivered by Privoxy
5441 {+redirect{s@^http://www@http://config@}}
5442 www.privoxy.org/user-manual/</screen>
5443   </listitem>
5444  </varlistentry>
5445
5446 </variablelist>
5447 </sect3>
5448
5449
5450 <!--   ~~~~~       New section      ~~~~~     -->
5451 <sect3 renderas="sect4" id="server-header-filter">
5452 <title>server-header-filter</title>
5453
5454 <variablelist>
5455  <varlistentry>
5456   <term>Typical use:</term>
5457   <listitem>
5458    <para>
5459    Rewrite or remove single server headers.
5460    </para>
5461   </listitem>
5462  </varlistentry>
5463
5464  <varlistentry>
5465   <term>Effect:</term>
5466   <listitem>
5467    <para>
5468     All server headers to which this action applies are filtered on-the-fly
5469     through the specified regular expression based substitutions.
5470    </para>
5471   </listitem>
5472  </varlistentry>
5473
5474  <varlistentry>
5475   <term>Type:</term>
5476   <!-- boolean, parameterized, Multi-value -->
5477   <listitem>
5478    <para>Multi-value.</para>
5479   </listitem>
5480  </varlistentry>
5481
5482  <varlistentry>
5483   <term>Parameter:</term>
5484   <listitem>
5485    <para>
5486     The name of a server-header filter, as defined in one of the
5487     <link linkend="filter-file">filter files</link>.
5488    </para>
5489   </listitem>
5490  </varlistentry>
5491
5492  <varlistentry>
5493   <term>Notes:</term>
5494   <listitem>
5495    <para>
5496     Server-header filters are applied to each header on its own, not to
5497     all at once. This makes it easier to diagnose problems, but on the downside
5498     you can't write filters that only change header x if header y's value is z.
5499     You can do that by using tags though.
5500    </para>
5501    <para>
5502     Server-header filters are executed after the other header actions have finished
5503     and use their output as input.
5504    </para>
5505    <para>
5506     Please refer to the <link linkend="filter-file">filter file chapter</link>
5507     to learn which server-header filters are available by default, and how to
5508     create your own.
5509    </para>
5510  </listitem>
5511  </varlistentry>
5512
5513  <varlistentry>
5514   <term>Example usage (section):</term>
5515   <listitem>
5516      <screen>
5517 {+server-header-filter{html-to-xml}}
5518 example.org/xml-instance-that-is-delivered-as-html
5519
5520 {+server-header-filter{xml-to-html}}
5521 example.org/instance-that-is-delivered-as-xml-but-is-not
5522     </screen>
5523   </listitem>
5524  </varlistentry>
5525
5526 </variablelist>
5527 </sect3>
5528
5529
5530 <!--   ~~~~~       New section      ~~~~~     -->
5531 <sect3 renderas="sect4" id="server-header-tagger">
5532 <title>server-header-tagger</title>
5533
5534 <variablelist>
5535  <varlistentry>
5536   <term>Typical use:</term>
5537   <listitem>
5538    <para>
5539    Enable or disable filters based on the Content-Type header.
5540    </para>
5541   </listitem>
5542  </varlistentry>
5543
5544  <varlistentry>
5545   <term>Effect:</term>
5546   <listitem>
5547    <para>
5548     Server headers to which this action applies are filtered on-the-fly through
5549     the specified regular expression based substitutions, the result is used as
5550     tag.
5551    </para>
5552   </listitem>
5553  </varlistentry>
5554
5555  <varlistentry>
5556   <term>Type:</term>
5557   <!-- boolean, parameterized, Multi-value -->
5558   <listitem>
5559    <para>Multi-value.</para>
5560   </listitem>
5561  </varlistentry>
5562
5563  <varlistentry>
5564   <term>Parameter:</term>
5565   <listitem>
5566    <para>
5567     The name of a server-header tagger, as defined in one of the
5568     <link linkend="filter-file">filter files</link>.
5569    </para>
5570   </listitem>
5571  </varlistentry>
5572
5573  <varlistentry>
5574   <term>Notes:</term>
5575   <listitem>
5576    <para>
5577     Server-header taggers are applied to each header on its own,
5578     and as the header isn't modified, each tagger <quote>sees</quote>
5579     the original.
5580    </para>
5581    <para>
5582     Server-header taggers are executed before all other header actions
5583     that modify server headers. Their tags can be used to control
5584     all of the other server-header actions, the content filters
5585     and the crunch actions (<link linkend="redirect">redirect</link>
5586     and <link linkend="block">block</link>).
5587    </para>
5588    <para>
5589     Obviously crunching based on tags created by server-header taggers
5590     doesn't prevent the request from showing up in the server's log file.
5591    </para>
5592
5593  </listitem>
5594  </varlistentry>
5595
5596  <varlistentry>
5597   <term>Example usage (section):</term>
5598   <listitem>
5599      <screen>
5600 # Tag every request with the content type declared by the server
5601 {+server-header-tagger{content-type}}
5602 /
5603
5604 # If the response has a tag starting with 'image/' enable an external
5605 # filter that only applies to images.
5606 #
5607 # Note that the filter is not available by default, it's just a
5608 # <literal><link linkend="external-filter-syntax">silly example</link></literal>.
5609 {+external-filter{rotate-image} +force-text-mode}
5610 TAG:^image/
5611 </screen>
5612   </listitem>
5613  </varlistentry>
5614
5615 </variablelist>
5616 </sect3>
5617
5618
5619 <!--   ~~~~~       New section      ~~~~~     -->
5620 <sect3 renderas="sect4" id="session-cookies-only">
5621 <title>session-cookies-only</title>
5622
5623 <variablelist>
5624  <varlistentry>
5625   <term>Typical use:</term>
5626   <listitem>
5627    <para>
5628     Allow only temporary <quote>session</quote> cookies (for the current
5629     browser session <emphasis>only</emphasis>).
5630    </para>
5631   </listitem>
5632  </varlistentry>
5633
5634  <varlistentry>
5635   <term>Effect:</term>
5636   <listitem>
5637    <para>
5638     Deletes the <quote>expires</quote> field from <quote>Set-Cookie:</quote>
5639     server headers. Most browsers will not store such cookies permanently and
5640     forget them in between sessions.
5641    </para>
5642   </listitem>
5643  </varlistentry>
5644
5645 <varlistentry>
5646   <term>Type:</term>
5647   <!-- Boolean, Parameterized, Multi-value -->
5648   <listitem>
5649    <para>Boolean.</para>
5650   </listitem>
5651  </varlistentry>
5652
5653  <varlistentry>
5654   <term>Parameter:</term>
5655   <listitem>
5656    <para>
5657     N/A
5658    </para>
5659   </listitem>
5660  </varlistentry>
5661
5662  <varlistentry>
5663   <term>Notes:</term>
5664   <listitem>
5665    <para>
5666     This is less strict than <literal><link linkend="crunch-incoming-cookies">crunch-incoming-cookies</link></literal> /
5667     <literal><link linkend="crunch-outgoing-cookies">crunch-outgoing-cookies</link></literal> and allows you to browse
5668     websites that insist or rely on setting cookies, without compromising your privacy too badly.
5669    </para>
5670    <para>
5671     Most browsers will not permanently store cookies that have been processed by
5672     <literal>session-cookies-only</literal> and will forget about them between sessions.
5673     This makes profiling cookies useless, but won't break sites which require cookies so
5674     that you can log in for transactions. This is generally turned on for all
5675     sites, and is the recommended setting.
5676    </para>
5677    <para>
5678     It makes <emphasis>no sense at all</emphasis> to use <literal>session-cookies-only</literal>
5679     together with <literal><link linkend="crunch-incoming-cookies">crunch-incoming-cookies</link></literal> or
5680     <literal><link linkend="crunch-outgoing-cookies">crunch-outgoing-cookies</link></literal>. If you do, cookies
5681     will be plainly killed.
5682    </para>
5683    <para>
5684     Note that it is up to the browser how it handles such cookies without an <quote>expires</quote>
5685     field. If you use an exotic browser, you might want to try it out to be sure.
5686    </para>
5687    <para>
5688     This setting also has no effect on cookies that may have been stored
5689     previously by the browser before starting <application>Privoxy</application>.
5690     These would have to be removed manually.
5691    </para>
5692    <para>
5693      <application>Privoxy</application> also uses
5694      the <link linkend="filter-content-cookies">content-cookies filter</link>
5695      to block some types of cookies. Content cookies are not effected by
5696      <literal>session-cookies-only</literal>.
5697    </para>
5698   </listitem>
5699  </varlistentry>
5700
5701  <varlistentry>
5702   <term>Example usage:</term>
5703   <listitem>
5704      <screen>+session-cookies-only</screen>
5705   </listitem>
5706  </varlistentry>
5707 </variablelist>
5708 </sect3>
5709
5710
5711 <!--   ~~~~~       New section      ~~~~~     -->
5712 <sect3 renderas="sect4" id="set-image-blocker">
5713 <title>set-image-blocker</title>
5714
5715 <variablelist>
5716  <varlistentry>
5717   <term>Typical use:</term>
5718   <listitem>
5719    <para>Choose the replacement for blocked images</para>
5720   </listitem>
5721  </varlistentry>
5722
5723  <varlistentry>
5724   <term>Effect:</term>
5725   <listitem>
5726    <para>
5727      This action alone doesn't do anything noticeable. If <emphasis>both</emphasis>
5728      <literal><link linkend="block">block</link></literal> <emphasis>and</emphasis> <literal><link
5729      linkend="handle-as-image">handle-as-image</link></literal> <emphasis>also</emphasis>
5730      apply, i.e. if the request is to be blocked as an image,
5731      <emphasis>then</emphasis> the parameter of this action decides what will be
5732      sent as a replacement.
5733    </para>
5734   </listitem>
5735  </varlistentry>
5736
5737  <varlistentry>
5738   <term>Type:</term>
5739   <!-- Boolean, Parameterized, Multi-value -->
5740   <listitem>
5741    <para>Parameterized.</para>
5742   </listitem>
5743  </varlistentry>
5744
5745  <varlistentry>
5746   <term>Parameter:</term>
5747   <listitem>
5748    <itemizedlist>
5749     <listitem>
5750      <para>
5751       <quote>pattern</quote> to send a built-in checkerboard pattern image. The image is visually
5752       decent, scales very well, and makes it obvious where banners were busted.
5753      </para>
5754     </listitem>
5755     <listitem>
5756      <para>
5757       <quote>blank</quote> to send a built-in transparent image. This makes banners disappear
5758       completely, but makes it hard to detect where <application>Privoxy</application> has blocked
5759       images on a given page and complicates troubleshooting if <application>Privoxy</application>
5760       has blocked innocent images, like navigation icons.
5761      </para>
5762     </listitem>
5763     <listitem>
5764      <para>
5765       <quote><replaceable class="parameter">target-url</replaceable></quote> to
5766       send a redirect to <replaceable class="parameter">target-url</replaceable>. You can redirect
5767       to any image anywhere, even in your local filesystem via <quote>file:///</quote> URL.
5768       (But note that not all browsers support redirecting to a local file system).
5769      </para>
5770      <para>
5771       A good application of redirects is to use special <application>Privoxy</application>-built-in
5772       URLs, which send the built-in images, as <replaceable class="parameter">target-url</replaceable>.
5773       This has the same visual effect as specifying <quote>blank</quote> or <quote>pattern</quote> in
5774       the first place, but enables your browser to cache the replacement image, instead of requesting
5775       it over and over again.
5776      </para>
5777     </listitem>
5778    </itemizedlist>
5779   </listitem>
5780  </varlistentry>
5781
5782  <varlistentry>
5783   <term>Notes:</term>
5784   <listitem>
5785    <para>
5786     The URLs for the built-in images are <quote>http://config.privoxy.org/send-banner?type=<replaceable
5787     class="parameter">type</replaceable></quote>, where <replaceable class="parameter">type</replaceable> is
5788     either <quote>blank</quote> or <quote>pattern</quote>.
5789    </para>
5790    <para>
5791     There is a third (advanced) type, called <quote>auto</quote>. It is <emphasis>NOT</emphasis> to be
5792     used in <literal>set-image-blocker</literal>, but meant for use from <link linkend="filter-file">filters</link>.
5793     Auto will select the type of image that would have applied to the referring page, had it been an image.
5794    </para>
5795   </listitem>
5796  </varlistentry>
5797
5798  <varlistentry>
5799   <term>Example usage:</term>
5800   <listitem>
5801    <para>
5802     Built-in pattern:
5803    </para>
5804     <screen>+set-image-blocker{pattern}</screen>
5805    <para>
5806     Redirect to the BSD daemon:
5807    </para>
5808     <screen>+set-image-blocker{http://www.freebsd.org/gifs/dae_up3.gif}</screen>
5809    <para>
5810     Redirect to the built-in pattern for better caching:
5811    </para>
5812     <screen>+set-image-blocker{http://config.privoxy.org/send-banner?type=pattern}</screen>
5813   </listitem>
5814  </varlistentry>
5815 </variablelist>
5816 </sect3>
5817
5818
5819 <!--   ~~~~~       New section      ~~~~~     -->
5820 <sect3 id="summary">
5821 <title>Summary</title>
5822 <para>
5823  Note that many of these actions have the potential to cause a page to
5824  misbehave, possibly even not to display at all. There are many ways
5825  a site designer may choose to design his site, and what HTTP header
5826  content, and other criteria, he may depend on. There is no way to have hard
5827  and fast rules for all sites. See the <link
5828  linkend="ACTIONSANAT">Appendix</link> for a brief example on troubleshooting
5829  actions.
5830 </para>
5831 </sect3>
5832 </sect2>
5833
5834 <!--   ~~~~~       New section      ~~~~~     -->
5835 <sect2 id="aliases">
5836 <title>Aliases</title>
5837 <para>
5838  Custom <quote>actions</quote>, known to <application>Privoxy</application>
5839  as <quote>aliases</quote>, can be defined by combining other actions.
5840  These can in turn be invoked just like the built-in actions.
5841  Currently, an alias name can contain any character except space, tab,
5842  <quote>=</quote>,
5843  <quote>{</quote> and <quote>}</quote>, but we <emphasis>strongly
5844  recommend</emphasis> that you only use <quote>a</quote> to <quote>z</quote>,
5845  <quote>0</quote> to <quote>9</quote>, <quote>+</quote>, and <quote>-</quote>.
5846  Alias names are not case sensitive, and are not required to start with a
5847  <quote>+</quote> or <quote>-</quote> sign, since they are merely textually
5848  expanded.
5849 </para>
5850 <para>
5851  Aliases can be used throughout the actions file, but they <emphasis>must be
5852  defined in a special section at the top of the file!</emphasis>
5853  And there can only be one such section per actions file. Each actions file may
5854  have its own alias section, and the aliases defined in it are only visible
5855  within that file.
5856 </para>
5857 <para>
5858  There are two main reasons to use aliases: One is to save typing for frequently
5859  used combinations of actions, the other one is a gain in flexibility: If you
5860  decide once how you want to handle shops by defining an alias called
5861  <quote>shop</quote>, you can later change your policy on shops in
5862  <emphasis>one</emphasis> place, and your changes will take effect everywhere
5863  in the actions file where the <quote>shop</quote> alias is used. Calling aliases
5864  by their purpose also makes your actions files more readable.
5865 </para>
5866 <para>
5867  Currently, there is one big drawback to using aliases, though:
5868  <application>Privoxy</application>'s built-in web-based action file
5869  editor honors aliases when reading the actions files, but it expands
5870  them before writing. So the effects of your aliases are of course preserved,
5871  but the aliases themselves are lost when you edit sections that use aliases
5872  with it.
5873 </para>
5874
5875 <para>
5876  Now let's define some aliases...
5877 </para>
5878
5879  <screen>
5880  # Useful custom aliases we can use later.
5881  #
5882  # Note the (required!) section header line and that this section
5883  # must be at the top of the actions file!
5884  #
5885  {{alias}}
5886
5887  # These aliases just save typing later:
5888  # (Note that some already use other aliases!)
5889  #
5890  +crunch-all-cookies = +<link linkend="CRUNCH-INCOMING-COOKIES">crunch-incoming-cookies</link> +<link linkend="CRUNCH-OUTGOING-COOKIES">crunch-outgoing-cookies</link>
5891  -crunch-all-cookies = -<link linkend="CRUNCH-INCOMING-COOKIES">crunch-incoming-cookies</link> -<link linkend="CRUNCH-OUTGOING-COOKIES">crunch-outgoing-cookies</link>
5892  +block-as-image      = +block{Blocked image.} +handle-as-image
5893  allow-all-cookies   = -crunch-all-cookies -<link linkend="SESSION-COOKIES-ONLY">session-cookies-only</link> -<link linkend="FILTER-CONTENT-COOKIES">filter{content-cookies}</link>
5894
5895  # These aliases define combinations of actions
5896  # that are useful for certain types of sites:
5897  #
5898  fragile     = -<link linkend="BLOCK">block</link> -<link linkend="FILTER">filter</link> -crunch-all-cookies -<link linkend="FAST-REDIRECTS">fast-redirects</link> -<link linkend="HIDE-REFERER">hide-referrer</link> -<link linkend="PREVENT-COMPRESSION">prevent-compression</link>
5899
5900  shop        = -crunch-all-cookies -<link linkend="FILTER-ALL-POPUPS">filter{all-popups}</link>
5901
5902  # Short names for other aliases, for really lazy people ;-)
5903  #
5904  c0 = +crunch-all-cookies
5905  c1 = -crunch-all-cookies</screen>
5906
5907 <para>
5908  ...and put them to use. These sections would appear in the lower part of an
5909  actions file and define exceptions to the default actions (as specified further
5910  up for the <quote>/</quote> pattern):
5911 </para>
5912
5913  <screen>
5914  # These sites are either very complex or very keen on
5915  # user data and require minimal interference to work:
5916  #
5917  {fragile}
5918  .office.microsoft.com
5919  .windowsupdate.microsoft.com
5920  # Gmail is really mail.google.com, not gmail.com
5921  mail.google.com
5922
5923  # Shopping sites:
5924  # Allow cookies (for setting and retrieving your customer data)
5925  #
5926  {shop}
5927  .quietpc.com
5928  .worldpay.com   # for quietpc.com
5929  mybank.example.com
5930
5931  # These shops require pop-ups:
5932  #
5933  {-filter{all-popups} -filter{unsolicited-popups}}
5934   .dabs.com
5935   .overclockers.co.uk</screen>
5936
5937 <para>
5938  Aliases like <quote>shop</quote> and <quote>fragile</quote> are typically used for
5939  <quote>problem</quote> sites that require more than one action to be disabled
5940  in order to function properly.
5941 </para>
5942 </sect2>
5943 <!--
5944 hal stop here
5945 -->
5946 <!--   ~~~~~       New section      ~~~~~     -->
5947 <sect2 id="act-examples">
5948 <title>Actions Files Tutorial</title>
5949 <para>
5950  The above chapters have shown <link linkend="actions-file">which actions files
5951  there are and how they are organized</link>, how actions are <link
5952  linkend="actions">specified</link> and <link linkend="actions-apply">applied
5953  to URLs</link>, how <link linkend="af-patterns">patterns</link> work, and how to
5954  define and use <link linkend="aliases">aliases</link>. Now, let's look at an
5955  example <filename>match-all.action</filename>, <filename>default.action</filename>
5956  and <filename>user.action</filename> file and see how all these pieces come together:
5957 </para>
5958
5959 <sect3 id="match-all">
5960 <title>match-all.action</title>
5961 <para>
5962  Remember <emphasis>all actions are disabled when matching starts</emphasis>,
5963  so we have to explicitly enable the ones we want.
5964 </para>
5965
5966 <para>
5967  While the <filename>match-all.action</filename> file only contains a
5968  single section, it is probably the most important one. It has only one
5969  pattern, <quote><literal>/</literal></quote>, but this pattern
5970  <link linkend="af-patterns">matches all URLs</link>. Therefore, the set of
5971  actions used in this <quote>default</quote> section <emphasis>will
5972  be applied to all requests as a start</emphasis>. It can  be partly or
5973  wholly overridden by other actions files like <filename>default.action</filename>
5974  and <filename>user.action</filename>, but it will still be largely responsible
5975  for your overall browsing experience.
5976 </para>
5977
5978 <para>
5979  Again, at the start of matching, all actions are disabled, so there is
5980  no need to disable any actions here. (Remember: a <quote>+</quote>
5981  preceding the action name enables the action, a <quote>-</quote> disables!).
5982  Also note how this long line has been made more readable by splitting it into
5983  multiple lines with line continuation.
5984 </para>
5985
5986  <screen>
5987 { \
5988  +<link linkend="CHANGE-X-FORWARDED-FOR">change-x-forwarded-for{block}</link> \
5989  +<link linkend="HIDE-FROM-HEADER">hide-from-header{block}</link> \
5990  +<link linkend="SET-IMAGE-BLOCKER">set-image-blocker{pattern}</link> \
5991 }
5992 / # Match all URLs
5993  </screen>
5994
5995 <para>
5996  The default behavior is now set.
5997 </para>
5998 </sect3>
5999
6000 <sect3 id="default-action">
6001 <title>default.action</title>
6002
6003 <para>
6004  If you aren't a developer, there's no need for you to edit the
6005  <filename>default.action</filename> file. It is maintained by
6006  the &my-app; developers and if you disagree with some of the
6007  sections, you should overrule them in your <filename>user.action</filename>.
6008 </para>
6009
6010 <para>
6011  Understanding the <filename>default.action</filename> file can
6012  help you with your <filename>user.action</filename>, though.
6013 </para>
6014
6015 <para>
6016  The first section in this file is a special section for internal use
6017  that prevents older &my-app; versions from reading the file:
6018 </para>
6019
6020  <screen>
6021 ##########################################################################
6022 # Settings -- Don't change! For internal Privoxy use ONLY.
6023 ##########################################################################
6024 {{settings}}
6025 for-privoxy-version=3.0.11</screen>
6026
6027 <para>
6028  After that comes the (optional) alias section. We'll use the example
6029  section from the above <link linkend="aliases">chapter on aliases</link>,
6030  that also explains why and how aliases are used:
6031 </para>
6032
6033  <screen>
6034 ##########################################################################
6035 # Aliases
6036 ##########################################################################
6037 {{alias}}
6038
6039  # These aliases just save typing later:
6040  # (Note that some already use other aliases!)
6041  #
6042  +crunch-all-cookies = +<link linkend="CRUNCH-INCOMING-COOKIES">crunch-incoming-cookies</link> +<link linkend="CRUNCH-OUTGOING-COOKIES">crunch-outgoing-cookies</link>
6043  -crunch-all-cookies = -<link linkend="CRUNCH-INCOMING-COOKIES">crunch-incoming-cookies</link> -<link linkend="CRUNCH-OUTGOING-COOKIES">crunch-outgoing-cookies</link>
6044  +block-as-image      = +block{Blocked image.} +handle-as-image
6045  mercy-for-cookies   = -crunch-all-cookies -<link linkend="SESSION-COOKIES-ONLY">session-cookies-only</link> -<link linkend="FILTER-CONTENT-COOKIES">filter{content-cookies}</link>
6046
6047  # These aliases define combinations of actions
6048  # that are useful for certain types of sites:
6049  #
6050  fragile     = -<link linkend="BLOCK">block</link> -<link linkend="FILTER">filter</link> -crunch-all-cookies -<link linkend="FAST-REDIRECTS">fast-redirects</link> -<link linkend="HIDE-REFERER">hide-referrer</link>
6051  shop        = -crunch-all-cookies -<link linkend="FILTER-ALL-POPUPS">filter{all-popups}</link></screen>
6052
6053 <para>
6054  The first of our specialized sections is concerned with <quote>fragile</quote>
6055  sites, i.e. sites that require minimum interference, because they are either
6056  very complex or very keen on tracking you (and have mechanisms in place that
6057  make them unusable for people who avoid being tracked). We will use
6058  our pre-defined <literal>fragile</literal> alias instead of stating the list
6059  of actions explicitly:
6060 </para>
6061
6062  <screen>
6063 ##########################################################################
6064 # Exceptions for sites that'll break under the default action set:
6065 ##########################################################################
6066
6067 # "Fragile" Use a minimum set of actions for these sites (see alias above):
6068 #
6069 { fragile }
6070 .office.microsoft.com           # surprise, surprise!
6071 .windowsupdate.microsoft.com
6072 mail.google.com</screen>
6073
6074 <para>
6075  Shopping sites are not as fragile, but they typically
6076  require cookies to log in, and pop-up windows for shopping
6077  carts or item details. Again, we'll use a pre-defined alias:
6078 </para>
6079
6080  <screen>
6081 # Shopping sites:
6082 #
6083 { shop }
6084 .quietpc.com
6085 .worldpay.com   # for quietpc.com
6086 .jungle.com
6087 .scan.co.uk</screen>
6088
6089 <para>
6090  The <literal><link linkend="FAST-REDIRECTS">fast-redirects</link></literal>
6091  action, which may have been enabled in <filename>match-all.action</filename>,
6092  breaks some sites. So disable it for popular sites where we know it misbehaves:
6093 </para>
6094
6095  <screen>
6096 { -<link linkend="FAST-REDIRECTS">fast-redirects</link> }
6097 login.yahoo.com
6098 edit.*.yahoo.com
6099 .google.com
6100 .altavista.com/.*(like|url|link):http
6101 .altavista.com/trans.*urltext=http
6102 .nytimes.com</screen>
6103
6104 <para>
6105  It is important that <application>Privoxy</application> knows which
6106  URLs belong to images, so that <emphasis>if</emphasis> they are to
6107  be blocked, a substitute image can be sent, rather than an HTML page.
6108  Contacting the remote site to find out is not an option, since it
6109  would destroy the loading time advantage of banner blocking, and it
6110  would feed the advertisers information about you. We can mark any
6111  URL as an image with the <literal><link
6112  linkend="handle-as-image">handle-as-image</link></literal> action,
6113  and marking all URLs that end in a known image file extension is a
6114  good start:
6115 </para>
6116
6117  <screen>
6118 ##########################################################################
6119 # Images:
6120 ##########################################################################
6121
6122 # Define which file types will be treated as images, in case they get
6123 # blocked further down this file:
6124 #
6125 { +<link linkend="HANDLE-AS-IMAGE">handle-as-image</link> }
6126 /.*\.(gif|jpe?g|png|bmp|ico)$</screen>
6127
6128 <para>
6129  And then there are known banner sources. They often use scripts to
6130  generate the banners, so it won't be visible from the URL that the
6131  request is for an image. Hence we block them <emphasis>and</emphasis>
6132  mark them as images in one go, with the help of our
6133  <literal>+block-as-image</literal> alias defined above. (We could of
6134  course just as well use <literal>+<link linkend="block">block</link>
6135  +<link linkend="handle-as-image">handle-as-image</link></literal> here.)
6136  Remember that the type of the replacement image is chosen by the
6137  <literal><link linkend="set-image-blocker">set-image-blocker</link></literal>
6138  action. Since all URLs have matched the default section with its
6139  <literal>+<link linkend="set-image-blocker">set-image-blocker</link>{pattern}</literal>
6140  action before, it still applies and needn't be repeated:
6141 </para>
6142
6143  <screen>
6144 # Known ad generators:
6145 #
6146 { +block-as-image }
6147 ar.atwola.com
6148 .ad.doubleclick.net
6149 .ad.*.doubleclick.net
6150 .a.yimg.com/(?:(?!/i/).)*$
6151 .a[0-9].yimg.com/(?:(?!/i/).)*$
6152 bs*.gsanet.com
6153 .qkimg.net</screen>
6154
6155 <para>
6156  One of the most important jobs of <application>Privoxy</application>
6157  is to block banners. Many of these can be <quote>blocked</quote>
6158  by the <literal><link linkend="filter">filter</link>{banners-by-size}</literal>
6159  action, which we enabled above, and which deletes the references to banner
6160  images from the pages while they are loaded, so the browser doesn't request
6161  them anymore, and hence they don't need to be blocked here. But this naturally
6162  doesn't catch all banners, and some people choose not to use filters, so we
6163  need a comprehensive list of patterns for banner URLs here, and apply the
6164  <literal><link linkend="block">block</link></literal> action to them.
6165 </para>
6166 <para>
6167  First comes many generic patterns, which do most of the work, by
6168  matching typical domain and path name components of banners. Then comes
6169  a list of individual patterns for specific sites, which is omitted here
6170  to keep the example short:
6171 </para>
6172
6173  <screen>
6174 ##########################################################################
6175 # Block these fine banners:
6176 ##########################################################################
6177 { <link linkend="BLOCK">+block{Banner ads.}</link> }
6178
6179 # Generic patterns:
6180 #
6181 ad*.
6182 .*ads.
6183 banner?.
6184 count*.
6185 /.*count(er)?\.(pl|cgi|exe|dll|asp|php[34]?)
6186 /(?:.*/)?(publicite|werbung|rekla(ma|me|am)|annonse|maino(kset|nta|s)?)/
6187
6188 # Site-specific patterns (abbreviated):
6189 #
6190 .hitbox.com</screen>
6191
6192 <para>
6193  It's quite remarkable how many advertisers actually call their banner
6194  servers ads.<replaceable>company</replaceable>.com, or call the directory
6195  in which the banners are stored literally <quote>banners</quote>. So the above
6196  generic patterns are surprisingly effective.
6197 </para>
6198 <para>
6199  But being very generic, they necessarily also catch URLs that we don't want
6200  to block. The pattern <literal>.*ads.</literal> e.g. catches
6201  <quote>nasty-<emphasis>ads</emphasis>.nasty-corp.com</quote> as intended,
6202  but also <quote>downlo<emphasis>ads</emphasis>.sourcefroge.net</quote> or
6203  <quote><emphasis>ads</emphasis>l.some-provider.net.</quote> So here come some
6204  well-known exceptions to the <literal>+<link linkend="BLOCK">block</link></literal>
6205  section above.
6206 </para>
6207 <para>
6208  Note that these are exceptions to exceptions from the default! Consider the URL
6209  <quote>downloads.sourcefroge.net</quote>: Initially, all actions are deactivated,
6210  so it wouldn't get blocked. Then comes the defaults section, which matches the
6211  URL, but just deactivates the <literal><link linkend="BLOCK">block</link></literal>
6212  action once again. Then it matches <literal>.*ads.</literal>, an exception to the
6213  general non-blocking policy, and suddenly
6214  <literal><link linkend="BLOCK">+block</link></literal> applies. And now, it'll match
6215  <literal>.*loads.</literal>, where <literal><link linkend="BLOCK">-block</link></literal>
6216  applies, so (unless it matches <emphasis>again</emphasis> further down) it ends up
6217  with no <literal><link linkend="BLOCK">block</link></literal> action applying.
6218 </para>
6219
6220  <screen>
6221 ##########################################################################
6222 # Save some innocent victims of the above generic block patterns:
6223 ##########################################################################
6224
6225 # By domain:
6226 #
6227 { -<link linkend="BLOCK">block</link> }
6228 adv[io]*.  # (for advogato.org and advice.*)
6229 adsl.      # (has nothing to do with ads)
6230 adobe.     # (has nothing to do with ads either)
6231 ad[ud]*.   # (adult.* and add.*)
6232 .edu       # (universities don't host banners (yet!))
6233 .*loads.   # (downloads, uploads etc)
6234
6235 # By path:
6236 #
6237 /.*loads/
6238
6239 # Site-specific:
6240 #
6241 www.globalintersec.com/adv # (adv = advanced)
6242 www.ugu.com/sui/ugu/adv</screen>
6243
6244 <para>
6245  Filtering source code can have nasty side effects,
6246  so make an exception for our friends at sourceforge.net,
6247  and all paths with <quote>cvs</quote> in them. Note that
6248  <literal>-<link linkend="FILTER">filter</link></literal>
6249  disables <emphasis>all</emphasis> filters in one fell swoop!
6250 </para>
6251
6252  <screen>
6253 # Don't filter code!
6254 #
6255 { -<link linkend="FILTER">filter</link> }
6256 /(.*/)?cvs
6257 bugzilla.
6258 developer.
6259 wiki.
6260 .sourceforge.net</screen>
6261
6262 <para>
6263  The actual <filename>default.action</filename> is of course much more
6264  comprehensive, but we hope this example made clear how it works.
6265 </para>
6266
6267 </sect3>
6268
6269 <sect3 id="user-action"><title>user.action</title>
6270
6271 <para>
6272  So far we are painting with a broad brush by setting general policies,
6273  which would be a reasonable starting point for many people. Now,
6274  you might want to be more specific and have customized rules that
6275  are more suitable to your personal habits and preferences. These would
6276  be for narrowly defined situations like your ISP or your bank, and should
6277  be placed in <filename>user.action</filename>, which is parsed after all other
6278  actions files and hence has the last word, over-riding any previously
6279  defined actions. <filename>user.action</filename> is also a
6280  <emphasis>safe</emphasis> place for your personal settings, since
6281  <filename>default.action</filename> is actively maintained by the
6282  <application>Privoxy</application> developers and you'll probably want
6283  to install updated versions from time to time.
6284 </para>
6285
6286 <para>
6287  So let's look at a few examples of things that one might typically do in
6288  <filename>user.action</filename>:
6289 </para>
6290
6291
6292 <!-- brief sample user.action here -->
6293
6294  <screen>
6295 # My user.action file. &lt;fred@example.com&gt;</screen>
6296
6297 <para>
6298  As <link linkend="aliases">aliases</link> are local to the actions
6299  file that they are defined in, you can't use the ones from
6300  <filename>default.action</filename>, unless you repeat them here:
6301 </para>
6302
6303  <screen>
6304 # Aliases are local to the file they are defined in.
6305 # (Re-)define aliases for this file:
6306 #
6307 {{alias}}
6308 #
6309 # These aliases just save typing later, and the alias names should
6310 # be self explanatory.
6311 #
6312 +crunch-all-cookies = +crunch-incoming-cookies +crunch-outgoing-cookies
6313 -crunch-all-cookies = -crunch-incoming-cookies -crunch-outgoing-cookies
6314  allow-all-cookies  = -crunch-all-cookies -session-cookies-only
6315  allow-popups       = -filter{all-popups}
6316 +block-as-image     = +block{Blocked as image.} +handle-as-image
6317 -block-as-image     = -block
6318
6319 # These aliases define combinations of actions that are useful for
6320 # certain types of sites:
6321 #
6322 fragile     = -block -crunch-all-cookies -filter -fast-redirects -hide-referrer
6323 shop        = -crunch-all-cookies allow-popups
6324
6325 # Allow ads for selected useful free sites:
6326 #
6327 allow-ads   = -block -filter{banners-by-size} -filter{banners-by-link}
6328
6329 # Alias for specific file types that are text, but might have conflicting
6330 # MIME types. We want the browser to force these to be text documents.
6331 handle-as-text = -<link linkend="FILTER">filter</link> +-<link linkend="content-type-overwrite">content-type-overwrite{text/plain}</link> +-<link linkend="FORCE-TEXT-MODE">force-text-mode</link> -<link linkend="HIDE-CONTENT-DISPOSITION">hide-content-disposition</link></screen>
6332
6333 <para>
6334  Say you have accounts on some sites that you visit regularly, and
6335  you don't want to have to log in manually each time. So you'd like
6336  to allow persistent cookies for these sites. The
6337  <literal>allow-all-cookies</literal> alias defined above does exactly
6338  that, i.e. it disables crunching of cookies in any direction, and the
6339  processing of cookies to make them only temporary.
6340 </para>
6341
6342  <screen>
6343 { allow-all-cookies }
6344  sourceforge.net
6345  .yahoo.com
6346  .msdn.microsoft.com
6347  .redhat.com</screen>
6348
6349 <para>
6350  Your bank is allergic to some filter, but you don't know which, so you disable them all:
6351 </para>
6352
6353  <screen>
6354 { -<link linkend="FILTER">filter</link> }
6355  .your-home-banking-site.com</screen>
6356
6357 <para>
6358  Some file types you may not want to filter for various reasons:
6359 </para>
6360
6361  <screen>
6362 # Technical documentation is likely to contain strings that might
6363 # erroneously get altered by the JavaScript-oriented filters:
6364 #
6365 .tldp.org
6366 /(.*/)?selfhtml/
6367
6368 # And this stupid host sends streaming video with a wrong MIME type,
6369 # so that Privoxy thinks it is getting HTML and starts filtering:
6370 #
6371 stupid-server.example.com/</screen>
6372
6373 <para>
6374  Example of a simple <link linkend="BLOCK">block</link> action. Say you've
6375  seen an ad on your favourite page on example.com that you want to get rid of.
6376  You have right-clicked the image, selected <quote>copy image location</quote>
6377  and pasted the URL below while removing the leading http://, into a
6378  <literal>{ +block{} }</literal> section. Note that <literal>{ +handle-as-image
6379  }</literal> need not be specified, since all URLs ending in
6380  <literal>.gif</literal> will be tagged as images by the general rules as set
6381  in default.action anyway:
6382 </para>
6383
6384  <screen>
6385 { +<link linkend="BLOCK">block</link>{Nasty ads.} }
6386  www.example.com/nasty-ads/sponsor\.gif
6387  another.example.net/more/junk/here/</screen>
6388
6389 <para>
6390  The URLs of dynamically generated banners, especially from large banner
6391  farms, often don't use the well-known image file name extensions, which
6392  makes it impossible for <application>Privoxy</application> to guess
6393  the file type just by looking at the URL.
6394  You can use the <literal>+block-as-image</literal> alias defined above for
6395  these cases.
6396  Note that objects which match this rule but then turn out NOT to be an
6397  image are typically rendered as a <quote>broken image</quote> icon by the
6398  browser. Use cautiously.
6399 </para>
6400
6401  <screen>
6402 { +block-as-image }
6403  .doubleclick.net
6404  .fastclick.net
6405  /Realmedia/ads/
6406  ar.atwola.com/</screen>
6407
6408 <para>
6409  Now you noticed that the default configuration breaks Forbes Magazine,
6410  but you were too lazy to find out which action is the culprit, and you
6411  were again too lazy to give <link linkend="contact">feedback</link>, so
6412  you just used the <literal>fragile</literal> alias on the site, and
6413  -- <emphasis>whoa!</emphasis> -- it worked. The <literal>fragile</literal>
6414  aliases disables those actions that are most likely to break a site. Also,
6415  good for testing purposes to see if it is <application>Privoxy</application>
6416  that is causing the problem or not. We later find other regular sites
6417  that misbehave, and add those to our personalized list of troublemakers:
6418 </para>
6419
6420 <screen>
6421 { fragile }
6422  .forbes.com
6423  webmail.example.com
6424  .mybank.com</screen>
6425
6426 <para>
6427  You like the <quote>fun</quote> text replacements in <filename>default.filter</filename>,
6428  but it is disabled in the distributed actions file.
6429  So you'd like to turn it on in your private,
6430  update-safe config, once and for all:
6431 </para>
6432
6433 <screen>
6434 { +<link linkend="filter-fun">filter{fun}</link> }
6435  / # For ALL sites!</screen>
6436
6437 <para>
6438  Note that the above is not really a good idea: There are exceptions
6439  to the filters in <filename>default.action</filename> for things that
6440  really shouldn't be filtered, like code on CVS->Web interfaces. Since
6441  <filename>user.action</filename> has the last word, these exceptions
6442  won't be valid for the <quote>fun</quote> filtering specified here.
6443 </para>
6444
6445 <para>
6446  You might also worry about how your favourite free websites are
6447  funded, and find that they rely on displaying banner advertisements
6448  to survive. So you might want to specifically allow banners for those
6449  sites that you feel provide value to you:
6450 </para>
6451
6452 <screen>
6453 { allow-ads }
6454  .sourceforge.net
6455  .slashdot.org
6456  .osdn.net</screen>
6457
6458 <para>
6459  Note that <literal>allow-ads</literal> has been aliased to
6460  <literal>-<link linkend="block">block</link></literal>,
6461  <literal>-<link linkend="filter-banners-by-size">filter{banners-by-size}</link></literal>, and
6462  <literal>-<link linkend="filter-banners-by-link">filter{banners-by-link}</link></literal> above.
6463 </para>
6464
6465 <para>
6466  Invoke another alias here to force an over-ride of the MIME type <literal>
6467  application/x-sh</literal> which typically would open a download type
6468  dialog. In my case, I want to look at the shell script, and then I can save
6469  it should I choose to.
6470 </para>
6471
6472 <screen>
6473 { handle-as-text }
6474  /.*\.sh$</screen>
6475
6476 <para>
6477  <filename>user.action</filename> is generally the best place to define
6478  exceptions and additions to the default policies of
6479  <filename>default.action</filename>. Some actions are safe to have their
6480  default policies set here though. So let's set a default policy to have a
6481  <quote>blank</quote> image as opposed to the checkerboard pattern for
6482  <emphasis>ALL</emphasis> sites. <quote>/</quote> of course matches all URL
6483  paths and patterns:
6484 </para>
6485
6486 <screen>
6487 { +<link linkend="set-image-blocker">set-image-blocker{blank}</link> }
6488 / # ALL sites</screen>
6489
6490 </sect3>
6491 </sect2>
6492
6493 <!--  ~  End section  ~  -->
6494
6495 </sect1>
6496
6497 <!--  ~  End section  ~  -->
6498
6499 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
6500
6501 <sect1 id="filter-file">
6502 <title>Filter Files</title>
6503
6504 <para>
6505  On-the-fly text substitutions need
6506  to be defined in a <quote>filter file</quote>. Once defined, they
6507  can then be invoked as an <quote>action</quote>.
6508 </para>
6509
6510 <para>
6511  &my-app; supports three different pcrs-based filter actions:
6512  <literal><link linkend="filter">filter</link></literal> to
6513  rewrite the content that is send to the client,
6514  <literal><link linkend="client-header-filter">client-header-filter</link></literal>
6515  to rewrite headers that are send by the client, and
6516  <literal><link linkend="server-header-filter">server-header-filter</link></literal>
6517  to rewrite headers that are send by the server.
6518 </para>
6519
6520 <para>
6521  &my-app; also supports two tagger actions:
6522  <literal><link linkend="client-header-tagger">client-header-tagger</link></literal>
6523  and
6524  <literal><link linkend="server-header-tagger">server-header-tagger</link></literal>.
6525  Taggers and filters use the same syntax in the filter files, the difference
6526  is that taggers don't modify the text they are filtering, but use a rewritten
6527  version of the filtered text as tag. The tags can then be used to change the
6528  applying actions through sections with <link linkend="tag-pattern">tag-patterns</link>.
6529 </para>
6530
6531 <para>
6532  Finally &my-app; supports the
6533  <literal><link linkend="external-filter">external-filter</link></literal> action
6534  to enable <literal><link linkend="external-filter-syntax">external filters</link></literal>
6535  written in proper programming languages.
6536 </para>
6537
6538
6539 <para>
6540  Multiple filter files can be defined through the <literal> <link
6541  linkend="filterfile">filterfile</link></literal> config directive. The filters
6542  as supplied by the developers are located in
6543  <filename>default.filter</filename>. It is recommended that any locally
6544  defined or modified filters go in a separately defined file such as
6545  <filename>user.filter</filename>.
6546  </para>
6547
6548 <para>
6549  Common tasks for content filters are to eliminate common annoyances in
6550  HTML and JavaScript, such as pop-up windows,
6551  exit consoles, crippled windows without navigation tools, the
6552  infamous &lt;BLINK&gt; tag etc, to suppress images with certain
6553  width and height attributes (standard banner sizes or web-bugs),
6554  or just to have fun.
6555 </para>
6556
6557 <para>
6558  Enabled content filters are applied to any content whose
6559  <quote>Content Type</quote> header is recognised as a sign
6560  of text-based content, with the exception of <literal>text/plain</literal>.
6561  Use the <link linkend="FORCE-TEXT-MODE">force-text-mode</link> action
6562  to also filter other content.
6563 </para>
6564
6565 <para>
6566  Substitutions are made at the source level, so if you want to <quote>roll
6567  your own</quote> filters, you should first be familiar with HTML syntax,
6568  and, of course, regular expressions.
6569 </para>
6570
6571 <para>
6572  Just like the <link linkend="actions-file">actions files</link>, the
6573  filter file is organized in sections, which are called <emphasis>filters</emphasis>
6574  here. Each filter consists of a heading line, that starts with one of the
6575  <emphasis>keywords</emphasis> <literal>FILTER:</literal>,
6576  <literal>CLIENT-HEADER-FILTER:</literal> or <literal>SERVER-HEADER-FILTER:</literal>
6577  followed by the filter's <emphasis>name</emphasis>, and a short (one line)
6578  <emphasis>description</emphasis> of what it does. Below that line
6579  come the <emphasis>jobs</emphasis>, i.e. lines that define the actual
6580  text substitutions. By convention, the name of a filter
6581  should describe what the filter <emphasis>eliminates</emphasis>. The
6582  comment is used in the <ulink url="http://config.privoxy.org/">web-based
6583  user interface</ulink>.
6584 </para>
6585
6586 <para>
6587  Once a filter called <replaceable>name</replaceable> has been defined
6588  in the filter file, it can be invoked by using an action of the form
6589  +<literal><link linkend="filter">filter</link>{<replaceable>name</replaceable>}</literal>
6590  in any <link linkend="actions-file">actions file</link>.
6591 </para>
6592
6593 <para>
6594  Filter definitions start with a header line that contains the filter
6595  type, the filter name and the filter description.
6596  A content filter header line for a filter called <quote>foo</quote> could look
6597  like this:
6598 </para>
6599
6600  <screen>FILTER: foo Replace all "foo" with "bar"</screen>
6601
6602 <para>
6603  Below that line, and up to the next header line, come the jobs that
6604  define what text replacements the filter executes. They are specified
6605  in a syntax that imitates <ulink url="http://www.perl.org/">Perl</ulink>'s
6606  <literal>s///</literal> operator. If you are familiar with Perl, you
6607  will find this to be quite intuitive, and may want to look at the
6608  PCRS documentation for the subtle differences to Perl behaviour.
6609 </para>
6610
6611 <para>
6612  Most notably, the non-standard option letter <literal>U</literal> is supported,
6613  which turns the default to ungreedy matching (add <literal>?</literal> to
6614  quantifiers to turn them greedy again).
6615 </para>
6616
6617 <para>
6618  The non-standard option letter <literal>D</literal> (dynamic) allows
6619  to use the variables $host, $origin (the IP address the request came from),
6620  $path, $url and $listen-address (the address on which Privoxy accepted the
6621  client request. Example: 127.0.0.1:8118).
6622  They will be replaced with the value they refer to before the filter
6623  is executed.
6624 </para>
6625
6626 <para>
6627  Note that '$' is a bad choice for a delimiter in a dynamic filter as you
6628  might end up with unintended variables if you use a variable name
6629  directly after the delimiter. Variables will be resolved without
6630  escaping anything, therefore you also have to be careful not to chose
6631  delimiters that appear in the replacement text. For example '<' should
6632  be save, while '?' will sooner or later cause conflicts with $url.
6633 </para>
6634
6635 <para>
6636  The non-standard option letter <literal>T</literal> (trivial) prevents
6637  parsing for backreferences in the substitute. Use it if you want to include
6638  text like '$&' in your substitute without quoting.
6639 </para>
6640
6641 <para>
6642  If you are new to
6643   <ulink url="http://en.wikipedia.org/wiki/Regular_expressions"><quote>Regular
6644   Expressions</quote></ulink>, you might want to take a look at
6645  the <link linkend="regex">Appendix on regular expressions</link>, and
6646  see the <ulink url="http://perldoc.perl.org/perlre.html">Perl
6647  manual</ulink> for
6648  <ulink url="http://perldoc.perl.org/perlop.html">the
6649  <literal>s///</literal> operator's syntax</ulink> and <ulink
6650  url="http://perldoc.perl.org/perlre.html">Perl-style regular
6651  expressions</ulink> in general.
6652  The below examples might also help to get you started.
6653 </para>
6654
6655
6656 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
6657
6658 <sect2 id="filter-file-tut"><title>Filter File Tutorial</title>
6659 <para>
6660  Now, let's complete our <quote>foo</quote> content filter. We have already defined
6661  the heading, but the jobs are still missing. Since all it does is to replace
6662  <quote>foo</quote> with <quote>bar</quote>, there is only one (trivial) job
6663  needed:
6664 </para>
6665
6666  <screen>s/foo/bar/</screen>
6667
6668 <para>
6669  But wait! Didn't the comment say that <emphasis>all</emphasis> occurrences
6670  of <quote>foo</quote> should be replaced? Our current job will only take
6671  care of the first <quote>foo</quote> on each page. For global substitution,
6672  we'll need to add the <literal>g</literal> option:
6673 </para>
6674
6675  <screen>s/foo/bar/g</screen>
6676
6677 <para>
6678  Our complete filter now looks like this:
6679 </para>
6680
6681  <screen>FILTER: foo Replace all "foo" with "bar"
6682 s/foo/bar/g</screen>
6683
6684 <para>
6685  Let's look at some real filters for more interesting examples. Here you see
6686  a filter that protects against some common annoyances that arise from JavaScript
6687  abuse. Let's look at its jobs one after the other:
6688 </para>
6689
6690
6691  <screen>
6692 FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse
6693
6694 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm
6695 #
6696 s|(&lt;script.*)document\.referrer(.*&lt;/script&gt;)|$1"Not Your Business!"$2|Usg</screen>
6697
6698 <para>
6699  Following the header line and a comment, you see the job. Note that it uses
6700  <literal>|</literal> as the delimiter instead of <literal>/</literal>, because
6701  the pattern contains a forward slash, which would otherwise have to be escaped
6702  by a backslash (<literal>\</literal>).
6703 </para>
6704
6705 <para>
6706  Now, let's examine the pattern: it starts with the text <literal>&lt;script.*</literal>
6707  enclosed in parentheses. Since the dot matches any character, and <literal>*</literal>
6708  means: <quote>Match an arbitrary number of the element left of myself</quote>, this
6709  matches <quote>&lt;script</quote>, followed by <emphasis>any</emphasis> text, i.e.
6710  it matches the whole page, from the start of the first &lt;script&gt; tag.
6711 </para>
6712
6713 <para>
6714  That's more than we want, but the pattern continues: <literal>document\.referrer</literal>
6715  matches only the exact string <quote>document.referrer</quote>. The dot needed to
6716  be <emphasis>escaped</emphasis>, i.e. preceded by a backslash, to take away its
6717  special meaning as a joker, and make it just a regular dot. So far, the meaning is:
6718  Match from the start of the first &lt;script&gt; tag in a the page, up to, and including,
6719  the text <quote>document.referrer</quote>, if <emphasis>both</emphasis> are present
6720  in the page (and appear in that order).
6721 </para>
6722
6723 <para>
6724  But there's still more pattern to go. The next element, again enclosed in parentheses,
6725  is <literal>.*&lt;/script&gt;</literal>. You already know what <literal>.*</literal>
6726  means, so the whole pattern translates to: Match from the start of the first  &lt;script&gt;
6727  tag in a page to the end of the last &lt;script&gt; tag, provided that the text
6728  <quote>document.referrer</quote> appears somewhere in between.
6729 </para>
6730
6731 <para>
6732  This is still not the whole story, since we have ignored the options and the parentheses:
6733  The portions of the page matched by sub-patterns that are enclosed in parentheses, will be
6734  remembered and be available through the variables <literal>$1, $2, ...</literal> in
6735  the substitute. The <literal>U</literal> option switches to ungreedy matching, which means
6736  that the first <literal>.*</literal> in the pattern will only <quote>eat up</quote> all
6737  text in between <quote>&lt;script</quote> and the <emphasis>first</emphasis> occurrence
6738  of <quote>document.referrer</quote>, and that the second <literal>.*</literal> will
6739  only span the text up to the <emphasis>first</emphasis> <quote>&lt;/script&gt;</quote>
6740  tag. Furthermore, the <literal>s</literal> option says that the match may span
6741  multiple lines in the page, and the <literal>g</literal> option again means that the
6742  substitution is global.
6743 </para>
6744
6745 <para>
6746  So, to summarize, the pattern means: Match all scripts that contain the text
6747  <quote>document.referrer</quote>. Remember the parts of the script from
6748  (and including) the start tag up to (and excluding) the string
6749  <quote>document.referrer</quote> as <literal>$1</literal>, and the part following
6750  that string, up to and including the closing tag, as <literal>$2</literal>.
6751 </para>
6752
6753 <para>
6754  Now the pattern is deciphered, but wasn't this about substituting things? So
6755  lets look at the substitute: <literal>$1"Not Your Business!"$2</literal> is
6756  easy to read: The text remembered as <literal>$1</literal>, followed by
6757  <literal>"Not Your Business!"</literal> (<emphasis>including</emphasis>
6758  the quotation marks!), followed by the text remembered as <literal>$2</literal>.
6759  This produces an exact copy of the original string, with the middle part
6760  (the <quote>document.referrer</quote>) replaced by <literal>"Not Your
6761  Business!"</literal>.
6762 </para>
6763
6764 <para>
6765  The whole job now reads: Replace <quote>document.referrer</quote> by
6766  <literal>"Not Your Business!"</literal> wherever it appears inside a
6767  &lt;script&gt tag. Note that this job won't break JavaScript syntax,
6768  since both the original and the replacement are syntactically valid
6769  string objects. The script just won't have access to the referrer
6770  information anymore.
6771 </para>
6772
6773 <para>
6774  We'll show you two other jobs from the JavaScript taming department, but
6775  this time only point out the constructs of special interest:
6776 </para>
6777
6778  <screen>
6779 # The status bar is for displaying link targets, not pointless blahblah
6780 #
6781 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</screen>
6782
6783 <para>
6784  <literal>\s</literal> stands for whitespace characters (space, tab, newline,
6785  carriage return, form feed), so that <literal>\s*</literal> means: <quote>zero
6786  or more whitespace</quote>. The <literal>?</literal> in <literal>.*?</literal>
6787  makes this matching of arbitrary text ungreedy. (Note that the <literal>U</literal>
6788  option is not set). The <literal>['"]</literal> construct means: <quote>a single
6789  <emphasis>or</emphasis> a double quote</quote>. Finally, <literal>\1</literal> is
6790  a back-reference to the first parenthesis just like <literal>$1</literal> above,
6791  with the difference that in the <emphasis>pattern</emphasis>, a backslash indicates
6792  a back-reference, whereas in the <emphasis>substitute</emphasis>, it's the dollar.
6793 </para>
6794
6795 <para>
6796  So what does this job do? It replaces assignments of single- or double-quoted
6797  strings to the <quote>window.status</quote> object with a dummy assignment
6798  (using a variable name that is hopefully odd enough not to conflict with
6799  real variables in scripts). Thus, it catches many cases where e.g. pointless
6800  descriptions are displayed in the status bar instead of the link target when
6801  you move your mouse over links.
6802 </para>
6803
6804  <screen>
6805 # Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
6806 #
6807 s/(&lt;body [^&gt;]*)onunload(.*&gt;)/$1never$2/iU</screen>
6808
6809 <para>
6810  Including the
6811  <ulink url="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents">OnUnload
6812  event binding</ulink> in the HTML DOM was a <emphasis>CRIME</emphasis>.
6813  When I close a browser window, I want it to close and die. Basta.
6814  This job replaces the <quote>onunload</quote> attribute in
6815  <quote>&lt;body&gt</quote> tags with the dummy word <literal>never</literal>.
6816  Note that the <literal>i</literal> option makes the pattern matching
6817  case-insensitive. Also note that ungreedy matching alone doesn't always guarantee
6818  a minimal match: In the first parenthesis, we had to use <literal>[^&gt;]*</literal>
6819  instead of <literal>.*</literal> to prevent the match from exceeding the
6820  &lt;body&gt tag if it doesn't contain <quote>OnUnload</quote>, but the page's
6821  content does.
6822 </para>
6823
6824 <para>
6825  The last example is from the fun department:
6826 </para>
6827
6828  <screen>
6829 FILTER: fun Fun text replacements
6830
6831 # Spice the daily news:
6832 #
6833 s/microsoft(?!\.com)/MicroSuck/ig</screen>
6834
6835 <para>
6836  Note the <literal>(?!\.com)</literal> part (a so-called negative lookahead)
6837  in the job's pattern, which means: Don't match, if the string
6838  <quote>.com</quote> appears directly following <quote>microsoft</quote>
6839  in the page. This prevents links to microsoft.com from being trashed, while
6840  still replacing the word everywhere else.
6841 </para>
6842
6843  <screen>
6844 # Buzzword Bingo (example for extended regex syntax)
6845 #
6846 s* industry[ -]leading \
6847 |  cutting[ -]edge \
6848 |  customer[ -]focused \
6849 |  market[ -]driven \
6850 |  award[ -]winning # Comments are OK, too! \
6851 |  high[ -]performance \
6852 |  solutions[ -]based \
6853 |  unmatched \
6854 |  unparalleled \
6855 |  unrivalled \
6856 *&lt;font color="red"&gt;&lt;b&gt;BINGO!&lt;/b&gt;&lt;/font&gt; \
6857 *igx</screen>
6858
6859 <para>
6860  The <literal>x</literal> option in this job turns on extended syntax, and allows for
6861  e.g. the liberal use of (non-interpreted!) whitespace for nicer formatting.
6862 </para>
6863
6864 <para>
6865  You get the idea?
6866 </para>
6867 </sect2>
6868
6869 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
6870
6871 <sect2 id="predefined-filters"><title>The Pre-defined Filters</title>
6872
6873 <!--
6874
6875  Note each filter is also listed in the +filter action section above. Please
6876  keep these listings in sync.
6877
6878 -->
6879
6880 <para>
6881 The distribution <filename>default.filter</filename> file contains a selection of
6882 pre-defined filters for your convenience:
6883 </para>
6884
6885 <variablelist>
6886  <varlistentry>
6887   <term><emphasis>js-annoyances</emphasis></term>
6888   <listitem>
6889    <para>
6890     The purpose of this filter is to get rid of particularly annoying JavaScript abuse.
6891     To that end, it
6892    </para>
6893    <itemizedlist>
6894     <listitem>
6895      <para>
6896       replaces JavaScript references to the browser's referrer information
6897       with the string "Not Your Business!". This compliments the <literal><link
6898       linkend="hide-referrer">hide-referrer</link></literal> action on the content level.
6899      </para>
6900     </listitem>
6901     <listitem>
6902      <para>
6903       removes the bindings to the DOM's
6904       <ulink url="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents">unload
6905       event</ulink> which we feel has no right to exist and is responsible for most <quote>exit consoles</quote>, i.e.
6906       nasty windows that pop up when you close another one.
6907      </para>
6908     </listitem>
6909     <listitem>
6910      <para>
6911       removes code that causes new windows to be opened with undesired properties, such as being
6912       full-screen, non-resizeable, without location, status or menu bar etc.
6913      </para>
6914     </listitem>
6915    </itemizedlist>
6916    <para>
6917     Use with caution. This is an aggressive filter, and can break sites that
6918     rely heavily on JavaScript.
6919    </para>
6920   </listitem>
6921  </varlistentry>
6922
6923  <varlistentry>
6924   <term><emphasis>js-events</emphasis></term>
6925   <listitem>
6926    <para>
6927     This is a very radical measure. It removes virtually all JavaScript event bindings, which
6928     means that scripts can not react to user actions such as mouse movements or clicks, window
6929     resizing etc, anymore. Use with caution!
6930    </para>
6931    <para>
6932     We <emphasis>strongly discourage</emphasis> using this filter as a default since it breaks
6933     many legitimate scripts. It is meant for use only on extra-nasty sites (should you really
6934     need to go there).
6935    </para>
6936   </listitem>
6937  </varlistentry>
6938
6939 <varlistentry>
6940   <term><emphasis>html-annoyances</emphasis></term>
6941   <listitem>
6942    <para>
6943     This filter will undo many common instances of HTML based abuse.
6944    </para>
6945    <para>
6946     The <literal>BLINK</literal> and <literal>MARQUEE</literal> tags
6947     are neutralized (yeah baby!), and browser windows will be created as
6948     resizeable (as of course they should be!), and will have location,
6949     scroll and menu bars -- even if specified otherwise.
6950    </para>
6951   </listitem>
6952  </varlistentry>
6953
6954  <varlistentry>
6955   <term><emphasis>content-cookies</emphasis></term>
6956   <listitem>
6957    <para>
6958     Most cookies are set in the HTTP dialog, where they can be intercepted
6959     by the
6960     <literal><link linkend="crunch-incoming-cookies">crunch-incoming-cookies</link></literal>
6961     and <literal><link linkend="crunch-outgoing-cookies">crunch-outgoing-cookies</link></literal>
6962     actions. But web sites increasingly make use of HTML meta tags and JavaScript
6963     to sneak cookies to the browser on the content level.
6964    </para>
6965    <para>
6966     This filter disables most HTML and JavaScript code that reads or sets
6967     cookies. It cannot detect all clever uses of these types of code, so it
6968     should not be relied on as an absolute fix. Use it wherever you would also
6969     use the cookie crunch actions.
6970    </para>
6971   </listitem>
6972  </varlistentry>
6973
6974  <varlistentry>
6975   <term><emphasis>refresh-tags</emphasis></term>
6976   <listitem>
6977    <para>
6978     Disable any refresh tags if the interval is greater than nine seconds (so
6979     that redirections done via refresh tags are not destroyed). This is useful
6980     for dial-on-demand setups, or for those who find this HTML feature
6981     annoying.
6982    </para>
6983   </listitem>
6984  </varlistentry>
6985
6986  <varlistentry>
6987   <term><emphasis>unsolicited-popups</emphasis></term>
6988   <listitem>
6989    <para>
6990     This filter attempts to prevent only <quote>unsolicited</quote> pop-up
6991     windows from opening, yet still allow pop-up windows that the user
6992     has explicitly chosen to open. It was added in version 3.0.1,
6993     as an improvement over earlier such filters.
6994    </para>
6995    <para>
6996     Technical note: The filter works by redefining the window.open JavaScript
6997     function to a dummy function, <literal>PrivoxyWindowOpen()</literal>,
6998     during the loading and rendering phase of each HTML page access, and
6999     restoring the function afterward.
7000    </para>
7001    <para>
7002     This is recommended only for browsers that cannot perform this function
7003     reliably themselves. And be aware that some sites require such windows
7004     in order to function normally. Use with caution.
7005    </para>
7006   </listitem>
7007  </varlistentry>
7008
7009  <varlistentry>
7010   <term><emphasis>all-popups</emphasis></term>
7011   <listitem>
7012    <para>
7013     Attempt to prevent <emphasis>all</emphasis> pop-up windows from opening.
7014     Note this should be used with even more discretion than the above, since
7015     it is more likely to break some sites that require pop-ups for normal
7016     usage. Use with caution.
7017    </para>
7018   </listitem>
7019  </varlistentry>
7020
7021  <varlistentry>
7022   <term><emphasis>img-reorder</emphasis></term>
7023   <listitem>
7024    <para>
7025     This is a helper filter that has no value if used alone. It makes the
7026     <literal>banners-by-size</literal> and <literal>banners-by-link</literal>
7027     (see below) filters more effective and should be enabled together with them.
7028    </para>
7029   </listitem>
7030  </varlistentry>
7031
7032  <varlistentry>
7033   <term><emphasis>banners-by-size</emphasis></term>
7034   <listitem>
7035    <para>
7036     This filter removes image tags purely based on what size they are. Fortunately
7037     for us, many ads and banner images tend to conform to certain standardized
7038     sizes, which makes this filter quite effective for ad stripping purposes.
7039    </para>
7040    <para>
7041     Occasionally this filter will cause false positives on images that are not ads,
7042     but just happen to be of one of the standard banner sizes.
7043    </para>
7044    <para>
7045     Recommended only for those who require extreme ad blocking. The default
7046     block rules should catch 95+% of all ads <emphasis>without</emphasis> this filter enabled.
7047    </para>
7048   </listitem>
7049  </varlistentry>
7050
7051  <varlistentry>
7052   <term><emphasis>banners-by-link</emphasis></term>
7053   <listitem>
7054    <para>
7055     This is an experimental filter that attempts to kill any banners if
7056     their URLs seem to point to known or suspected click trackers. It is currently
7057     not of much value and is not recommended for use by default.
7058    </para>
7059   </listitem>
7060  </varlistentry>
7061
7062  <varlistentry>
7063   <term><emphasis>webbugs</emphasis></term>
7064   <listitem>
7065    <para>
7066     Webbugs are small, invisible images (technically 1X1 GIF images), that
7067     are used to track users across websites, and collect information on them.
7068     As an HTML page is loaded by the browser, an embedded image tag causes the
7069     browser to contact a third-party site, disclosing the tracking information
7070     through the requested URL and/or cookies for that third-party domain, without
7071     the user ever becoming aware of the interaction with the third-party site.
7072     HTML-ized spam also uses a similar technique to verify email addresses.
7073    </para>
7074    <para>
7075     This filter removes the HTML code that loads such <quote>webbugs</quote>.
7076    </para>
7077   </listitem>
7078  </varlistentry>
7079
7080  <varlistentry>
7081   <term><emphasis>tiny-textforms</emphasis></term>
7082   <listitem>
7083    <para>
7084     A rather special-purpose filter that can be used to enlarge textareas (those
7085     multi-line text boxes in web forms) and turn off hard word wrap in them.
7086     It was written for the sourceforge.net tracker system where such boxes are
7087     a nuisance, but it can be handy on other sites, too.
7088    </para>
7089    <para>
7090     It is not recommended to use this filter as a default.
7091    </para>
7092   </listitem>
7093  </varlistentry>
7094
7095  <varlistentry>
7096   <term><emphasis>jumping-windows</emphasis></term>
7097   <listitem>
7098    <para>
7099     Many consider windows that move, or resize themselves to be abusive. This filter
7100     neutralizes the related JavaScript code. Note that some sites might not display
7101     or behave as intended when using this filter. Use with caution.
7102    </para>
7103   </listitem>
7104  </varlistentry>
7105
7106  <varlistentry>
7107   <term><emphasis>frameset-borders</emphasis></term>
7108   <listitem>
7109    <para>
7110     Some web designers seem to assume that everyone in the world will view their
7111     web sites using the same browser brand and version, screen resolution etc,
7112     because only that assumption could explain why they'd use static frame sizes,
7113     yet prevent their frames from being resized by the user, should they be too
7114     small to show their whole content.
7115    </para>
7116    <para>
7117     This filter removes the related HTML code. It should only be applied to sites
7118     which need it.
7119    </para>
7120   </listitem>
7121  </varlistentry>
7122
7123  <varlistentry>
7124   <term><emphasis>demoronizer</emphasis></term>
7125   <listitem>
7126    <para>
7127     Many Microsoft products that generate HTML use non-standard extensions (read:
7128     violations) of the ISO 8859-1 aka Latin-1 character set. This can cause those
7129     HTML documents to display with errors on standard-compliant platforms.
7130    </para>
7131    <para>
7132     This filter translates the MS-only characters into Latin-1 equivalents.
7133     It is not necessary when using MS products, and will cause corruption of
7134     all documents that use 8-bit character sets other than Latin-1. It's mostly
7135     worthwhile for Europeans on non-MS platforms, if weird garbage characters
7136     sometimes appear on some pages, or user agents that don't correct for this on
7137     the fly.
7138 <!--
7139     My version of Mozilla (ancient) shows litte square boxes for quote
7140     characters, and apostrophes on moronized pages. So many pages have this, I
7141     can read them fine now. HB 08/27/06
7142 -->
7143    </para>
7144   </listitem>
7145  </varlistentry>
7146
7147  <varlistentry>
7148   <term><emphasis>shockwave-flash</emphasis></term>
7149   <listitem>
7150    <para>
7151     A filter for shockwave haters. As the name suggests, this filter strips code
7152     out of web pages that is used to embed shockwave flash objects.
7153    </para>
7154    <para>
7155    </para>
7156   </listitem>
7157  </varlistentry>
7158
7159  <varlistentry>
7160   <term><emphasis>quicktime-kioskmode</emphasis></term>
7161   <listitem>
7162    <para>
7163     Change HTML code that embeds Quicktime objects so that kioskmode, which
7164     prevents saving, is disabled.
7165    </para>
7166   </listitem>
7167  </varlistentry>
7168
7169  <varlistentry>
7170   <term><emphasis>fun</emphasis></term>
7171   <listitem>
7172    <para>
7173     Text replacements for subversive browsing fun. Make fun of your favorite
7174     Monopolist or play buzzword bingo.
7175    </para>
7176   </listitem>
7177  </varlistentry>
7178
7179  <varlistentry>
7180   <term><emphasis>crude-parental</emphasis></term>
7181   <listitem>
7182    <para>
7183     A demonstration-only filter that shows how <application>Privoxy</application>
7184     can be used to delete web content on a keyword basis.
7185    </para>
7186   </listitem>
7187  </varlistentry>
7188
7189  <varlistentry>
7190   <term><emphasis>ie-exploits</emphasis></term>
7191   <listitem>
7192    <para>
7193     An experimental collection of text replacements to disable malicious HTML and JavaScript
7194     code that exploits known security holes in Internet Explorer.
7195    </para>
7196    <para>
7197     Presently, it only protects against Nimda and a cross-site scripting bug, and
7198     would need active maintenance to provide more substantial protection.
7199    </para>
7200   </listitem>
7201  </varlistentry>
7202
7203  <varlistentry>
7204   <term><emphasis>site-specifics</emphasis></term>
7205   <listitem>
7206    <para>
7207     Some web sites have very specific problems, the cure for which doesn't apply
7208     anywhere else, or could even cause damage on other sites.
7209    </para>
7210    <para>
7211     This is a collection of such site-specific cures which should only be applied
7212     to the sites they were intended for, which is what the supplied
7213     <filename>default.action</filename> file does. Users shouldn't need to change
7214     anything regarding this filter.
7215    </para>
7216   </listitem>
7217  </varlistentry>
7218
7219  <varlistentry>
7220   <term><emphasis>google</emphasis></term>
7221   <listitem>
7222    <para>
7223     A CSS based block for Google text ads. Also removes a width limitation
7224     and the toolbar advertisement.
7225    </para>
7226   </listitem>
7227  </varlistentry>
7228
7229   <varlistentry>
7230   <term><emphasis>yahoo</emphasis></term>
7231   <listitem>
7232    <para>
7233     Another CSS based block, this time for Yahoo text ads. And removes
7234     a width limitation as well.
7235    </para>
7236   </listitem>
7237  </varlistentry>
7238
7239   <varlistentry>
7240   <term><emphasis>msn</emphasis></term>
7241   <listitem>
7242    <para>
7243     Another CSS based block, this time for MSN text ads. And removes
7244     tracking URLs, as well as a width limitation.
7245    </para>
7246   </listitem>
7247  </varlistentry>
7248
7249  <varlistentry>
7250   <term><emphasis>blogspot</emphasis></term>
7251   <listitem>
7252    <para>
7253     Cleans up some Blogspot blogs. Read the fine print before using this one!
7254    </para>
7255    <para>
7256     This filter also intentionally removes some navigation stuff and sets the
7257     page width to 100%. As a result, some rounded <quote>corners</quote> would
7258     appear to early or not at all and as fixing this would require a browser
7259     that understands background-size (CSS3), they are removed instead.
7260    </para>
7261   </listitem>
7262  </varlistentry>
7263
7264   <varlistentry>
7265   <term><emphasis>xml-to-html</emphasis></term>
7266   <listitem>
7267    <para>
7268     Server-header filter to change the Content-Type from xml to html.
7269    </para>
7270   </listitem>
7271  </varlistentry>
7272
7273   <varlistentry>
7274   <term><emphasis>html-to-xml</emphasis></term>
7275   <listitem>
7276    <para>
7277     Server-header filter to change the Content-Type from html to xml.
7278    </para>
7279   </listitem>
7280  </varlistentry>
7281
7282   <varlistentry>
7283   <term><emphasis>no-ping</emphasis></term>
7284   <listitem>
7285    <para>
7286     Removes the non-standard <literal>ping</literal> attribute from
7287     anchor and area HTML tags.
7288    </para>
7289   </listitem>
7290  </varlistentry>
7291
7292   <varlistentry>
7293   <term><emphasis>hide-tor-exit-notation</emphasis></term>
7294   <listitem>
7295    <para>
7296     Client-header filter to remove the <command>Tor</command> exit node notation
7297     found in Host and Referer headers.
7298    </para>
7299    <para>
7300     If &my-app; and <command>Tor</command> are chained and &my-app;
7301     is configured to use socks4a, one can use <quote>http://www.example.org.foobar.exit/</quote>
7302     to access the host <quote>www.example.org</quote> through the
7303     <command>Tor</command> exit node <quote>foobar</quote>.
7304    </para>
7305    <para>
7306     As the HTTP client isn't aware of this notation, it treats the
7307     whole string <quote>www.example.org.foobar.exit</quote> as host and uses it
7308     for the <quote>Host</quote> and <quote>Referer</quote> headers. From the
7309     server's point of view the resulting headers are invalid and can cause problems.
7310    </para>
7311    <para>
7312     An invalid <quote>Referer</quote> header can trigger <quote>hot-linking</quote>
7313     protections, an invalid <quote>Host</quote> header will make it impossible for
7314     the server to find the right vhost (several domains hosted on the same IP address).
7315    </para>
7316    <para>
7317     This client-header filter removes the <quote>foo.exit</quote> part in those headers
7318     to prevent the mentioned problems. Note that it only modifies
7319     the HTTP headers, it doesn't make it impossible for the server
7320     to detect your <command>Tor</command> exit node based on the IP address
7321     the request is coming from.
7322    </para>
7323   </listitem>
7324  </varlistentry>
7325
7326 <!--
7327  <varlistentry>
7328   <term><emphasis> </emphasis></term>
7329   <listitem>
7330    <para>
7331    </para>
7332    <para>
7333    </para>
7334   </listitem>
7335  </varlistentry>
7336 -->
7337 </variablelist>
7338
7339 </sect2>
7340
7341 <!--   ~~~~~~~~       New section Header    ~~~~~~~~~     -->
7342 <sect2 id="external-filter-syntax"><title>External filter syntax</title>
7343 <para>
7344  External filters are scripts or programs that can modify the content in
7345  case common <literal><link linkend="filter">filters</link></literal>
7346  aren't powerful enough.
7347 </para>
7348 <para>
7349  External filters can be written in any language the platform &my-app; runs
7350  on supports.
7351 </para>
7352 <para>
7353  They are controlled with the
7354  <literal><link linkend="external-filter">external-filter</link></literal> action
7355  and have to be defined in the <literal><link linkend="filterfile">filterfile</link></literal>
7356  first.
7357 </para>
7358 <para>
7359  The header looks like any other filter, but instead of pcrs jobs, external
7360  filters contain a single job which can be a program or a shell script (which
7361  may call other scripts or programs).
7362 </para>
7363 <para>
7364  External filters read the content from STDIN and write the rewritten
7365  content to STDOUT.
7366  The environment variables PRIVOXY_URL, PRIVOXY_PATH, PRIVOXY_HOST,
7367  PRIVOXY_ORIGIN, PRIVOXY_LISTEN_ADDRESS can be used to get some details
7368  about the client request.
7369 </para>
7370 <para>
7371  &my-app; will temporary store the content to filter in the
7372  <literal><link linkend="temporary-directory">temporary-directory</link></literal>.
7373 </para>
7374
7375  <screen>
7376 EXTERNAL-FILTER: cat Pointless example filter that doesn't actually modify the content
7377 /bin/cat
7378
7379 # Incorrect reimplementation of the filter above in POSIX shell.
7380 #
7381 # Note that it's a single job that spans multiple lines, the line
7382 # breaks are not passed to the shell, thus the semicolons are required.
7383 #
7384 # If the script isn't trivial, it is recommended to put it into an external file.
7385 #
7386 # In general, writing external filters entirely in POSIX shell is not
7387 # considered a good idea.
7388 EXTERNAL-FILTER: cat2 Pointless example filter that despite its name may actually modify the content
7389 while read line; \
7390 do \
7391   echo "$line"; \
7392 done
7393
7394 EXTERNAL-FILTER: rotate-image Rotate an image by 180 degree. Test filter with limited value.
7395 /usr/local/bin/convert - -rotate 180 -
7396
7397 EXTERNAL-FILTER: citation-needed Adds a "[citation needed]" tag to an image. The coordinates may need adjustment.
7398 /usr/local/bin/convert - -pointsize 16 -fill white  -annotate +17+418 "[citation needed]" -
7399 </screen>
7400
7401 <warning>
7402  <para>
7403   Currently external filters are executed with &my-app;'s privileges!
7404   Only use external filters you understand and trust.
7405  </para>
7406 </warning>
7407 <para>
7408  External filters are experimental and the syntax may change in the future.
7409 </para>
7410 </sect2>
7411
7412 </sect1>
7413
7414 <!--  ~  End section  ~  -->
7415
7416
7417
7418 <!--   ~~~~~       New section      ~~~~~     -->
7419
7420 <sect1 id="templates">
7421 <title>Privoxy's Template Files</title>
7422 <para>
7423  All <application>Privoxy</application> built-in pages, i.e. error pages such as the
7424  <ulink url="http://show-the-404-error.page"><quote>404 - No Such Domain</quote>
7425  error page</ulink>, the <ulink
7426  url="http://ads.bannerserver.example.com/nasty-ads/sponsor.html"><quote>BLOCKED</quote>
7427  page</ulink>
7428  and all pages of its <ulink url="http://config.privoxy.org/">web-based
7429  user interface</ulink>, are generated from <emphasis>templates</emphasis>.
7430  (<application>Privoxy</application> must be running for the above links to work as
7431  intended.)
7432 </para>
7433
7434 <para>
7435  These templates are stored in a subdirectory of the <link linkend="confdir">configuration
7436  directory</link> called <filename>templates</filename>. On Unixish platforms,
7437  this is typically
7438  <ulink url="file:///etc/privoxy/templates/"><filename>/etc/privoxy/templates/</filename></ulink>.
7439 </para>
7440
7441 <para>
7442  The templates are basically normal HTML files, but with place-holders (called symbols
7443  or exports), which <application>Privoxy</application> fills at run time. It
7444  is possible to edit the templates with a normal text editor, should you want
7445  to customize them. (<emphasis>Not recommended for the casual
7446  user</emphasis>). Should you create your own custom templates, you should use
7447  the <filename>config</filename> setting <link linkend="templdir">templdir</link>
7448  to specify an alternate location, so your templates do not get overwritten
7449  during upgrades.
7450  </para>
7451  <para>
7452  Note that just like in configuration files, lines starting
7453  with <literal>#</literal> are ignored when the templates are filled in.
7454 </para>
7455
7456 <para>
7457  The place-holders are of the form <literal>@name@</literal>, and you will
7458  find a list of available symbols, which vary from template to template,
7459  in the comments at the start of each file. Note that these comments are not
7460  always accurate, and that it's probably best to look at the existing HTML
7461  code to find out which symbols are supported and what they are filled in with.
7462 </para>
7463
7464 <para>
7465  A special application of this substitution mechanism is to make whole
7466  blocks of HTML code disappear when a specific symbol is set. We use this
7467  for many purposes, one of them being to include the beta warning in all
7468  our user interface (CGI) pages when <application>Privoxy</application>
7469  is in an alpha or beta development stage:
7470 </para>
7471
7472  <screen>
7473 &lt;!-- @if-unstable-start --&gt;
7474
7475   ... beta warning HTML code goes here ...
7476
7477 &lt;!-- if-unstable-end@ --&gt;</screen>
7478
7479 <para>
7480  If the "unstable" symbol is set, everything in between and including
7481  <literal>@if-unstable-start</literal> and <literal>if-unstable-end@</literal>
7482  will disappear, leaving nothing but an empty comment:
7483 </para>
7484
7485  <screen>&lt;!--  --&gt;</screen>
7486
7487 <para>
7488  There's also an if-then-else construct and an <literal>#include</literal>
7489  mechanism, but you'll sure find out if you are inclined to edit the
7490  templates ;-)
7491 </para>
7492
7493 <para>
7494  All templates refer to a style located at
7495  <ulink url="http://config.privoxy.org/send-stylesheet"><literal>http://config.privoxy.org/send-stylesheet</literal></ulink>.
7496  This is, of course, locally served by <application>Privoxy</application>
7497  and the source for it can be found and edited in the
7498  <filename>cgi-style.css</filename> template.
7499 </para>
7500
7501 </sect1>
7502
7503 <!--  ~  End section  ~  -->
7504
7505
7506
7507 <!--   ~~~~~       New section      ~~~~~     -->
7508
7509 <sect1 id="contact"><title>Contacting the Developers, Bug Reporting and Feature
7510 Requests</title>
7511
7512 <!-- Include contacting.sgml boilerplate: -->
7513  &contacting;
7514 <!-- end boilerplate -->
7515
7516 </sect1>
7517
7518 <!--  ~  End section  ~  -->
7519
7520
7521 <!--   ~~~~~       New section      ~~~~~     -->
7522 <sect1 id="copyright"><title>Privoxy Copyright, License and History</title>
7523
7524 <!-- Include copyright.sgml: -->
7525  &copyright;
7526 <!-- end copyright -->
7527
7528 <para>
7529  <application>Privoxy</application> is free software; you can
7530  redistribute it and/or modify it under the terms of the
7531  <citetitle>GNU General Public License</citetitle>, version 2,
7532  as published by the Free Software Foundation and included in
7533  the next section.
7534 </para>
7535
7536 <!--   ~~~~~       New section      ~~~~~     -->
7537 <sect2 id="license"><title>License</title>
7538
7539  <screen><![ RCDATA [ &GPLv2; ]]></screen>
7540
7541 </sect2>
7542 <!--  ~  End section  ~  -->
7543
7544
7545 <!--   ~~~~~       New section      ~~~~~     -->
7546
7547 <sect2 id="history"><title>History</title>
7548 <!-- Include history.sgml: -->
7549  &history;
7550 <!-- end history -->
7551 </sect2>
7552
7553 <sect2 id="authors"><title>Authors</title>
7554 <!-- Include p-authors.sgml: -->
7555  &p-authors;
7556 <!-- end authors -->
7557 </sect2>
7558
7559 </sect1>
7560
7561 <!--  ~  End section  ~  -->
7562
7563
7564 <!--   ~~~~~       New section      ~~~~~     -->
7565 <sect1 id="seealso"><title>See Also</title>
7566 <!-- Include seealso.sgml: -->
7567  &seealso;
7568 <!-- end seealso -->
7569 </sect1>
7570
7571
7572
7573 <!--   ~~~~~       New section      ~~~~~     -->
7574 <sect1 id="appendix"><title>Appendix</title>
7575
7576
7577 <!--   ~~~~~       New section      ~~~~~     -->
7578 <sect2 id="regex">
7579 <title>Regular Expressions</title>
7580 <para>
7581  <application>Privoxy</application> uses Perl-style <quote>regular
7582  expressions</quote> in its <link linkend="actions-file">actions
7583  files</link> and <link linkend="filter-file">filter file</link>,
7584  through the <ulink url="http://www.pcre.org/">PCRE</ulink> and
7585 <!--
7586  dead 08/27/06
7587  <ulink url="http://www.oesterhelt.org/pcrs/">PCRS</ulink> libraries.
7588 -->
7589  <application>PCRS</application> libraries.
7590 </para>
7591
7592 <para>
7593  If you are reading this, you probably don't understand what <quote>regular
7594  expressions</quote> are, or what they can do. So this will be a very brief
7595  introduction only. A full explanation would require a <ulink
7596  url="http://www.oreilly.com/catalog/regex/">book</ulink> ;-)
7597 </para>
7598
7599 <para>
7600  Regular expressions provide a language to describe patterns that can be
7601  run against strings of characters (letter, numbers, etc), to see if they
7602  match the string or not. The  patterns are themselves (sometimes complex)
7603  strings of literal characters, combined with  wild-cards, and other special
7604  characters, called meta-characters. The <quote>meta-characters</quote> have
7605  special meanings and are used to build complex patterns to be matched against.
7606  Perl Compatible Regular Expressions are an especially convenient
7607  <quote>dialect</quote> of the regular expression language.
7608 </para>
7609
7610 <para>
7611  To make a simple analogy, we do something similar when we use wild-card
7612  characters when listing files with the <command>dir</command> command in DOS.
7613  <literal>*.*</literal> matches all filenames. The <quote>special</quote>
7614  character here is the asterisk which matches any and all characters. We can be
7615  more specific and use <literal>?</literal> to match just individual
7616  characters. So <quote>dir file?.text</quote> would match
7617  <quote>file1.txt</quote>, <quote>file2.txt</quote>, etc. We are pattern
7618  matching, using a similar technique to <quote>regular expressions</quote>!
7619 </para>
7620
7621 <para>
7622  Regular expressions do essentially the same thing, but are much, much more
7623  powerful. There are many more <quote>special characters</quote> and ways of
7624  building complex patterns however. Let's look at a few of the common ones,
7625  and then some examples:
7626 </para>
7627
7628 <simplelist>
7629  <member>
7630   <emphasis>.</emphasis> - Matches any single character, e.g. <quote>a</quote>,
7631   <quote>A</quote>, <quote>4</quote>, <quote>:</quote>, or <quote>@</quote>.
7632  </member>
7633 </simplelist>
7634
7635 <simplelist>
7636  <member>
7637   <emphasis>?</emphasis> - The preceding character or expression is matched ZERO or ONE
7638   times. Either/or.
7639  </member>
7640 </simplelist>
7641
7642 <simplelist>
7643  <member>
7644   <emphasis>+</emphasis> - The preceding character or expression is matched ONE or MORE
7645   times.
7646  </member>
7647 </simplelist>
7648
7649 <simplelist>
7650  <member>
7651   <emphasis>*</emphasis> - The preceding character or expression is matched ZERO or MORE
7652   times.
7653  </member>
7654 </simplelist>
7655
7656 <simplelist>
7657  <member>
7658   <emphasis>\</emphasis> - The <quote>escape</quote> character denotes that
7659   the following character should be taken literally. This is used where one of the
7660   special characters (e.g. <quote>.</quote>) needs to be taken literally and
7661   not as a special meta-character. Example: <quote>example\.com</quote>, makes
7662   sure the period is recognized only as a period (and not expanded to its
7663   meta-character meaning of any single character).
7664  </member>
7665 </simplelist>
7666
7667 <simplelist>
7668  <member>
7669   <emphasis>[ ]</emphasis> - Characters enclosed in brackets will be matched if
7670   any of the enclosed characters are encountered. For instance, <quote>[0-9]</quote>
7671   matches any numeric digit (zero through nine). As an example, we can combine
7672   this with <quote>+</quote> to match any digit one of more times: <quote>[0-9]+</quote>.
7673  </member>
7674 </simplelist>
7675
7676 <simplelist>
7677  <member>
7678   <emphasis>( )</emphasis> - parentheses are used to group a sub-expression,
7679   or multiple sub-expressions.
7680  </member>
7681 </simplelist>
7682
7683 <simplelist>
7684  <member>
7685   <emphasis>|</emphasis> - The <quote>bar</quote> character works like an
7686   <quote>or</quote> conditional statement. A match is successful if the
7687   sub-expression on either side of <quote>|</quote> matches. As an example:
7688   <quote>/(this|that) example/</quote> uses grouping and the bar character
7689   and would match either <quote>this example</quote> or <quote>that
7690   example</quote>, and nothing else.
7691  </member>
7692 </simplelist>
7693
7694 <para>
7695  These are just some of the ones you are likely to use when matching URLs with
7696  <application>Privoxy</application>, and is a long way from a definitive
7697  list. This is enough to get us started with a few simple examples which may
7698  be more illuminating:
7699 </para>
7700
7701 <para>
7702  <emphasis><literal>/.*/banners/.*</literal></emphasis> - A  simple example
7703  that uses the common combination of <quote>.</quote> and <quote>*</quote> to
7704  denote any character, zero or more times. In other words, any string at all.
7705  So we start with a literal forward slash, then our regular expression pattern
7706  (<quote>.*</quote>) another literal forward slash, the string
7707  <quote>banners</quote>, another forward slash, and lastly another
7708  <quote>.*</quote>. We are building
7709  a directory path here. This will match any file with the path that has a
7710  directory named <quote>banners</quote> in it. The <quote>.*</quote> matches
7711  any characters, and this could conceivably be more forward slashes, so it
7712  might expand into a much longer looking path. For example, this could match:
7713  <quote>/eye/hate/spammers/banners/annoy_me_please.gif</quote>, or just
7714  <quote>/banners/annoying.html</quote>, or almost an infinite number of other
7715  possible combinations, just so it has <quote>banners</quote> in the path
7716  somewhere.
7717 </para>
7718
7719 <para>
7720  And now something a little more complex:
7721 </para>
7722
7723 <para>
7724  <emphasis><literal>/.*/adv((er)?ts?|ertis(ing|ements?))?/</literal></emphasis> -
7725  We have several literal forward slashes again (<quote>/</quote>), so we are
7726  building another expression that is a file path statement. We have another
7727  <quote>.*</quote>, so we are matching against any conceivable sub-path, just so
7728  it matches our expression. The only true literal that <emphasis>must
7729  match</emphasis> our pattern is <application>adv</application>, together with
7730  the forward slashes. What comes after the <quote>adv</quote> string is the
7731  interesting part.
7732 </para>
7733
7734 <para>
7735  Remember the <quote>?</quote> means the preceding expression (either a
7736  literal character or anything grouped with <quote>(...)</quote> in this case)
7737  can exist or not, since this means either zero or one match. So
7738  <quote>((er)?ts?|ertis(ing|ements?))</quote> is optional, as are the
7739  individual sub-expressions: <quote>(er)</quote>,
7740  <quote>(ing|ements?)</quote>, and the <quote>s</quote>. The <quote>|</quote>
7741  means <quote>or</quote>. We have two of those. For instance,
7742  <quote>(ing|ements?)</quote>, can expand to match either <quote>ing</quote>
7743  <emphasis>OR</emphasis> <quote>ements?</quote>. What is being done here, is an
7744  attempt at matching as many variations of <quote>advertisement</quote>, and
7745  similar, as possible. So this would expand to match just <quote>adv</quote>,
7746  or <quote>advert</quote>, or <quote>adverts</quote>, or
7747  <quote>advertising</quote>, or <quote>advertisement</quote>, or
7748  <quote>advertisements</quote>. You get the idea. But it would not match
7749  <quote>advertizements</quote> (with a <quote>z</quote>). We could fix that by
7750  changing our regular expression to:
7751  <quote>/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/</quote>, which would then match
7752  either spelling.
7753 </para>
7754
7755 <para>
7756  <emphasis><literal>/.*/advert[0-9]+\.(gif|jpe?g)</literal></emphasis> - Again
7757  another path statement with forward slashes. Anything in the square brackets
7758  <quote>[ ]</quote> can be matched. This is using <quote>0-9</quote> as a
7759  shorthand expression to mean any digit one through nine. It is the same as
7760  saying <quote>0123456789</quote>. So any digit matches. The <quote>+</quote>
7761  means one or more of the preceding expression must be included. The preceding
7762  expression here is what is in the square brackets -- in this case, any digit
7763  one through nine. Then, at the end, we have a grouping: <quote>(gif|jpe?g)</quote>.
7764  This includes a <quote>|</quote>, so this needs to match the expression on
7765  either side of that bar character also. A simple <quote>gif</quote> on one side, and the other
7766  side will in turn match either <quote>jpeg</quote> or <quote>jpg</quote>,
7767  since the <quote>?</quote> means the letter <quote>e</quote> is optional and
7768  can be matched once or not at all. So we are building an expression here to
7769  match image GIF or JPEG type image file. It must include the literal
7770  string <quote>advert</quote>, then one or more digits, and a <quote>.</quote>
7771  (which is now a literal, and not a special character, since it is escaped
7772  with <quote>\</quote>), and lastly either <quote>gif</quote>, or
7773  <quote>jpeg</quote>, or <quote>jpg</quote>. Some possible matches would
7774  include: <quote>//advert1.jpg</quote>,
7775  <quote>/nasty/ads/advert1234.gif</quote>,
7776  <quote>/banners/from/hell/advert99.jpg</quote>. It would not match
7777  <quote>advert1.gif</quote> (no leading slash), or
7778  <quote>/adverts232.jpg</quote> (the expression does not include an
7779  <quote>s</quote>), or <quote>/advert1.jsp</quote> (<quote>jsp</quote> is not
7780  in the expression anywhere).
7781 </para>
7782
7783 <para>
7784  We are barely scratching the surface of regular expressions here so that you
7785  can understand the default <application>Privoxy</application>
7786  configuration files, and maybe use this knowledge to customize your own
7787  installation. There is much, much more that can be done with regular
7788  expressions. Now that you know enough to get started, you can learn more on
7789  your own :/
7790 </para>
7791
7792 <para>
7793  More reading on Perl Compatible Regular expressions:
7794  <ulink url="http://perldoc.perl.org/perlre.html">http://perldoc.perl.org/perlre.html</ulink>
7795 </para>
7796
7797 <para>
7798  For information on regular expression based substitutions and their applications
7799  in filters, please see the <link linkend="filter-file">filter file tutorial</link>
7800  in this manual.
7801 </para>
7802 </sect2>
7803
7804 <!--  ~  End section  ~  -->
7805
7806
7807 <!--   ~~~~~       New section      ~~~~~     -->
7808 <sect2 id="internal-pages">
7809 <title>Privoxy's Internal Pages</title>
7810
7811 <para>
7812  Since <application>Privoxy</application> proxies each requested
7813  web page, it is easy for <application>Privoxy</application> to
7814  trap certain special URLs. In this way, we can talk directly to
7815  <application>Privoxy</application>, and see how it is
7816  configured, see how our rules are being applied, change these
7817  rules and other configuration options, and even turn
7818  <application>Privoxy's</application> filtering off, all with
7819  a web browser.
7820 </para>
7821
7822 <para>
7823  The URLs listed below are the special ones that allow direct access
7824  to <application>Privoxy</application>. Of course,
7825  <application>Privoxy</application> must be running to access these. If
7826  not, you will get a friendly error message. Internet access is not
7827  necessary either.
7828 </para>
7829
7830  <itemizedlist>
7831
7832  <listitem>
7833   <para>
7834    Privoxy main page:
7835   </para>
7836   <blockquote>
7837    <para>
7838      <ulink url="http://config.privoxy.org/">http://config.privoxy.org/</ulink>
7839    </para>
7840   </blockquote>
7841   <para>
7842    There is a shortcut: <ulink url="http://p.p/">http://p.p/</ulink> (But it
7843    doesn't provide a fall-back to a real page, in case the request is not
7844    sent through <application>Privoxy</application>)
7845   </para>
7846  </listitem>
7847
7848  <listitem>
7849   <para>
7850     Show information about the current configuration, including viewing and
7851     editing of actions files:
7852   </para>
7853    <blockquote>
7854    <para>
7855     <ulink url="http://config.privoxy.org/show-status">http://config.privoxy.org/show-status</ulink>
7856    </para>
7857   </blockquote>
7858  </listitem>
7859
7860  <listitem>
7861   <para>
7862     Show the source code version numbers:
7863   </para>
7864   <blockquote>
7865    <para>
7866     <ulink url="http://config.privoxy.org/show-version">http://config.privoxy.org/show-version</ulink>
7867    </para>
7868   </blockquote>
7869  </listitem>
7870
7871  <listitem>
7872   <para>
7873    Show the browser's request headers:
7874   </para>
7875   <blockquote>
7876    <para>
7877     <ulink url="http://config.privoxy.org/show-request">http://config.privoxy.org/show-request</ulink>
7878    </para>
7879   </blockquote>
7880  </listitem>
7881
7882  <listitem>
7883   <para>
7884    Show which actions apply to a URL and why:
7885   </para>
7886    <blockquote>
7887    <para>
7888     <ulink url="http://config.privoxy.org/show-url-info">http://config.privoxy.org/show-url-info</ulink>
7889    </para>
7890   </blockquote>
7891  </listitem>
7892
7893  <listitem>
7894   <para>
7895    Toggle Privoxy on or off. This feature can be turned off/on in the main
7896    <filename>config</filename> file. When toggled <quote>off</quote>, <quote>Privoxy</quote>
7897    continues to run, but only as a pass-through proxy, with no actions taking
7898    place:
7899   </para>
7900    <blockquote>
7901    <para>
7902     <ulink url="http://config.privoxy.org/toggle">http://config.privoxy.org/toggle</ulink>
7903    </para>
7904   </blockquote>
7905   <para>
7906    Short cuts. Turn off, then on:
7907   </para>
7908    <blockquote>
7909    <para>
7910      <ulink url="http://config.privoxy.org/toggle?set=disable">http://config.privoxy.org/toggle?set=disable</ulink>
7911    </para>
7912   </blockquote>
7913    <blockquote>
7914    <para>
7915      <ulink url="http://config.privoxy.org/toggle?set=enable">http://config.privoxy.org/toggle?set=enable</ulink>
7916    </para>
7917   </blockquote>
7918  </listitem>
7919
7920  </itemizedlist>
7921
7922 </sect2>
7923
7924
7925 <!--   ~~~~~       New section      ~~~~~     -->
7926 <sect2 id="chain">
7927 <title>Chain of Events</title>
7928 <para>
7929  Let's take a quick look at how some of <application>Privoxy's</application>
7930  core features are triggered, and the ensuing sequence of events when a web
7931  page is requested by your browser:
7932 </para>
7933
7934  <itemizedlist>
7935  <listitem>
7936   <para>
7937    First, your web browser requests a web page. The browser knows to send
7938    the request to <application>Privoxy</application>, which will in turn,
7939    relay the request to the remote web server after passing the following
7940    tests:
7941   </para>
7942  </listitem>
7943  <listitem>
7944   <para>
7945    <application>Privoxy</application> traps any request for its own internal CGI
7946    pages (e.g <ulink url="http://p.p/">http://p.p/</ulink>) and sends the CGI page back to the browser.
7947   </para>
7948  </listitem>
7949  <listitem>
7950   <para>
7951    Next, <application>Privoxy</application> checks to see if the URL
7952    matches any <link
7953    linkend="BLOCK"><quote>+block</quote></link> patterns. If
7954    so, the URL is then blocked, and the remote web server will not be contacted.
7955    <link linkend="HANDLE-AS-IMAGE"><quote>+handle-as-image</quote></link>
7956    and
7957    <link linkend="HANDLE-AS-EMPTY-DOCUMENT"><quote>+handle-as-empty-document</quote></link>
7958    are then checked, and if there is no match, an
7959    HTML <quote>BLOCKED</quote> page is sent back to the browser. Otherwise, if
7960    it does match, an image is returned for the former, and an empty text
7961    document for the latter. The type of image would depend on the setting of
7962    <link linkend="SET-IMAGE-BLOCKER"><quote>+set-image-blocker</quote></link>
7963    (blank, checkerboard pattern, or an HTTP redirect to an image elsewhere).
7964   </para>
7965  </listitem>
7966  <listitem>
7967   <para>
7968    Untrusted URLs are blocked. If URLs are being added to the
7969    <filename>trust</filename> file, then that is done.
7970   </para>
7971  </listitem>
7972  <listitem>
7973   <para>
7974    If the URL pattern matches the <link
7975    linkend="FAST-REDIRECTS"><quote>+fast-redirects</quote></link> action,
7976    it is then processed. Unwanted parts of the requested URL are stripped.
7977   </para>
7978  </listitem>
7979  <listitem>
7980   <para>
7981    Now the rest of the client browser's request headers are processed. If any
7982    of these match any of the relevant actions (e.g. <link
7983    linkend="HIDE-USER-AGENT"><quote>+hide-user-agent</quote></link>,
7984    etc.), headers are suppressed or forged as determined by these actions and
7985    their parameters.
7986   </para>
7987  </listitem>
7988  <listitem>
7989   <para>
7990    Now the web server starts sending its response back (i.e. typically a web
7991    page).
7992   </para>
7993  </listitem>
7994  <listitem>
7995   <para>
7996    First, the server headers are read and processed to determine, among other
7997    things, the MIME type (document type) and encoding. The headers are then
7998    filtered as determined by the
7999    <link linkend="CRUNCH-INCOMING-COOKIES"><quote>+crunch-incoming-cookies</quote></link>,
8000    <link linkend="SESSION-COOKIES-ONLY"><quote>+session-cookies-only</quote></link>,
8001    and <link linkend="DOWNGRADE-HTTP-VERSION"><quote>+downgrade-http-version</quote></link>
8002    actions.
8003   </para>
8004  </listitem>
8005  <listitem>
8006   <para>
8007    If any <link linkend="FILTER"><quote>+filter</quote></link> action
8008    or <link
8009    linkend="DEANIMATE-GIFS"><quote>+deanimate-gifs</quote></link>
8010    action applies (and the document type fits the action), the rest of the page is
8011    read into memory (up to a configurable limit). Then the filter rules (from
8012    <filename>default.filter</filename> and any other filter files) are
8013    processed against the buffered content. Filters are applied in the order
8014    they are specified in one of the filter files. Animated GIFs, if present,
8015    are reduced to either the first or last frame, depending on the action
8016    setting.The entire page, which is now filtered, is then sent by
8017    <application>Privoxy</application> back to your browser.
8018   </para>
8019   <para>
8020    If neither a <link linkend="FILTER"><quote>+filter</quote></link> action
8021    or <link
8022    linkend="DEANIMATE-GIFS"><quote>+deanimate-gifs</quote></link>
8023    matches, then <application>Privoxy</application> passes the raw data through
8024    to the client browser as it becomes available.
8025   </para>
8026  </listitem>
8027  <listitem>
8028   <para>
8029    As the browser receives the now (possibly filtered) page content, it
8030    reads and then requests any URLs that may be embedded within the page
8031    source, e.g. ad images, stylesheets, JavaScript, other HTML documents (e.g.
8032    frames), sounds, etc. For each of these objects, the browser issues a
8033    separate request (this is easily viewable in <application>Privoxy's</application>
8034    logs). And each such request is in turn processed just as above. Note that a
8035    complex web page will have many, many such embedded URLs. If these
8036    secondary requests are to a different server, then quite possibly a very
8037    differing set of actions is triggered.
8038   </para>
8039  </listitem>
8040
8041  </itemizedlist>
8042
8043 <para>
8044  NOTE: This is somewhat of a simplistic overview of what happens with each URL
8045  request. For the sake of brevity and simplicity, we have focused on
8046  <application>Privoxy's</application> core features only.
8047 </para>
8048
8049 </sect2>
8050
8051
8052 <!--   ~~~~~       New section      ~~~~~     -->
8053 <sect2 id="actionsanat">
8054 <title>Troubleshooting: Anatomy of an Action</title>
8055
8056 <para>
8057  The way <application>Privoxy</application> applies
8058  <link linkend="ACTIONS">actions</link> and <link linkend="FILTER">filters</link>
8059  to any given URL can be complex, and not always so
8060  easy to understand what is happening. And sometimes we need to be able to
8061  <emphasis>see</emphasis> just what <application>Privoxy</application> is
8062  doing. Especially, if something <application>Privoxy</application> is doing
8063  is causing us a problem inadvertently. It can be a little daunting to look at
8064  the actions and filters files themselves, since they tend to be filled with
8065  <link linkend="regex">regular expressions</link> whose consequences are not
8066  always so obvious.
8067 </para>
8068
8069 <para>
8070  One quick test to see if <application>Privoxy</application> is causing a problem
8071  or not, is to disable it temporarily. This should be the first troubleshooting
8072  step (be sure to flush caches afterward!). Looking at the
8073  logs is a good idea too. (Note that both the toggle feature and logging are
8074  enabled via <filename>config</filename> file settings, and may need to be
8075  turned <quote>on</quote>.)
8076 </para>
8077 <para>
8078  Another easy troubleshooting step to try is if you have done any
8079  customization of your installation, revert back to the installed
8080  defaults and see if that helps. There are times the developers get complaints
8081  about one thing or another, and the problem is more related to a customized
8082  configuration issue.
8083 </para>
8084
8085 <para>
8086  <application>Privoxy</application> also provides the
8087  <ulink url="http://config.privoxy.org/show-url-info">http://config.privoxy.org/show-url-info</ulink>
8088  page that can show us very specifically how <application>actions</application>
8089  are being applied to any given URL. This is a big help for troubleshooting.
8090 </para>
8091
8092 <para>
8093  First, enter one URL (or partial URL) at the prompt, and then
8094  <application>Privoxy</application> will tell us
8095  how the current configuration will handle it. This will not
8096  help with filtering effects (i.e. the <link
8097  linkend="FILTER"><quote>+filter</quote></link> action) from
8098  one of the filter files since this is handled very
8099  differently and not so easy to trap! It also will not tell you about any other
8100  URLs that may be embedded within the URL you are testing. For instance, images
8101  such as ads are expressed as URLs within the raw page source of HTML pages. So
8102  you will only get info for the actual URL that is pasted into the prompt area
8103  -- not any sub-URLs. If you want to know about embedded URLs like ads, you
8104  will have to dig those out of the HTML source. Use your browser's <quote>View
8105  Page Source</quote> option for this. Or right click on the ad, and grab the
8106  URL.
8107 </para>
8108
8109 <para>
8110  Let's try an example, <ulink url="http://google.com">google.com</ulink>,
8111  and look at it one section at a time in a sample configuration (your real
8112  configuration may vary):
8113 </para>
8114
8115  <screen>
8116  Matches for http://www.google.com:
8117
8118  In file: default.action <guibutton>[ View ]</guibutton> <guibutton>[ Edit ]</guibutton>
8119
8120  {+change-x-forwarded-for{block}
8121  +deanimate-gifs {last}
8122  +fast-redirects {check-decoded-url}
8123  +filter {refresh-tags}
8124  +filter {img-reorder}
8125  +filter {banners-by-size}
8126  +filter {webbugs}
8127  +filter {jumping-windows}
8128  +filter {ie-exploits}
8129  +hide-from-header {block}
8130  +hide-referrer {forge}
8131  +session-cookies-only
8132  +set-image-blocker {pattern}
8133 /
8134
8135  { -session-cookies-only }
8136  .google.com
8137
8138  { -fast-redirects }
8139  .google.com
8140
8141 In file: user.action <guibutton>[ View ]</guibutton> <guibutton>[ Edit ]</guibutton>
8142 (no matches in this file)
8143 </screen>
8144
8145 <para>
8146  This is telling us how we have defined our
8147  <link linkend="ACTIONS"><quote>actions</quote></link>, and
8148  which ones match for our test case, <quote>google.com</quote>.
8149  Displayed is all the actions that are available to us. Remember,
8150  the <literal>+</literal> sign denotes <quote>on</quote>. <literal>-</literal>
8151  denotes <quote>off</quote>. So some are <quote>on</quote> here, but many
8152  are <quote>off</quote>. Each example we try may provide a slightly different
8153  end result, depending on our configuration directives.
8154 </para>
8155 <para>
8156  The first listing
8157   is for our <filename>default.action</filename> file. The large, multi-line
8158   listing, is how the actions are set to match for all URLs, i.e. our default
8159   settings. If you look at your <quote>actions</quote> file, this would be the
8160   section just below the <quote>aliases</quote> section near the top. This
8161   will apply to all URLs as signified by the single forward slash at the end
8162   of the listing -- <quote> / </quote>.
8163 </para>
8164
8165 <para>
8166  But we have defined additional actions that would be exceptions to these general
8167  rules, and then we list specific URLs (or patterns) that these exceptions
8168  would apply to. Last match wins. Just below this then are two explicit
8169  matches for <quote>.google.com</quote>. The first is negating our previous
8170  cookie setting, which was for <link
8171  linkend="SESSION-COOKIES-ONLY"><quote>+session-cookies-only</quote></link>
8172  (i.e. not persistent). So we will allow persistent cookies for google, at
8173  least that is how it is in this example. The second turns
8174  <emphasis>off</emphasis> any <link
8175  linkend="FAST-REDIRECTS"><quote>+fast-redirects</quote></link>
8176  action, allowing this to take place unmolested. Note that there is a leading
8177  dot here -- <quote>.google.com</quote>. This will match any hosts and
8178  sub-domains, in the google.com domain also, such as
8179  <quote>www.google.com</quote> or <quote>mail.google.com</quote>. But it would not
8180  match <quote>www.google.de</quote>! So, apparently, we have these two actions
8181  defined as exceptions to the general rules at the top somewhere in the lower
8182  part of our <filename>default.action</filename> file, and
8183  <quote>google.com</quote> is referenced somewhere in these latter sections.
8184 </para>
8185
8186 <para>
8187  Then, for our <filename>user.action</filename> file, we again have no hits.
8188  So there is nothing google-specific that we might have added to our own, local
8189  configuration. If there was, those actions would over-rule any actions from
8190  previously processed files, such as <filename>default.action</filename>.
8191  <filename>user.action</filename> typically has the last word. This is the
8192  best place to put hard and fast exceptions,
8193 </para>
8194
8195 <para>
8196  And finally we pull it all together in the bottom section and summarize how
8197  <application>Privoxy</application> is applying all its <quote>actions</quote>
8198  to <quote>google.com</quote>:
8199 </para>
8200
8201  <screen>
8202  Final results:
8203
8204  -add-header
8205  -block
8206  +change-x-forwarded-for{block}
8207  -client-header-filter{hide-tor-exit-notation}
8208  -content-type-overwrite
8209  -crunch-client-header
8210  -crunch-if-none-match
8211  -crunch-incoming-cookies
8212  -crunch-outgoing-cookies
8213  -crunch-server-header
8214  +deanimate-gifs {last}
8215  -downgrade-http-version
8216  -fast-redirects
8217  -filter {js-events}
8218  -filter {content-cookies}
8219  -filter {all-popups}
8220  -filter {banners-by-link}
8221  -filter {tiny-textforms}
8222  -filter {frameset-borders}
8223  -filter {demoronizer}
8224  -filter {shockwave-flash}
8225  -filter {quicktime-kioskmode}
8226  -filter {fun}
8227  -filter {crude-parental}
8228  -filter {site-specifics}
8229  -filter {js-annoyances}
8230  -filter {html-annoyances}
8231  +filter {refresh-tags}
8232  -filter {unsolicited-popups}
8233  +filter {img-reorder}
8234  +filter {banners-by-size}
8235  +filter {webbugs}
8236  +filter {jumping-windows}
8237  +filter {ie-exploits}
8238  -filter {google}
8239  -filter {yahoo}
8240  -filter {msn}
8241  -filter {blogspot}
8242  -filter {no-ping}
8243  -force-text-mode
8244  -handle-as-empty-document
8245  -handle-as-image
8246  -hide-accept-language
8247  -hide-content-disposition
8248  +hide-from-header {block}
8249  -hide-if-modified-since
8250  +hide-referrer {forge}
8251  -hide-user-agent
8252  -limit-connect
8253  -overwrite-last-modified
8254  -prevent-compression
8255  -redirect
8256  -server-header-filter{xml-to-html}
8257  -server-header-filter{html-to-xml}
8258  -session-cookies-only
8259  +set-image-blocker {pattern} </screen>
8260
8261 <para>
8262  Notice the only difference here to the previous listing, is to
8263  <quote>fast-redirects</quote> and <quote>session-cookies-only</quote>,
8264  which are activated specifically for this site in our configuration,
8265  and thus show in the <quote>Final Results</quote>.
8266 </para>
8267
8268 <para>
8269  Now another example, <quote>ad.doubleclick.net</quote>:
8270 </para>
8271
8272  <screen>
8273  { +block{Domains starts with "ad"} }
8274   ad*.
8275
8276  { +block{Domain contains "ad"} }
8277   .ad.
8278
8279  { +block{Doubleclick banner server} +handle-as-image }
8280   .[a-vx-z]*.doubleclick.net
8281 </screen>
8282
8283 <para>
8284  We'll just show the interesting part here - the explicit matches. It is
8285  matched three different times. Two <quote>+block{}</quote> sections,
8286  and a <quote>+block{} +handle-as-image</quote>,
8287  which is the expanded form of one of our aliases that had been defined as:
8288  <quote>+block-as-image</quote>. (<link
8289  linkend="ALIASES"><quote>Aliases</quote></link> are defined in
8290  the first section of the actions file and typically used to combine more
8291  than one action.)
8292 </para>
8293
8294 <para>
8295  Any one of these would have done the trick and blocked this as an unwanted
8296  image. This is unnecessarily redundant since the last case effectively
8297  would also cover the first. No point in taking chances with these guys
8298  though ;-) Note that if you want an ad or obnoxious
8299  URL to be invisible, it should be defined as <quote>ad.doubleclick.net</quote>
8300  is done here -- as both a <link
8301  linkend="BLOCK"><quote>+block{}</quote></link>
8302  <emphasis>and</emphasis> an
8303  <link linkend="HANDLE-AS-IMAGE"><quote>+handle-as-image</quote></link>.
8304  The custom alias <quote><literal>+block-as-image</literal></quote> just
8305  simplifies the process and make it more readable.
8306 </para>
8307
8308 <para>
8309  One last example. Let's try <quote>http://www.example.net/adsl/HOWTO/</quote>.
8310  This one is giving us problems. We are getting a blank page. Hmmm ...
8311 </para>
8312
8313  <screen>
8314  Matches for http://www.example.net/adsl/HOWTO/:
8315
8316  In file: default.action <guibutton>[ View ]</guibutton> <guibutton>[ Edit ]</guibutton>
8317
8318  {-add-header
8319   -block
8320   +change-x-forwarded-for{block}
8321   -client-header-filter{hide-tor-exit-notation}
8322   -content-type-overwrite
8323   -crunch-client-header
8324   -crunch-if-none-match
8325   -crunch-incoming-cookies
8326   -crunch-outgoing-cookies
8327   -crunch-server-header
8328   +deanimate-gifs
8329   -downgrade-http-version
8330   +fast-redirects {check-decoded-url}
8331   -filter {js-events}
8332   -filter {content-cookies}
8333   -filter {all-popups}
8334   -filter {banners-by-link}
8335   -filter {tiny-textforms}
8336   -filter {frameset-borders}
8337   -filter {demoronizer}
8338   -filter {shockwave-flash}
8339   -filter {quicktime-kioskmode}
8340   -filter {fun}
8341   -filter {crude-parental}
8342   -filter {site-specifics}
8343   -filter {js-annoyances}
8344   -filter {html-annoyances}
8345   +filter {refresh-tags}
8346   -filter {unsolicited-popups}
8347   +filter {img-reorder}
8348   +filter {banners-by-size}
8349   +filter {webbugs}
8350   +filter {jumping-windows}
8351   +filter {ie-exploits}
8352   -filter {google}
8353   -filter {yahoo}
8354   -filter {msn}
8355   -filter {blogspot}
8356   -filter {no-ping}
8357   -force-text-mode
8358   -handle-as-empty-document
8359   -handle-as-image
8360   -hide-accept-language
8361   -hide-content-disposition
8362   +hide-from-header{block}
8363   +hide-referer{forge}
8364   -hide-user-agent
8365   -overwrite-last-modified
8366   +prevent-compression
8367   -redirect
8368   -server-header-filter{xml-to-html}
8369   -server-header-filter{html-to-xml}
8370   +session-cookies-only
8371   +set-image-blocker{blank} }
8372    /
8373
8374  { +block{Path contains "ads".} +handle-as-image }
8375   /ads
8376 </screen>
8377
8378 <para>
8379  Ooops, the <quote>/adsl/</quote> is matching <quote>/ads</quote> in our
8380  configuration! But we did not want this at all! Now we see why we get the
8381  blank page. It is actually triggering two different actions here, and
8382  the effects are aggregated so that the URL is blocked, and &my-app; is told
8383  to treat the block as if it were an image. But this is, of course, all wrong.
8384   We could now add a new action below this (or better in our own
8385   <filename>user.action</filename> file) that explicitly
8386   <emphasis>un</emphasis> blocks (
8387   <link linkend="BLOCK"><quote>{-block}</quote></link>) paths with
8388   <quote>adsl</quote> in them (remember, last match in the configuration
8389   wins). There are various ways to handle such exceptions. Example:
8390 </para>
8391
8392  <screen>
8393  { -block }
8394   /adsl
8395 </screen>
8396
8397 <para>
8398  Now the page displays ;-)
8399  Remember to flush your browser's caches when making these kinds of changes to
8400  your configuration to insure that you get a freshly delivered page! Or, try
8401  using <literal>Shift+Reload</literal>.
8402 </para>
8403
8404 <para>
8405  But now what about a situation where we get no explicit matches like
8406  we did with:
8407 </para>
8408
8409  <screen>
8410  { +block{Path starts with "ads".} +handle-as-image }
8411  /ads
8412 </screen>
8413
8414 <para>
8415  That actually was very helpful and pointed us quickly to where the problem
8416  was. If you don't get this kind of match, then it means one of the default
8417  rules in the first section of <filename>default.action</filename> is causing
8418  the problem. This would require some guesswork, and maybe a little trial and
8419  error to isolate the offending rule. One likely cause would be one of the
8420  <link linkend="FILTER"><quote>+filter</quote></link> actions.
8421  These tend to be harder to troubleshoot.
8422  Try adding the URL for the site to one of aliases that turn off
8423  <link linkend="FILTER"><quote>+filter</quote></link>:
8424 </para>
8425
8426  <screen>
8427  { shop }
8428  .quietpc.com
8429  .worldpay.com   # for quietpc.com
8430  .jungle.com
8431  .scan.co.uk
8432  .forbes.com
8433 </screen>
8434
8435 <para>
8436  <quote><literal>{ shop }</literal></quote> is an <quote>alias</quote> that expands to
8437  <quote><literal>{ -filter -session-cookies-only }</literal></quote>.
8438  Or you could do your own exception to negate filtering:
8439 </para>
8440
8441  <screen>
8442  { -filter }
8443  # Disable ALL filter actions for sites in this section
8444  .forbes.com
8445  developer.ibm.com
8446  localhost
8447 </screen>
8448
8449 <para>
8450  This would turn off all filtering for these sites. This is best
8451  put in <filename>user.action</filename>, for local site
8452  exceptions. Note that when a simple domain pattern is used by itself (without
8453  the subsequent path portion), all sub-pages within that domain are included
8454  automatically in the scope of the action.
8455 </para>
8456
8457 <para>
8458  Images that are inexplicably being blocked, may well be hitting the
8459 <link linkend="FILTER-BANNERS-BY-SIZE"><quote>+filter{banners-by-size}</quote></link>
8460  rule, which assumes
8461  that images of certain sizes are ad banners (works well
8462  <emphasis>most of the time</emphasis>  since these tend to be standardized).
8463 </para>
8464
8465 <para>
8466  <quote><literal>{ fragile }</literal></quote> is an alias that disables most
8467  actions that are the most likely to cause trouble. This can be used as a
8468  last resort for problem sites.
8469 </para>
8470
8471  <screen>
8472  { fragile }
8473  # Handle with care: easy to break
8474  mail.google.
8475  mybank.example.com</screen>
8476
8477
8478 <para>
8479  <emphasis>Remember to flush caches!</emphasis> Note that the
8480  <literal>mail.google</literal> reference lacks the TLD portion (e.g.
8481  <quote>.com</quote>). This will effectively match any TLD with
8482  <literal>google</literal> in it, such as <literal>mail.google.de.</literal>,
8483  just as an example.
8484 </para>
8485 <para>
8486  If this still does not work, you will have to go through the remaining
8487  actions one by one to find which one(s) is causing the problem.
8488 </para>
8489
8490 </sect2>
8491
8492 </sect1>
8493
8494  <!--
8495
8496  This program is free software; you can redistribute it
8497  and/or modify it under the terms of the GNU General
8498  Public License as published by the Free Software
8499  Foundation; either version 2 of the License, or (at
8500  your option) any later version.
8501
8502  This program is distributed in the hope that it will
8503  be useful, but WITHOUT ANY WARRANTY; without even the
8504  implied warranty of MERCHANTABILITY or FITNESS FOR A
8505  PARTICULAR PURPOSE.  See the GNU General Public
8506  License for more details.
8507
8508  The GNU General Public License should be included with
8509  this file.  If not, you can view it at
8510  http://www.gnu.org/copyleft/gpl.html
8511  or write to the Free Software Foundation, Inc.,
8512  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
8513  USA
8514
8515  -->
8516
8517 </article>