X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=doc%2Fwebserver%2Fuser-manual%2Factions-file.html;h=d62ddefe0c6df60ac03e5d75139c8fcf120d2b23;hp=21b85d43037908ec4f228a4d335b86dc40b2e6b6;hb=60cbbc5f5d7514135bc5afc02d24e77a231c47f4;hpb=00ff6723cacb0c08cbf3f1044e8639a89ebc23d7 diff --git a/doc/webserver/user-manual/actions-file.html b/doc/webserver/user-manual/actions-file.html index 21b85d43..d62ddefe 100644 --- a/doc/webserver/user-manual/actions-file.html +++ b/doc/webserver/user-manual/actions-file.html @@ -1,6510 +1,4391 @@ -Actions Files - -
Privoxy 3.0.4 User Manual
PrevNext

8. Actions Files

The actions files are used to define what actions - Privoxy takes for which URLs, and thus determines - how ad images, cookies and various other aspects of HTTP content and - transactions are handled, and on which sites (or even parts thereof). - There are a number of such actions, with a wide range of functionality. - Each action does something a little different. - These actions give us a veritable arsenal of tools with which to exert - our control, preferences and independence.

There - are three action files included with Privoxy with - differing purposes: -

-

The list of actions files to be used are defined in the main configuration - file, and are processed in the order they are defined (e.g. - default.action is typically process before - user.action). The content of these can all be viewed and - edited from http://config.privoxy.org/show-status.

An actions file typically has multiple sections. If you want to use - "aliases" in an actions file, you have to place the (optional) - alias section at the top of that file. - Then comes the default set of rules which will apply universally to all - sites and pages (be very careful with using such a - universal set in user.action or any other actions file after - default.action, because it will override the result - from consulting any previous file). And then below that, - exceptions to the defined universal policies. You can regard - user.action as an appendix to default.action, - with the advantage that is a separate file, which makes preserving your - personal settings across Privoxy upgrades easier.

- Actions can be used to block anything you want, including ads, banners, or - just some obnoxious URL that you would rather not see. Cookies can be accepted - or rejected, or accepted only during the current browser session (i.e. not - written to disk), content can be modified, JavaScripts tamed, user-tracking - fooled, and much more. See below for a complete list - of actions.

8.1. Finding the Right Mix

Note that some actions, like cookie suppression - or script disabling, may render some sites unusable that rely on these - techniques to work properly. Finding the right mix of actions is not always easy and - certainly a matter of personal taste. In general, it can be said that the more - "aggressive" your default settings (in the top section of the - actions file) are, the more exceptions for "trusted" sites you - will have to make later. If, for example, you want to crunch all cookies per - default, you'll have to make exceptions from that rule for sites that you - regularly use and that require cookies for actually useful puposes, like maybe - your bank, favorite shop, or newspaper.

We have tried to provide you with reasonable rules to start from in the - distribution actions files. But there is no general rule of thumb on these - things. There just are too many variables, and sites are constantly changing. - Sooner or later you will want to change the rules (and read this chapter again :).

8.2. How to Edit

The easiest way to edit the actions files is with a browser by - using our browser-based editor, which can be reached from http://config.privoxy.org/show-status. - The editor allows both fine-grained control over every single feature on a - per-URL basis, and easy choosing from wholesale sets of defaults like - "Cautious", "Medium" or "Adventuresome". - Warning: the "Adventuresome" setting is not only more aggressive, - but includes settings that are fun and subversive, and which some may find of - dubious merit!

If you prefer plain text editing to GUIs, you can of course also directly edit the - the actions files. Look at default.action which is richly - commented.

8.3. How Actions are Applied to URLs

Actions files are divided into sections. There are special sections, - like the "alias" sections which will - be discussed later. For now let's concentrate on regular sections: They have a - heading line (often split up to multiple lines for readability) which consist - of a list of actions, separated by whitespace and enclosed in curly braces. - Below that, there is a list of URL patterns, each on a separate line.

