1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <title>Appendix</title>
6 <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
7 <link rel="HOME" title="Privoxy 3.0.29 User Manual" href="index.html">
8 <link rel="PREVIOUS" title="See Also" href="seealso.html">
9 <link rel="STYLESHEET" type="text/css" href="../p_doc.css">
10 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
11 <link rel="STYLESHEET" type="text/css" href="p_doc.css">
13 <body class="SECT1" bgcolor="#EEEEEE" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <div class="NAVHEADER">
15 <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
17 <th colspan="3" align="center">Privoxy 3.0.29 User Manual</th>
20 <td width="10%" align="left" valign="bottom"><a href="seealso.html" accesskey="P">Prev</a></td>
21 <td width="80%" align="center" valign="bottom"></td>
22 <td width="10%" align="right" valign="bottom"> </td>
25 <hr align="left" width="100%">
28 <h1 class="SECT1"><a name="APPENDIX" id="APPENDIX">14. Appendix</a></h1>
30 <h2 class="SECT2"><a name="REGEX" id="REGEX">14.1. Regular Expressions</a></h2>
31 <p><span class="APPLICATION">Privoxy</span> uses Perl-style <span class="QUOTE">"regular expressions"</span> in
32 its <a href="actions-file.html">actions files</a> and <a href="filter-file.html">filter file</a>, through the
33 <a href="http://www.pcre.org/" target="_top">PCRE</a> and <span class="APPLICATION">PCRS</span> libraries.</p>
34 <p>If you are reading this, you probably don't understand what <span class="QUOTE">"regular expressions"</span>
35 are, or what they can do. So this will be a very brief introduction only. A full explanation would require a
36 <a href="http://www.oreilly.com/catalog/regex/" target="_top">book</a> ;-)</p>
37 <p>Regular expressions provide a language to describe patterns that can be run against strings of characters
38 (letter, numbers, etc), to see if they match the string or not. The patterns are themselves (sometimes complex)
39 strings of literal characters, combined with wild-cards, and other special characters, called meta-characters.
40 The <span class="QUOTE">"meta-characters"</span> have special meanings and are used to build complex patterns to
41 be matched against. Perl Compatible Regular Expressions are an especially convenient <span class=
42 "QUOTE">"dialect"</span> of the regular expression language.</p>
43 <p>To make a simple analogy, we do something similar when we use wild-card characters when listing files with the
44 <b class="COMMAND">dir</b> command in DOS. <tt class="LITERAL">*.*</tt> matches all filenames. The <span class=
45 "QUOTE">"special"</span> character here is the asterisk which matches any and all characters. We can be more
46 specific and use <tt class="LITERAL">?</tt> to match just individual characters. So <span class="QUOTE">"dir
47 file?.text"</span> would match <span class="QUOTE">"file1.txt"</span>, <span class="QUOTE">"file2.txt"</span>,
48 etc. We are pattern matching, using a similar technique to <span class="QUOTE">"regular expressions"</span>!</p>
49 <p>Regular expressions do essentially the same thing, but are much, much more powerful. There are many more
50 <span class="QUOTE">"special characters"</span> and ways of building complex patterns however. Let's look at a
51 few of the common ones, and then some examples:</p>
55 <td><span class="emphasis"><i class="EMPHASIS">.</i></span> - Matches any single character, e.g.
56 <span class="QUOTE">"a"</span>, <span class="QUOTE">"A"</span>, <span class="QUOTE">"4"</span>,
57 <span class="QUOTE">":"</span>, or <span class="QUOTE">"@"</span>.</td>
64 <td><span class="emphasis"><i class="EMPHASIS">?</i></span> - The preceding character or expression is
65 matched ZERO or ONE times. Either/or.</td>
72 <td><span class="emphasis"><i class="EMPHASIS">+</i></span> - The preceding character or expression is
73 matched ONE or MORE times.</td>
80 <td><span class="emphasis"><i class="EMPHASIS">*</i></span> - The preceding character or expression is
81 matched ZERO or MORE times.</td>
88 <td><span class="emphasis"><i class="EMPHASIS">\</i></span> - The <span class="QUOTE">"escape"</span>
89 character denotes that the following character should be taken literally. This is used where one of the
90 special characters (e.g. <span class="QUOTE">"."</span>) needs to be taken literally and not as a special
91 meta-character. Example: <span class="QUOTE">"example\.com"</span>, makes sure the period is recognized
92 only as a period (and not expanded to its meta-character meaning of any single character).</td>
99 <td><span class="emphasis"><i class="EMPHASIS">[ ]</i></span> - Characters enclosed in brackets will be
100 matched if any of the enclosed characters are encountered. For instance, <span class="QUOTE">"[0-9]"</span>
101 matches any numeric digit (zero through nine). As an example, we can combine this with <span class=
102 "QUOTE">"+"</span> to match any digit one of more times: <span class="QUOTE">"[0-9]+"</span>.</td>
109 <td><span class="emphasis"><i class="EMPHASIS">( )</i></span> - parentheses are used to group a
110 sub-expression, or multiple sub-expressions.</td>
117 <td><span class="emphasis"><i class="EMPHASIS">|</i></span> - The <span class="QUOTE">"bar"</span>
118 character works like an <span class="QUOTE">"or"</span> conditional statement. A match is successful if the
119 sub-expression on either side of <span class="QUOTE">"|"</span> matches. As an example: <span class=
120 "QUOTE">"/(this|that) example/"</span> uses grouping and the bar character and would match either
121 <span class="QUOTE">"this example"</span> or <span class="QUOTE">"that example"</span>, and nothing
126 <p>These are just some of the ones you are likely to use when matching URLs with <span class=
127 "APPLICATION">Privoxy</span>, and is a long way from a definitive list. This is enough to get us started with a
128 few simple examples which may be more illuminating:</p>
129 <p><span class="emphasis"><i class="EMPHASIS"><tt class="LITERAL">/.*/banners/.*</tt></i></span> - A simple
130 example that uses the common combination of <span class="QUOTE">"."</span> and <span class="QUOTE">"*"</span> to
131 denote any character, zero or more times. In other words, any string at all. So we start with a literal forward
132 slash, then our regular expression pattern (<span class="QUOTE">".*"</span>) another literal forward slash, the
133 string <span class="QUOTE">"banners"</span>, another forward slash, and lastly another <span class=
134 "QUOTE">".*"</span>. We are building a directory path here. This will match any file with the path that has a
135 directory named <span class="QUOTE">"banners"</span> in it. The <span class="QUOTE">".*"</span> matches any
136 characters, and this could conceivably be more forward slashes, so it might expand into a much longer looking
137 path. For example, this could match: <span class="QUOTE">"/eye/hate/spammers/banners/annoy_me_please.gif"</span>,
138 or just <span class="QUOTE">"/banners/annoying.html"</span>, or almost an infinite number of other possible
139 combinations, just so it has <span class="QUOTE">"banners"</span> in the path somewhere.</p>
140 <p>And now something a little more complex:</p>
141 <p><span class="emphasis"><i class="EMPHASIS"><tt class=
142 "LITERAL">/.*/adv((er)?ts?|ertis(ing|ements?))?/</tt></i></span> - We have several literal forward slashes again
143 (<span class="QUOTE">"/"</span>), so we are building another expression that is a file path statement. We have
144 another <span class="QUOTE">".*"</span>, so we are matching against any conceivable sub-path, just so it matches
145 our expression. The only true literal that <span class="emphasis"><i class="EMPHASIS">must match</i></span> our
146 pattern is <span class="APPLICATION">adv</span>, together with the forward slashes. What comes after the
147 <span class="QUOTE">"adv"</span> string is the interesting part.</p>
148 <p>Remember the <span class="QUOTE">"?"</span> means the preceding expression (either a literal character or
149 anything grouped with <span class="QUOTE">"(...)"</span> in this case) can exist or not, since this means either
150 zero or one match. So <span class="QUOTE">"((er)?ts?|ertis(ing|ements?))"</span> is optional, as are the
151 individual sub-expressions: <span class="QUOTE">"(er)"</span>, <span class="QUOTE">"(ing|ements?)"</span>, and
152 the <span class="QUOTE">"s"</span>. The <span class="QUOTE">"|"</span> means <span class="QUOTE">"or"</span>. We
153 have two of those. For instance, <span class="QUOTE">"(ing|ements?)"</span>, can expand to match either
154 <span class="QUOTE">"ing"</span> <span class="emphasis"><i class="EMPHASIS">OR</i></span> <span class=
155 "QUOTE">"ements?"</span>. What is being done here, is an attempt at matching as many variations of <span class=
156 "QUOTE">"advertisement"</span>, and similar, as possible. So this would expand to match just <span class=
157 "QUOTE">"adv"</span>, or <span class="QUOTE">"advert"</span>, or <span class="QUOTE">"adverts"</span>, or
158 <span class="QUOTE">"advertising"</span>, or <span class="QUOTE">"advertisement"</span>, or <span class=
159 "QUOTE">"advertisements"</span>. You get the idea. But it would not match <span class=
160 "QUOTE">"advertizements"</span> (with a <span class="QUOTE">"z"</span>). We could fix that by changing our
161 regular expression to: <span class="QUOTE">"/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/"</span>, which would then
162 match either spelling.</p>
163 <p><span class="emphasis"><i class="EMPHASIS"><tt class="LITERAL">/.*/advert[0-9]+\.(gif|jpe?g)</tt></i></span> -
164 Again another path statement with forward slashes. Anything in the square brackets <span class="QUOTE">"[
165 ]"</span> can be matched. This is using <span class="QUOTE">"0-9"</span> as a shorthand expression to mean any
166 digit one through nine. It is the same as saying <span class="QUOTE">"0123456789"</span>. So any digit matches.
167 The <span class="QUOTE">"+"</span> means one or more of the preceding expression must be included. The preceding
168 expression here is what is in the square brackets -- in this case, any digit one through nine. Then, at the end,
169 we have a grouping: <span class="QUOTE">"(gif|jpe?g)"</span>. This includes a <span class="QUOTE">"|"</span>, so
170 this needs to match the expression on either side of that bar character also. A simple <span class=
171 "QUOTE">"gif"</span> on one side, and the other side will in turn match either <span class="QUOTE">"jpeg"</span>
172 or <span class="QUOTE">"jpg"</span>, since the <span class="QUOTE">"?"</span> means the letter <span class=
173 "QUOTE">"e"</span> is optional and can be matched once or not at all. So we are building an expression here to
174 match image GIF or JPEG type image file. It must include the literal string <span class="QUOTE">"advert"</span>,
175 then one or more digits, and a <span class="QUOTE">"."</span> (which is now a literal, and not a special
176 character, since it is escaped with <span class="QUOTE">"\"</span>), and lastly either <span class=
177 "QUOTE">"gif"</span>, or <span class="QUOTE">"jpeg"</span>, or <span class="QUOTE">"jpg"</span>. Some possible
178 matches would include: <span class="QUOTE">"//advert1.jpg"</span>, <span class=
179 "QUOTE">"/nasty/ads/advert1234.gif"</span>, <span class="QUOTE">"/banners/from/hell/advert99.jpg"</span>. It
180 would not match <span class="QUOTE">"advert1.gif"</span> (no leading slash), or <span class=
181 "QUOTE">"/adverts232.jpg"</span> (the expression does not include an <span class="QUOTE">"s"</span>), or
182 <span class="QUOTE">"/advert1.jsp"</span> (<span class="QUOTE">"jsp"</span> is not in the expression
184 <p>We are barely scratching the surface of regular expressions here so that you can understand the default
185 <span class="APPLICATION">Privoxy</span> configuration files, and maybe use this knowledge to customize your own
186 installation. There is much, much more that can be done with regular expressions. Now that you know enough to get
187 started, you can learn more on your own :/</p>
188 <p>More reading on Perl Compatible Regular expressions: <a href="http://perldoc.perl.org/perlre.html" target=
189 "_top">http://perldoc.perl.org/perlre.html</a></p>
190 <p>For information on regular expression based substitutions and their applications in filters, please see the
191 <a href="filter-file.html">filter file tutorial</a> in this manual.</p>
194 <h2 class="SECT2"><a name="INTERNAL-PAGES" id="INTERNAL-PAGES">14.2. Privoxy's Internal Pages</a></h2>
195 <p>Since <span class="APPLICATION">Privoxy</span> proxies each requested web page, it is easy for <span class=
196 "APPLICATION">Privoxy</span> to trap certain special URLs. In this way, we can talk directly to <span class=
197 "APPLICATION">Privoxy</span>, and see how it is configured, see how our rules are being applied, change these
198 rules and other configuration options, and even turn <span class="APPLICATION">Privoxy's</span> filtering off,
199 all with a web browser.</p>
200 <p>The URLs listed below are the special ones that allow direct access to <span class=
201 "APPLICATION">Privoxy</span>. Of course, <span class="APPLICATION">Privoxy</span> must be running to access
202 these. If not, you will get a friendly error message. Internet access is not necessary either.</p>
205 <p>Privoxy main page:</p><a name="AEN6026" id="AEN6026"></a>
206 <blockquote class="BLOCKQUOTE">
207 <p><a href="http://config.privoxy.org/" target="_top">http://config.privoxy.org/</a></p>
209 <p>There is a shortcut: <a href="http://p.p/" target="_top">http://p.p/</a> (But it doesn't provide a
210 fall-back to a real page, in case the request is not sent through <span class=
211 "APPLICATION">Privoxy</span>)</p>
214 <p>View and toggle client tags:</p><a name="AEN6034" id="AEN6034"></a>
215 <blockquote class="BLOCKQUOTE">
216 <p><a href="http://config.privoxy.org/client-tags" target=
217 "_top">http://config.privoxy.org/client-tags</a></p>
221 <p>Show information about the current configuration, including viewing and editing of actions
222 files:</p><a name="AEN6039" id="AEN6039"></a>
223 <blockquote class="BLOCKQUOTE">
224 <p><a href="http://config.privoxy.org/show-status" target=
225 "_top">http://config.privoxy.org/show-status</a></p>
229 <p>Show the browser's request headers:</p><a name="AEN6044" id="AEN6044"></a>
230 <blockquote class="BLOCKQUOTE">
231 <p><a href="http://config.privoxy.org/show-request" target=
232 "_top">http://config.privoxy.org/show-request</a></p>
236 <p>Show which actions apply to a URL and why:</p><a name="AEN6049" id="AEN6049"></a>
237 <blockquote class="BLOCKQUOTE">
238 <p><a href="http://config.privoxy.org/show-url-info" target=
239 "_top">http://config.privoxy.org/show-url-info</a></p>
243 <p>Toggle Privoxy on or off. This feature can be turned off/on in the main <tt class="FILENAME">config</tt>
244 file. When toggled <span class="QUOTE">"off"</span>, <span class="QUOTE">"Privoxy"</span> continues to run,
245 but only as a pass-through proxy, with no actions taking place:</p><a name="AEN6057" id="AEN6057"></a>
246 <blockquote class="BLOCKQUOTE">
247 <p><a href="http://config.privoxy.org/toggle" target="_top">http://config.privoxy.org/toggle</a></p>
249 <p>Short cuts. Turn off, then on:</p><a name="AEN6061" id="AEN6061"></a>
250 <blockquote class="BLOCKQUOTE">
251 <p><a href="http://config.privoxy.org/toggle?set=disable" target=
252 "_top">http://config.privoxy.org/toggle?set=disable</a></p>
253 </blockquote><a name="AEN6064" id="AEN6064"></a>
254 <blockquote class="BLOCKQUOTE">
255 <p><a href="http://config.privoxy.org/toggle?set=enable" target=
256 "_top">http://config.privoxy.org/toggle?set=enable</a></p>
262 <h2 class="SECT2"><a name="CHAIN" id="CHAIN">14.3. Chain of Events</a></h2>
263 <p>Let's take a quick look at how some of <span class="APPLICATION">Privoxy's</span> core features are triggered,
264 and the ensuing sequence of events when a web page is requested by your browser:</p>
267 <p>First, your web browser requests a web page. The browser knows to send the request to <span class=
268 "APPLICATION">Privoxy</span>, which will in turn, relay the request to the remote web server after passing
269 the following tests:</p>
272 <p><span class="APPLICATION">Privoxy</span> traps any request for its own internal CGI pages (e.g <a href=
273 "http://p.p/" target="_top">http://p.p/</a>) and sends the CGI page back to the browser.</p>
276 <p>Next, <span class="APPLICATION">Privoxy</span> checks to see if the URL matches any <a href=
277 "actions-file.html#BLOCK"><span class="QUOTE">"+block"</span></a> patterns. If so, the URL is then blocked,
278 and the remote web server will not be contacted. <a href="actions-file.html#HANDLE-AS-IMAGE"><span class=
279 "QUOTE">"+handle-as-image"</span></a> and <a href="actions-file.html#HANDLE-AS-EMPTY-DOCUMENT"><span class=
280 "QUOTE">"+handle-as-empty-document"</span></a> are then checked, and if there is no match, an HTML
281 <span class="QUOTE">"BLOCKED"</span> page is sent back to the browser. Otherwise, if it does match, an image
282 is returned for the former, and an empty text document for the latter. The type of image would depend on the
283 setting of <a href="actions-file.html#SET-IMAGE-BLOCKER"><span class="QUOTE">"+set-image-blocker"</span></a>
284 (blank, checkerboard pattern, or an HTTP redirect to an image elsewhere).</p>
287 <p>Untrusted URLs are blocked. If URLs are being added to the <tt class="FILENAME">trust</tt> file, then that
291 <p>If the URL pattern matches the <a href="actions-file.html#FAST-REDIRECTS"><span class=
292 "QUOTE">"+fast-redirects"</span></a> action, it is then processed. Unwanted parts of the requested URL are
296 <p>Now the rest of the client browser's request headers are processed. If any of these match any of the
297 relevant actions (e.g. <a href="actions-file.html#HIDE-USER-AGENT"><span class=
298 "QUOTE">"+hide-user-agent"</span></a>, etc.), headers are suppressed or forged as determined by these actions
299 and their parameters.</p>
302 <p>Now the web server starts sending its response back (i.e. typically a web page).</p>
305 <p>First, the server headers are read and processed to determine, among other things, the MIME type (document
306 type) and encoding. The headers are then filtered as determined by the <a href=
307 "actions-file.html#CRUNCH-INCOMING-COOKIES"><span class="QUOTE">"+crunch-incoming-cookies"</span></a>,
308 <a href="actions-file.html#SESSION-COOKIES-ONLY"><span class="QUOTE">"+session-cookies-only"</span></a>, and
309 <a href="actions-file.html#DOWNGRADE-HTTP-VERSION"><span class="QUOTE">"+downgrade-http-version"</span></a>
313 <p>If any <a href="actions-file.html#FILTER"><span class="QUOTE">"+filter"</span></a> action or <a href=
314 "actions-file.html#DEANIMATE-GIFS"><span class="QUOTE">"+deanimate-gifs"</span></a> action applies (and the
315 document type fits the action), the rest of the page is read into memory (up to a configurable limit). Then
316 the filter rules (from <tt class="FILENAME">default.filter</tt> and any other filter files) are processed
317 against the buffered content. Filters are applied in the order they are specified in one of the filter files.
318 Animated GIFs, if present, are reduced to either the first or last frame, depending on the action setting.The
319 entire page, which is now filtered, is then sent by <span class="APPLICATION">Privoxy</span> back to your
321 <p>If neither a <a href="actions-file.html#FILTER"><span class="QUOTE">"+filter"</span></a> action or
322 <a href="actions-file.html#DEANIMATE-GIFS"><span class="QUOTE">"+deanimate-gifs"</span></a> matches, then
323 <span class="APPLICATION">Privoxy</span> passes the raw data through to the client browser as it becomes
327 <p>As the browser receives the now (possibly filtered) page content, it reads and then requests any URLs that
328 may be embedded within the page source, e.g. ad images, stylesheets, JavaScript, other HTML documents (e.g.
329 frames), sounds, etc. For each of these objects, the browser issues a separate request (this is easily
330 viewable in <span class="APPLICATION">Privoxy's</span> logs). And each such request is in turn processed just
331 as above. Note that a complex web page will have many, many such embedded URLs. If these secondary requests
332 are to a different server, then quite possibly a very differing set of actions is triggered.</p>
335 <p>NOTE: This is somewhat of a simplistic overview of what happens with each URL request. For the sake of brevity
336 and simplicity, we have focused on <span class="APPLICATION">Privoxy's</span> core features only.</p>
339 <h2 class="SECT2"><a name="ACTIONSANAT" id="ACTIONSANAT">14.4. Troubleshooting: Anatomy of an Action</a></h2>
340 <p>The way <span class="APPLICATION">Privoxy</span> applies <a href="actions-file.html#ACTIONS">actions</a> and
341 <a href="actions-file.html#FILTER">filters</a> to any given URL can be complex, and not always so easy to
342 understand what is happening. And sometimes we need to be able to <span class="emphasis"><i class=
343 "EMPHASIS">see</i></span> just what <span class="APPLICATION">Privoxy</span> is doing. Especially, if something
344 <span class="APPLICATION">Privoxy</span> is doing is causing us a problem inadvertently. It can be a little
345 daunting to look at the actions and filters files themselves, since they tend to be filled with <a href=
346 "appendix.html#REGEX">regular expressions</a> whose consequences are not always so obvious.</p>
347 <p>One quick test to see if <span class="APPLICATION">Privoxy</span> is causing a problem or not, is to disable
348 it temporarily. This should be the first troubleshooting step (be sure to flush caches afterward!). Looking at
349 the logs is a good idea too. (Note that both the toggle feature and logging are enabled via <tt class=
350 "FILENAME">config</tt> file settings, and may need to be turned <span class="QUOTE">"on"</span>.)</p>
351 <p>Another easy troubleshooting step to try is if you have done any customization of your installation, revert
352 back to the installed defaults and see if that helps. There are times the developers get complaints about one
353 thing or another, and the problem is more related to a customized configuration issue.</p>
354 <p><span class="APPLICATION">Privoxy</span> also provides the <a href="http://config.privoxy.org/show-url-info"
355 target="_top">http://config.privoxy.org/show-url-info</a> page that can show us very specifically how
356 <span class="APPLICATION">actions</span> are being applied to any given URL. This is a big help for
358 <p>First, enter one URL (or partial URL) at the prompt, and then <span class="APPLICATION">Privoxy</span> will
359 tell us how the current configuration will handle it. This will not help with filtering effects (i.e. the
360 <a href="actions-file.html#FILTER"><span class="QUOTE">"+filter"</span></a> action) from one of the filter files
361 since this is handled very differently and not so easy to trap! It also will not tell you about any other URLs
362 that may be embedded within the URL you are testing. For instance, images such as ads are expressed as URLs
363 within the raw page source of HTML pages. So you will only get info for the actual URL that is pasted into the
364 prompt area -- not any sub-URLs. If you want to know about embedded URLs like ads, you will have to dig those out
365 of the HTML source. Use your browser's <span class="QUOTE">"View Page Source"</span> option for this. Or right
366 click on the ad, and grab the URL.</p>
367 <p>Let's try an example, <a href="http://google.com" target="_top">google.com</a>, and look at it one section at
368 a time in a sample configuration (your real configuration may vary):</p>
369 <table border="0" bgcolor="#E0E0E0" width="100%">
372 <pre class="SCREEN"> Matches for http://www.google.com:
374 In file: default.action <span class="GUIBUTTON">[ View ]</span> <span class="GUIBUTTON">[ Edit ]</span>
376 {+change-x-forwarded-for{block}
377 +deanimate-gifs {last}
378 +fast-redirects {check-decoded-url}
379 +filter {refresh-tags}
380 +filter {img-reorder}
381 +filter {banners-by-size}
383 +filter {jumping-windows}
384 +filter {ie-exploits}
385 +hide-from-header {block}
386 +hide-referrer {forge}
387 +session-cookies-only
388 +set-image-blocker {pattern}
391 { -session-cookies-only }
397 In file: user.action <span class="GUIBUTTON">[ View ]</span> <span class="GUIBUTTON">[ Edit ]</span>
398 (no matches in this file)</pre>
402 <p>This is telling us how we have defined our <a href="actions-file.html#ACTIONS"><span class=
403 "QUOTE">"actions"</span></a>, and which ones match for our test case, <span class="QUOTE">"google.com"</span>.
404 Displayed is all the actions that are available to us. Remember, the <tt class="LITERAL">+</tt> sign denotes
405 <span class="QUOTE">"on"</span>. <tt class="LITERAL">-</tt> denotes <span class="QUOTE">"off"</span>. So some are
406 <span class="QUOTE">"on"</span> here, but many are <span class="QUOTE">"off"</span>. Each example we try may
407 provide a slightly different end result, depending on our configuration directives.</p>
408 <p>The first listing is for our <tt class="FILENAME">default.action</tt> file. The large, multi-line listing, is
409 how the actions are set to match for all URLs, i.e. our default settings. If you look at your <span class=
410 "QUOTE">"actions"</span> file, this would be the section just below the <span class="QUOTE">"aliases"</span>
411 section near the top. This will apply to all URLs as signified by the single forward slash at the end of the
412 listing -- <span class="QUOTE">" / "</span>.</p>
413 <p>But we have defined additional actions that would be exceptions to these general rules, and then we list
414 specific URLs (or patterns) that these exceptions would apply to. Last match wins. Just below this then are two
415 explicit matches for <span class="QUOTE">".google.com"</span>. The first is negating our previous cookie setting,
416 which was for <a href="actions-file.html#SESSION-COOKIES-ONLY"><span class=
417 "QUOTE">"+session-cookies-only"</span></a> (i.e. not persistent). So we will allow persistent cookies for google,
418 at least that is how it is in this example. The second turns <span class="emphasis"><i class=
419 "EMPHASIS">off</i></span> any <a href="actions-file.html#FAST-REDIRECTS"><span class=
420 "QUOTE">"+fast-redirects"</span></a> action, allowing this to take place unmolested. Note that there is a leading
421 dot here -- <span class="QUOTE">".google.com"</span>. This will match any hosts and sub-domains, in the
422 google.com domain also, such as <span class="QUOTE">"www.google.com"</span> or <span class=
423 "QUOTE">"mail.google.com"</span>. But it would not match <span class="QUOTE">"www.google.de"</span>! So,
424 apparently, we have these two actions defined as exceptions to the general rules at the top somewhere in the
425 lower part of our <tt class="FILENAME">default.action</tt> file, and <span class="QUOTE">"google.com"</span> is
426 referenced somewhere in these latter sections.</p>
427 <p>Then, for our <tt class="FILENAME">user.action</tt> file, we again have no hits. So there is nothing
428 google-specific that we might have added to our own, local configuration. If there was, those actions would
429 over-rule any actions from previously processed files, such as <tt class="FILENAME">default.action</tt>.
430 <tt class="FILENAME">user.action</tt> typically has the last word. This is the best place to put hard and fast
432 <p>And finally we pull it all together in the bottom section and summarize how <span class=
433 "APPLICATION">Privoxy</span> is applying all its <span class="QUOTE">"actions"</span> to <span class=
434 "QUOTE">"google.com"</span>:</p>
435 <table border="0" bgcolor="#E0E0E0" width="100%">
438 <pre class="SCREEN"> Final results:
442 +change-x-forwarded-for{block}
443 -client-header-filter{hide-tor-exit-notation}
444 -content-type-overwrite
445 -crunch-client-header
446 -crunch-if-none-match
447 -crunch-incoming-cookies
448 -crunch-outgoing-cookies
449 -crunch-server-header
450 +deanimate-gifs {last}
451 -downgrade-http-version
454 -filter {content-cookies}
456 -filter {banners-by-link}
457 -filter {tiny-textforms}
458 -filter {frameset-borders}
459 -filter {demoronizer}
460 -filter {shockwave-flash}
461 -filter {quicktime-kioskmode}
463 -filter {crude-parental}
464 -filter {site-specifics}
465 -filter {js-annoyances}
466 -filter {html-annoyances}
467 +filter {refresh-tags}
468 -filter {unsolicited-popups}
469 +filter {img-reorder}
470 +filter {banners-by-size}
472 +filter {jumping-windows}
473 +filter {ie-exploits}
480 -handle-as-empty-document
482 -hide-accept-language
483 -hide-content-disposition
484 +hide-from-header {block}
485 -hide-if-modified-since
486 +hide-referrer {forge}
489 -overwrite-last-modified
492 -server-header-filter{xml-to-html}
493 -server-header-filter{html-to-xml}
494 -session-cookies-only
495 +set-image-blocker {pattern}</pre>
499 <p>Notice the only difference here to the previous listing, is to <span class="QUOTE">"fast-redirects"</span> and
500 <span class="QUOTE">"session-cookies-only"</span>, which are activated specifically for this site in our
501 configuration, and thus show in the <span class="QUOTE">"Final Results"</span>.</p>
502 <p>Now another example, <span class="QUOTE">"ad.doubleclick.net"</span>:</p>
503 <table border="0" bgcolor="#E0E0E0" width="100%">
506 <pre class="SCREEN"> { +block{Domains starts with "ad"} }
509 { +block{Domain contains "ad"} }
512 { +block{Doubleclick banner server} +handle-as-image }
513 .[a-vx-z]*.doubleclick.net</pre>
517 <p>We'll just show the interesting part here - the explicit matches. It is matched three different times. Two
518 <span class="QUOTE">"+block{}"</span> sections, and a <span class="QUOTE">"+block{} +handle-as-image"</span>,
519 which is the expanded form of one of our aliases that had been defined as: <span class=
520 "QUOTE">"+block-as-image"</span>. (<a href="actions-file.html#ALIASES"><span class="QUOTE">"Aliases"</span></a>
521 are defined in the first section of the actions file and typically used to combine more than one action.)</p>
522 <p>Any one of these would have done the trick and blocked this as an unwanted image. This is unnecessarily
523 redundant since the last case effectively would also cover the first. No point in taking chances with these guys
524 though ;-) Note that if you want an ad or obnoxious URL to be invisible, it should be defined as <span class=
525 "QUOTE">"ad.doubleclick.net"</span> is done here -- as both a <a href="actions-file.html#BLOCK"><span class=
526 "QUOTE">"+block{}"</span></a> <span class="emphasis"><i class="EMPHASIS">and</i></span> an <a href=
527 "actions-file.html#HANDLE-AS-IMAGE"><span class="QUOTE">"+handle-as-image"</span></a>. The custom alias
528 <span class="QUOTE">"<tt class="LITERAL">+block-as-image</tt>"</span> just simplifies the process and make it
530 <p>One last example. Let's try <span class="QUOTE">"http://www.example.net/adsl/HOWTO/"</span>. This one is
531 giving us problems. We are getting a blank page. Hmmm ...</p>
532 <table border="0" bgcolor="#E0E0E0" width="100%">
535 <pre class="SCREEN"> Matches for http://www.example.net/adsl/HOWTO/:
537 In file: default.action <span class="GUIBUTTON">[ View ]</span> <span class="GUIBUTTON">[ Edit ]</span>
541 +change-x-forwarded-for{block}
542 -client-header-filter{hide-tor-exit-notation}
543 -content-type-overwrite
544 -crunch-client-header
545 -crunch-if-none-match
546 -crunch-incoming-cookies
547 -crunch-outgoing-cookies
548 -crunch-server-header
550 -downgrade-http-version
551 +fast-redirects {check-decoded-url}
553 -filter {content-cookies}
555 -filter {banners-by-link}
556 -filter {tiny-textforms}
557 -filter {frameset-borders}
558 -filter {demoronizer}
559 -filter {shockwave-flash}
560 -filter {quicktime-kioskmode}
562 -filter {crude-parental}
563 -filter {site-specifics}
564 -filter {js-annoyances}
565 -filter {html-annoyances}
566 +filter {refresh-tags}
567 -filter {unsolicited-popups}
568 +filter {img-reorder}
569 +filter {banners-by-size}
571 +filter {jumping-windows}
572 +filter {ie-exploits}
579 -handle-as-empty-document
581 -hide-accept-language
582 -hide-content-disposition
583 +hide-from-header{block}
586 -overwrite-last-modified
589 -server-header-filter{xml-to-html}
590 -server-header-filter{html-to-xml}
591 +session-cookies-only
592 +set-image-blocker{blank} }
595 { +block{Path contains "ads".} +handle-as-image }
600 <p>Ooops, the <span class="QUOTE">"/adsl/"</span> is matching <span class="QUOTE">"/ads"</span> in our
601 configuration! But we did not want this at all! Now we see why we get the blank page. It is actually triggering
602 two different actions here, and the effects are aggregated so that the URL is blocked, and <span class=
603 "APPLICATION">Privoxy</span> is told to treat the block as if it were an image. But this is, of course, all
604 wrong. We could now add a new action below this (or better in our own <tt class="FILENAME">user.action</tt> file)
605 that explicitly <span class="emphasis"><i class="EMPHASIS">un</i></span> blocks ( <a href=
606 "actions-file.html#BLOCK"><span class="QUOTE">"{-block}"</span></a>) paths with <span class="QUOTE">"adsl"</span>
607 in them (remember, last match in the configuration wins). There are various ways to handle such exceptions.
609 <table border="0" bgcolor="#E0E0E0" width="100%">
612 <pre class="SCREEN"> { -block }
617 <p>Now the page displays ;-) Remember to flush your browser's caches when making these kinds of changes to your
618 configuration to insure that you get a freshly delivered page! Or, try using <tt class=
619 "LITERAL">Shift+Reload</tt>.</p>
620 <p>But now what about a situation where we get no explicit matches like we did with:</p>
621 <table border="0" bgcolor="#E0E0E0" width="100%">
624 <pre class="SCREEN"> { +block{Path starts with "ads".} +handle-as-image }
629 <p>That actually was very helpful and pointed us quickly to where the problem was. If you don't get this kind of
630 match, then it means one of the default rules in the first section of <tt class="FILENAME">default.action</tt> is
631 causing the problem. This would require some guesswork, and maybe a little trial and error to isolate the
632 offending rule. One likely cause would be one of the <a href="actions-file.html#FILTER"><span class=
633 "QUOTE">"+filter"</span></a> actions. These tend to be harder to troubleshoot. Try adding the URL for the site to
634 one of aliases that turn off <a href="actions-file.html#FILTER"><span class="QUOTE">"+filter"</span></a>:</p>
635 <table border="0" bgcolor="#E0E0E0" width="100%">
638 <pre class="SCREEN"> { shop }
640 .worldpay.com # for quietpc.com
647 <p><span class="QUOTE">"<tt class="LITERAL">{ shop }</tt>"</span> is an <span class="QUOTE">"alias"</span> that
648 expands to <span class="QUOTE">"<tt class="LITERAL">{ -filter -session-cookies-only }</tt>"</span>. Or you could
649 do your own exception to negate filtering:</p>
650 <table border="0" bgcolor="#E0E0E0" width="100%">
653 <pre class="SCREEN"> { -filter }
654 # Disable ALL filter actions for sites in this section
661 <p>This would turn off all filtering for these sites. This is best put in <tt class="FILENAME">user.action</tt>,
662 for local site exceptions. Note that when a simple domain pattern is used by itself (without the subsequent path
663 portion), all sub-pages within that domain are included automatically in the scope of the action.</p>
664 <p>Images that are inexplicably being blocked, may well be hitting the <a href=
665 "actions-file.html#FILTER-BANNERS-BY-SIZE"><span class="QUOTE">"+filter{banners-by-size}"</span></a> rule, which
666 assumes that images of certain sizes are ad banners (works well <span class="emphasis"><i class="EMPHASIS">most
667 of the time</i></span> since these tend to be standardized).</p>
668 <p><span class="QUOTE">"<tt class="LITERAL">{ fragile }</tt>"</span> is an alias that disables most actions that
669 are the most likely to cause trouble. This can be used as a last resort for problem sites.</p>
670 <table border="0" bgcolor="#E0E0E0" width="100%">
673 <pre class="SCREEN"> { fragile }
674 # Handle with care: easy to break
676 mybank.example.com</pre>
680 <p><span class="emphasis"><i class="EMPHASIS">Remember to flush caches!</i></span> Note that the <tt class=
681 "LITERAL">mail.google</tt> reference lacks the TLD portion (e.g. <span class="QUOTE">".com"</span>). This will
682 effectively match any TLD with <tt class="LITERAL">google</tt> in it, such as <tt class=
683 "LITERAL">mail.google.de.</tt>, just as an example.</p>
684 <p>If this still does not work, you will have to go through the remaining actions one by one to find which one(s)
685 is causing the problem.</p>
688 <div class="NAVFOOTER">
689 <hr align="left" width="100%">
690 <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
692 <td width="33%" align="left" valign="top"><a href="seealso.html" accesskey="P">Prev</a></td>
693 <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>
694 <td width="33%" align="right" valign="top"> </td>
697 <td width="33%" align="left" valign="top">See Also</td>
698 <td width="34%" align="center" valign="top"> </td>
699 <td width="33%" align="right" valign="top"> </td>