To determine which actions apply to a request, the URL of the request is - compared to all patterns in each "action file" file. Every time it matches, the list of - applicable actions for the URL is incrementally updated, using the heading - of the section in which the pattern is located. If multiple matches for - the same URL set the same action differently, the last match wins. If not, - the effects are aggregated. E.g. a URL might match a regular section with - a heading line of { - +handle-as-image }, - then later another one with just { - +block }, resulting - in both actions to apply.

You can trace this process for any given URL by visiting http://config.privoxy.org/show-url-info.

More detail on this is provided in the Appendix, Anatomy of an Action.

8.4. Patterns

- As mentioned, Privoxy uses "patterns" - to determine what actions might apply to which sites and pages your browser - attempts to access. These "patterns" use wild card type - pattern matching to achieve a high degree of - flexibility. This allows one expression to be expanded and potentially match - against many similar patterns.

Generally, a Privoxy pattern has the form - <domain>/<path>, where both the - <domain> and <path> are - optional. (This is why the special / pattern matches all - URLs). Note that the protocol portion of the URL pattern (e.g. - http://) should not be included in - the pattern. This is assumed already!

www.example.com/

is a domain-only pattern and will match any request to www.example.com, - regardless of which document on that server is requested. -

www.example.com

means exactly the same. For domain-only patterns, the trailing / may - be omitted. -

www.example.com/index.html

matches only the single document /index.html - on www.example.com. -

/index.html

matches the document /index.html, regardless of the domain, - i.e. on any web server. -

index.html

matches nothing, since it would be interpreted as a domain name and - there is no top-level domain called .html. -

8.4.1. The Domain Pattern

The matching of the domain part offers some flexible options: if the - domain starts or ends with a dot, it becomes unanchored at that end. - For example:

.example.com

matches any domain that ENDS in - .example.com -

www.

matches any domain that STARTS with - www. -

.example.

matches any domain that CONTAINS .example. - (Correctly speaking: It matches any FQDN that contains example as a domain.) -

Additionally, there are wild-cards that you can use in the domain names - themselves. They work pretty similar to shell wild-cards: "*" - stands for zero or more arbitrary characters, "?" stands for - any single character, you can define character classes in square - brackets and all of that can be freely mixed:

ad*.example.com

matches "adserver.example.com", - "ads.example.com", etc but not "sfads.example.com" -

*ad*.example.com

matches all of the above, and then some. -

.?pix.com

matches www.ipix.com, - pictures.epix.com, a.b.c.d.e.upix.com etc. -

www[1-9a-ez].example.c*

matches www1.example.com, - www4.example.cc, wwwd.example.cy, - wwwz.example.com etc., but not - wwww.example.com. -

8.4.2. The Path Pattern

Privoxy uses Perl compatible regular expressions - (through the PCRE library) for - matching the path.

There is an Appendix with a brief quick-start into regular - expressions, and full (very technical) documentation on PCRE regex syntax is available on-line - at http://www.pcre.org/man.txt. - You might also find the Perl man page on regular expressions (man perlre) - useful, which is available on-line at http://perldoc.perl.org/perlre.html.

Note that the path pattern is automatically left-anchored at the "/", - i.e. it matches as if it would start with a "^" (regular expression speak - for the beginning of a line).

Please also note that matching in the path is CASE INSENSITIVE - by default, but you can switch to case sensitive at any point in the pattern by using the - "(?-i)" switch: www.example.com/(?-i)PaTtErN.* will match - only documents whose path starts with PaTtErN in - exactly this capitalization.

8.5. Actions

All actions are disabled by default, until they are explicitly enabled - somewhere in an actions file. Actions are turned on if preceded with a - "+", and turned off if preceded with a "-". So a - +action means "do that action", e.g. - +block means "please block URLs that match the - following patterns", and -block means "don't - block URLs that match the following patterns, even if +block - previously applied."

- Again, actions are invoked by placing them on a line, enclosed in curly braces and - separated by whitespace, like in - {+some-action -some-other-action{some-parameter}}, - followed by a list of URL patterns, one per line, to which they apply. - Together, the actions line and the following pattern lines make up a section - of the actions file.

- There are three classes of actions:

+
+ + + + +