Rebuild user-manual, developer-manual and faq.
[privoxy.git] / doc / webserver / user-manual / appendix.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Appendix</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9 REL="HOME"
10 TITLE="Privoxy 3.0.18 User Manual"
11 HREF="index.html"><LINK
12 REL="PREVIOUS"
13 TITLE="See Also"
14 HREF="seealso.html"><LINK
15 REL="STYLESHEET"
16 TYPE="text/css"
17 HREF="../p_doc.css"><META
18 HTTP-EQUIV="Content-Type"
19 CONTENT="text/html;
20 charset=ISO-8859-1">
21 <LINK REL="STYLESHEET" TYPE="text/css" HREF="p_doc.css">
22 </head
23 ><BODY
24 CLASS="SECT1"
25 BGCOLOR="#EEEEEE"
26 TEXT="#000000"
27 LINK="#0000FF"
28 VLINK="#840084"
29 ALINK="#0000FF"
30 ><DIV
31 CLASS="NAVHEADER"
32 ><TABLE
33 SUMMARY="Header navigation table"
34 WIDTH="100%"
35 BORDER="0"
36 CELLPADDING="0"
37 CELLSPACING="0"
38 ><TR
39 ><TH
40 COLSPAN="3"
41 ALIGN="center"
42 >Privoxy 3.0.18 User Manual</TH
43 ></TR
44 ><TR
45 ><TD
46 WIDTH="10%"
47 ALIGN="left"
48 VALIGN="bottom"
49 ><A
50 HREF="seealso.html"
51 ACCESSKEY="P"
52 >Prev</A
53 ></TD
54 ><TD
55 WIDTH="80%"
56 ALIGN="center"
57 VALIGN="bottom"
58 ></TD
59 ><TD
60 WIDTH="10%"
61 ALIGN="right"
62 VALIGN="bottom"
63 >&nbsp;</TD
64 ></TR
65 ></TABLE
66 ><HR
67 ALIGN="LEFT"
68 WIDTH="100%"></DIV
69 ><DIV
70 CLASS="SECT1"
71 ><H1
72 CLASS="SECT1"
73 ><A
74 NAME="APPENDIX"
75 >14. Appendix</A
76 ></H1
77 ><DIV
78 CLASS="SECT2"
79 ><H2
80 CLASS="SECT2"
81 ><A
82 NAME="REGEX"
83 >14.1. Regular Expressions</A
84 ></H2
85 ><P
86 > <SPAN
87 CLASS="APPLICATION"
88 >Privoxy</SPAN
89 > uses Perl-style <SPAN
90 CLASS="QUOTE"
91 >"regular
92  expressions"</SPAN
93 > in its <A
94 HREF="actions-file.html"
95 >actions
96  files</A
97 > and <A
98 HREF="filter-file.html"
99 >filter file</A
100 >,
101  through the <A
102 HREF="http://www.pcre.org/"
103 TARGET="_top"
104 >PCRE</A
105 > and
106  <SPAN
107 CLASS="APPLICATION"
108 >PCRS</SPAN
109 > libraries.</P
110 ><P
111 > If you are reading this, you probably don't understand what <SPAN
112 CLASS="QUOTE"
113 >"regular
114  expressions"</SPAN
115 > are, or what they can do. So this will be a very brief
116  introduction only. A full explanation would require a <A
117 HREF="http://www.oreilly.com/catalog/regex/"
118 TARGET="_top"
119 >book</A
120 > ;-)</P
121 ><P
122 > Regular expressions provide a language to describe patterns that can be
123  run against strings of characters (letter, numbers, etc), to see if they
124  match the string or not. The  patterns are themselves (sometimes complex)
125  strings of literal characters, combined with  wild-cards, and other special
126  characters, called meta-characters. The <SPAN
127 CLASS="QUOTE"
128 >"meta-characters"</SPAN
129 > have
130  special meanings and are used to build complex patterns to be matched against.
131  Perl Compatible Regular Expressions are an especially convenient
132  <SPAN
133 CLASS="QUOTE"
134 >"dialect"</SPAN
135 > of the regular expression language.</P
136 ><P
137 > To make a simple analogy, we do something similar when we use wild-card
138  characters when listing files with the <B
139 CLASS="COMMAND"
140 >dir</B
141 > command in DOS. 
142  <TT
143 CLASS="LITERAL"
144 >*.*</TT
145 > matches all filenames. The <SPAN
146 CLASS="QUOTE"
147 >"special"</SPAN
148 >
149  character here is the asterisk which matches any and all characters. We can be
150  more specific and use <TT
151 CLASS="LITERAL"
152 >?</TT
153 > to match just individual
154  characters. So <SPAN
155 CLASS="QUOTE"
156 >"dir file?.text"</SPAN
157 > would match
158  <SPAN
159 CLASS="QUOTE"
160 >"file1.txt"</SPAN
161 >, <SPAN
162 CLASS="QUOTE"
163 >"file2.txt"</SPAN
164 >, etc. We are pattern
165  matching, using a similar technique to <SPAN
166 CLASS="QUOTE"
167 >"regular expressions"</SPAN
168 >!</P
169 ><P
170 > Regular expressions do essentially the same thing, but are much, much more
171  powerful. There are many more <SPAN
172 CLASS="QUOTE"
173 >"special characters"</SPAN
174 > and ways of 
175  building complex patterns however. Let's look at a few of the common ones,
176  and then some examples:</P
177 ><P
178 ><P
179 ></P
180 ><TABLE
181 BORDER="0"
182 ><TBODY
183 ><TR
184 ><TD
185 >  <SPAN
186 CLASS="emphasis"
187 ><I
188 CLASS="EMPHASIS"
189 >.</I
190 ></SPAN
191 > - Matches any single character, e.g. <SPAN
192 CLASS="QUOTE"
193 >"a"</SPAN
194 >,
195   <SPAN
196 CLASS="QUOTE"
197 >"A"</SPAN
198 >, <SPAN
199 CLASS="QUOTE"
200 >"4"</SPAN
201 >, <SPAN
202 CLASS="QUOTE"
203 >":"</SPAN
204 >, or <SPAN
205 CLASS="QUOTE"
206 >"@"</SPAN
207 >.
208  </TD
209 ></TR
210 ></TBODY
211 ></TABLE
212 ><P
213 ></P
214 ></P
215 ><P
216 ><P
217 ></P
218 ><TABLE
219 BORDER="0"
220 ><TBODY
221 ><TR
222 ><TD
223 >  <SPAN
224 CLASS="emphasis"
225 ><I
226 CLASS="EMPHASIS"
227 >?</I
228 ></SPAN
229 > - The preceding character or expression is matched ZERO or ONE
230   times. Either/or.
231  </TD
232 ></TR
233 ></TBODY
234 ></TABLE
235 ><P
236 ></P
237 ></P
238 ><P
239 ><P
240 ></P
241 ><TABLE
242 BORDER="0"
243 ><TBODY
244 ><TR
245 ><TD
246 >  <SPAN
247 CLASS="emphasis"
248 ><I
249 CLASS="EMPHASIS"
250 >+</I
251 ></SPAN
252 > - The preceding character or expression is matched ONE or MORE
253   times.
254  </TD
255 ></TR
256 ></TBODY
257 ></TABLE
258 ><P
259 ></P
260 ></P
261 ><P
262 ><P
263 ></P
264 ><TABLE
265 BORDER="0"
266 ><TBODY
267 ><TR
268 ><TD
269 >  <SPAN
270 CLASS="emphasis"
271 ><I
272 CLASS="EMPHASIS"
273 >*</I
274 ></SPAN
275 > - The preceding character or expression is matched ZERO or MORE
276   times.
277  </TD
278 ></TR
279 ></TBODY
280 ></TABLE
281 ><P
282 ></P
283 ></P
284 ><P
285 ><P
286 ></P
287 ><TABLE
288 BORDER="0"
289 ><TBODY
290 ><TR
291 ><TD
292 >  <SPAN
293 CLASS="emphasis"
294 ><I
295 CLASS="EMPHASIS"
296 >\</I
297 ></SPAN
298 > - The <SPAN
299 CLASS="QUOTE"
300 >"escape"</SPAN
301 > character denotes that
302   the following character should be taken literally. This is used where one of the 
303   special characters (e.g. <SPAN
304 CLASS="QUOTE"
305 >"."</SPAN
306 >) needs to be taken literally and
307   not as a special meta-character. Example: <SPAN
308 CLASS="QUOTE"
309 >"example\.com"</SPAN
310 >, makes 
311   sure the period is recognized only as a period (and not expanded to its 
312   meta-character meaning of any single character).
313  </TD
314 ></TR
315 ></TBODY
316 ></TABLE
317 ><P
318 ></P
319 ></P
320 ><P
321 ><P
322 ></P
323 ><TABLE
324 BORDER="0"
325 ><TBODY
326 ><TR
327 ><TD
328 >  <SPAN
329 CLASS="emphasis"
330 ><I
331 CLASS="EMPHASIS"
332 >[ ]</I
333 ></SPAN
334 > - Characters enclosed in brackets will be matched if
335   any of the enclosed characters are encountered. For instance, <SPAN
336 CLASS="QUOTE"
337 >"[0-9]"</SPAN
338 >
339   matches any numeric digit (zero through nine). As an example, we can combine 
340   this with <SPAN
341 CLASS="QUOTE"
342 >"+"</SPAN
343 > to match any digit one of more times: <SPAN
344 CLASS="QUOTE"
345 >"[0-9]+"</SPAN
346 >.
347  </TD
348 ></TR
349 ></TBODY
350 ></TABLE
351 ><P
352 ></P
353 ></P
354 ><P
355 ><P
356 ></P
357 ><TABLE
358 BORDER="0"
359 ><TBODY
360 ><TR
361 ><TD
362 >  <SPAN
363 CLASS="emphasis"
364 ><I
365 CLASS="EMPHASIS"
366 >( )</I
367 ></SPAN
368 > - parentheses are used to group a sub-expression,
369   or multiple sub-expressions.
370  </TD
371 ></TR
372 ></TBODY
373 ></TABLE
374 ><P
375 ></P
376 ></P
377 ><P
378 ><P
379 ></P
380 ><TABLE
381 BORDER="0"
382 ><TBODY
383 ><TR
384 ><TD
385 >  <SPAN
386 CLASS="emphasis"
387 ><I
388 CLASS="EMPHASIS"
389 >|</I
390 ></SPAN
391 > - The <SPAN
392 CLASS="QUOTE"
393 >"bar"</SPAN
394 > character works like an
395   <SPAN
396 CLASS="QUOTE"
397 >"or"</SPAN
398 > conditional statement. A match is successful if the
399   sub-expression on either side of <SPAN
400 CLASS="QUOTE"
401 >"|"</SPAN
402 > matches. As an example:
403   <SPAN
404 CLASS="QUOTE"
405 >"/(this|that) example/"</SPAN
406 > uses grouping and the bar character 
407   and would match either <SPAN
408 CLASS="QUOTE"
409 >"this example"</SPAN
410 > or <SPAN
411 CLASS="QUOTE"
412 >"that
413   example"</SPAN
414 >, and nothing else.
415  </TD
416 ></TR
417 ></TBODY
418 ></TABLE
419 ><P
420 ></P
421 ></P
422 ><P
423 > These are just some of the ones you are likely to use when matching URLs with 
424  <SPAN
425 CLASS="APPLICATION"
426 >Privoxy</SPAN
427 >, and is a long way from a definitive
428  list. This is enough to get us started with a few simple examples which may
429  be more illuminating:</P
430 ><P
431 > <SPAN
432 CLASS="emphasis"
433 ><I
434 CLASS="EMPHASIS"
435 ><TT
436 CLASS="LITERAL"
437 >/.*/banners/.*</TT
438 ></I
439 ></SPAN
440 > - A  simple example
441  that uses the common combination of <SPAN
442 CLASS="QUOTE"
443 >"."</SPAN
444 > and <SPAN
445 CLASS="QUOTE"
446 >"*"</SPAN
447 > to 
448  denote any character, zero or more times. In other words, any string at all.
449  So we start with a literal forward slash, then our regular expression pattern 
450  (<SPAN
451 CLASS="QUOTE"
452 >".*"</SPAN
453 >) another literal forward slash, the string
454  <SPAN
455 CLASS="QUOTE"
456 >"banners"</SPAN
457 >, another forward slash, and lastly another
458  <SPAN
459 CLASS="QUOTE"
460 >".*"</SPAN
461 >. We are building 
462  a directory path here. This will match any file with the path that has a
463  directory named <SPAN
464 CLASS="QUOTE"
465 >"banners"</SPAN
466 > in it. The <SPAN
467 CLASS="QUOTE"
468 >".*"</SPAN
469 > matches
470  any characters, and this could conceivably be more forward slashes, so it
471  might expand into a much longer looking path. For example, this could match:
472  <SPAN
473 CLASS="QUOTE"
474 >"/eye/hate/spammers/banners/annoy_me_please.gif"</SPAN
475 >, or just
476  <SPAN
477 CLASS="QUOTE"
478 >"/banners/annoying.html"</SPAN
479 >, or almost an infinite number of other
480  possible combinations, just so it has <SPAN
481 CLASS="QUOTE"
482 >"banners"</SPAN
483 > in the path
484  somewhere.</P
485 ><P
486 > And now something a little more complex:</P
487 ><P
488 > <SPAN
489 CLASS="emphasis"
490 ><I
491 CLASS="EMPHASIS"
492 ><TT
493 CLASS="LITERAL"
494 >/.*/adv((er)?ts?|ertis(ing|ements?))?/</TT
495 ></I
496 ></SPAN
497 > - 
498  We have several literal forward slashes again (<SPAN
499 CLASS="QUOTE"
500 >"/"</SPAN
501 >), so we are
502  building another expression that is a file path statement. We have another 
503  <SPAN
504 CLASS="QUOTE"
505 >".*"</SPAN
506 >, so we are matching against any conceivable sub-path, just so
507  it matches our expression. The only true literal that <SPAN
508 CLASS="emphasis"
509 ><I
510 CLASS="EMPHASIS"
511 >must
512  match</I
513 ></SPAN
514 > our pattern is <SPAN
515 CLASS="APPLICATION"
516 >adv</SPAN
517 >, together with
518  the forward slashes. What comes after the <SPAN
519 CLASS="QUOTE"
520 >"adv"</SPAN
521 > string is the
522  interesting part. </P
523 ><P
524 > Remember the <SPAN
525 CLASS="QUOTE"
526 >"?"</SPAN
527 > means the preceding expression (either a
528  literal character or anything grouped with <SPAN
529 CLASS="QUOTE"
530 >"(...)"</SPAN
531 > in this case)
532  can exist or not, since this means either zero or one match. So
533  <SPAN
534 CLASS="QUOTE"
535 >"((er)?ts?|ertis(ing|ements?))"</SPAN
536 > is optional, as are the
537  individual sub-expressions: <SPAN
538 CLASS="QUOTE"
539 >"(er)"</SPAN
540 >,
541  <SPAN
542 CLASS="QUOTE"
543 >"(ing|ements?)"</SPAN
544 >, and the <SPAN
545 CLASS="QUOTE"
546 >"s"</SPAN
547 >. The <SPAN
548 CLASS="QUOTE"
549 >"|"</SPAN
550 >
551  means <SPAN
552 CLASS="QUOTE"
553 >"or"</SPAN
554 >. We have two of those. For instance, 
555  <SPAN
556 CLASS="QUOTE"
557 >"(ing|ements?)"</SPAN
558 >, can expand to match either <SPAN
559 CLASS="QUOTE"
560 >"ing"</SPAN
561
562  <SPAN
563 CLASS="emphasis"
564 ><I
565 CLASS="EMPHASIS"
566 >OR</I
567 ></SPAN
568 > <SPAN
569 CLASS="QUOTE"
570 >"ements?"</SPAN
571 >. What is being done here, is an
572  attempt at matching as many variations of <SPAN
573 CLASS="QUOTE"
574 >"advertisement"</SPAN
575 >, and 
576  similar, as possible. So this would expand to match just <SPAN
577 CLASS="QUOTE"
578 >"adv"</SPAN
579 >,
580  or <SPAN
581 CLASS="QUOTE"
582 >"advert"</SPAN
583 >, or <SPAN
584 CLASS="QUOTE"
585 >"adverts"</SPAN
586 >, or
587  <SPAN
588 CLASS="QUOTE"
589 >"advertising"</SPAN
590 >, or <SPAN
591 CLASS="QUOTE"
592 >"advertisement"</SPAN
593 >, or
594  <SPAN
595 CLASS="QUOTE"
596 >"advertisements"</SPAN
597 >. You get the idea. But it would not match 
598  <SPAN
599 CLASS="QUOTE"
600 >"advertizements"</SPAN
601 > (with a <SPAN
602 CLASS="QUOTE"
603 >"z"</SPAN
604 >). We could fix that by
605  changing our regular expression to: 
606  <SPAN
607 CLASS="QUOTE"
608 >"/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/"</SPAN
609 >, which would then match
610  either spelling.</P
611 ><P
612 > <SPAN
613 CLASS="emphasis"
614 ><I
615 CLASS="EMPHASIS"
616 ><TT
617 CLASS="LITERAL"
618 >/.*/advert[0-9]+\.(gif|jpe?g)</TT
619 ></I
620 ></SPAN
621 > - Again 
622  another path statement with forward slashes. Anything in the square brackets 
623  <SPAN
624 CLASS="QUOTE"
625 >"[ ]"</SPAN
626 > can be matched. This is using <SPAN
627 CLASS="QUOTE"
628 >"0-9"</SPAN
629 > as a
630  shorthand expression to mean any digit one through nine. It is the same as
631  saying <SPAN
632 CLASS="QUOTE"
633 >"0123456789"</SPAN
634 >. So any digit matches. The <SPAN
635 CLASS="QUOTE"
636 >"+"</SPAN
637 >
638  means one or more of the preceding expression must be included. The preceding 
639  expression here is what is in the square brackets -- in this case, any digit 
640  one through nine. Then, at the end, we have a grouping: <SPAN
641 CLASS="QUOTE"
642 >"(gif|jpe?g)"</SPAN
643 >. 
644  This includes a <SPAN
645 CLASS="QUOTE"
646 >"|"</SPAN
647 >, so this needs to match the expression on
648  either side of that bar character also. A simple <SPAN
649 CLASS="QUOTE"
650 >"gif"</SPAN
651 > on one side, and the other
652  side will in turn match either <SPAN
653 CLASS="QUOTE"
654 >"jpeg"</SPAN
655 > or <SPAN
656 CLASS="QUOTE"
657 >"jpg"</SPAN
658 >,
659  since the <SPAN
660 CLASS="QUOTE"
661 >"?"</SPAN
662 > means the letter <SPAN
663 CLASS="QUOTE"
664 >"e"</SPAN
665 > is optional and
666  can be matched once or not at all. So we are building an expression here to
667  match image GIF or JPEG type image file. It must include the literal
668  string <SPAN
669 CLASS="QUOTE"
670 >"advert"</SPAN
671 >, then one or more digits, and a <SPAN
672 CLASS="QUOTE"
673 >"."</SPAN
674 >
675  (which is now a literal, and not a special character, since it is escaped
676  with <SPAN
677 CLASS="QUOTE"
678 >"\"</SPAN
679 >), and lastly either <SPAN
680 CLASS="QUOTE"
681 >"gif"</SPAN
682 >, or
683  <SPAN
684 CLASS="QUOTE"
685 >"jpeg"</SPAN
686 >, or <SPAN
687 CLASS="QUOTE"
688 >"jpg"</SPAN
689 >. Some possible matches would
690  include: <SPAN
691 CLASS="QUOTE"
692 >"//advert1.jpg"</SPAN
693 >,
694  <SPAN
695 CLASS="QUOTE"
696 >"/nasty/ads/advert1234.gif"</SPAN
697 >,
698  <SPAN
699 CLASS="QUOTE"
700 >"/banners/from/hell/advert99.jpg"</SPAN
701 >. It would not match
702  <SPAN
703 CLASS="QUOTE"
704 >"advert1.gif"</SPAN
705 > (no leading slash), or
706  <SPAN
707 CLASS="QUOTE"
708 >"/adverts232.jpg"</SPAN
709 > (the expression does not include an
710  <SPAN
711 CLASS="QUOTE"
712 >"s"</SPAN
713 >), or <SPAN
714 CLASS="QUOTE"
715 >"/advert1.jsp"</SPAN
716 > (<SPAN
717 CLASS="QUOTE"
718 >"jsp"</SPAN
719 > is not
720  in the expression anywhere).</P
721 ><P
722 > We are barely scratching the surface of regular expressions here so that you
723  can understand the default <SPAN
724 CLASS="APPLICATION"
725 >Privoxy</SPAN
726 >
727  configuration files, and maybe use this knowledge to customize your own
728  installation. There is much, much more that can be done with regular
729  expressions. Now that you know enough to get started, you can learn more on
730  your own :/</P
731 ><P
732 > More reading on Perl Compatible Regular expressions: 
733  <A
734 HREF="http://perldoc.perl.org/perlre.html"
735 TARGET="_top"
736 >http://perldoc.perl.org/perlre.html</A
737 ></P
738 ><P
739 > For information on regular expression based substitutions and their applications
740  in filters, please see the <A
741 HREF="filter-file.html"
742 >filter file tutorial</A
743 >
744  in this manual.</P
745 ></DIV
746 ><DIV
747 CLASS="SECT2"
748 ><H2
749 CLASS="SECT2"
750 ><A
751 NAME="AEN5638"
752 >14.2. Privoxy's Internal Pages</A
753 ></H2
754 ><P
755 > Since <SPAN
756 CLASS="APPLICATION"
757 >Privoxy</SPAN
758 > proxies each requested 
759  web page, it is easy for <SPAN
760 CLASS="APPLICATION"
761 >Privoxy</SPAN
762 > to 
763  trap certain special URLs. In this way, we can talk directly to
764  <SPAN
765 CLASS="APPLICATION"
766 >Privoxy</SPAN
767 >, and see how it is 
768  configured, see how our rules are being applied, change these 
769  rules and other configuration options, and even turn
770  <SPAN
771 CLASS="APPLICATION"
772 >Privoxy's</SPAN
773 > filtering off, all with 
774  a web browser.&#13;</P
775 ><P
776 > The URLs listed below are the special ones that allow direct access 
777  to <SPAN
778 CLASS="APPLICATION"
779 >Privoxy</SPAN
780 >. Of course,
781  <SPAN
782 CLASS="APPLICATION"
783 >Privoxy</SPAN
784 > must be running to access these. If 
785  not, you will get a friendly error message. Internet access is not 
786  necessary either.</P
787 ><P
788 > <P
789 ></P
790 ><UL
791 ><LI
792 ><P
793 >  
794    Privoxy main page: 
795   </P
796 ><A
797 NAME="AEN5652"
798 ></A
799 ><BLOCKQUOTE
800 CLASS="BLOCKQUOTE"
801 ><P
802
803      <A
804 HREF="http://config.privoxy.org/"
805 TARGET="_top"
806 >http://config.privoxy.org/</A
807 >
808    </P
809 ></BLOCKQUOTE
810 ><P
811 >   There is a shortcut: <A
812 HREF="http://p.p/"
813 TARGET="_top"
814 >http://p.p/</A
815 > (But it
816    doesn't provide a fall-back to a real page, in case the request is not
817    sent through <SPAN
818 CLASS="APPLICATION"
819 >Privoxy</SPAN
820 >)
821   </P
822 ></LI
823 ><LI
824 ><P
825 >  
826     Show information about the current configuration, including viewing and 
827     editing of actions files:
828   </P
829 ><A
830 NAME="AEN5660"
831 ></A
832 ><BLOCKQUOTE
833 CLASS="BLOCKQUOTE"
834 ><P
835
836     <A
837 HREF="http://config.privoxy.org/show-status"
838 TARGET="_top"
839 >http://config.privoxy.org/show-status</A
840 >
841    </P
842 ></BLOCKQUOTE
843 ></LI
844 ><LI
845 ><P
846 >  
847     Show the source code version numbers:
848   </P
849 ><A
850 NAME="AEN5665"
851 ></A
852 ><BLOCKQUOTE
853 CLASS="BLOCKQUOTE"
854 ><P
855
856     <A
857 HREF="http://config.privoxy.org/show-version"
858 TARGET="_top"
859 >http://config.privoxy.org/show-version</A
860 >
861    </P
862 ></BLOCKQUOTE
863 ></LI
864 ><LI
865 ><P
866 >  
867    Show the browser's request headers:
868   </P
869 ><A
870 NAME="AEN5670"
871 ></A
872 ><BLOCKQUOTE
873 CLASS="BLOCKQUOTE"
874 ><P
875
876     <A
877 HREF="http://config.privoxy.org/show-request"
878 TARGET="_top"
879 >http://config.privoxy.org/show-request</A
880 >
881    </P
882 ></BLOCKQUOTE
883 ></LI
884 ><LI
885 ><P
886 >  
887    Show which actions apply to a URL and why:
888   </P
889 ><A
890 NAME="AEN5675"
891 ></A
892 ><BLOCKQUOTE
893 CLASS="BLOCKQUOTE"
894 ><P
895
896     <A
897 HREF="http://config.privoxy.org/show-url-info"
898 TARGET="_top"
899 >http://config.privoxy.org/show-url-info</A
900 >
901    </P
902 ></BLOCKQUOTE
903 ></LI
904 ><LI
905 ><P
906 >  
907    Toggle Privoxy on or off. This feature can be turned off/on in the main 
908    <TT
909 CLASS="FILENAME"
910 >config</TT
911 > file. When toggled <SPAN
912 CLASS="QUOTE"
913 >"off"</SPAN
914 >, <SPAN
915 CLASS="QUOTE"
916 >"Privoxy"</SPAN
917 >
918    continues to run, but only as a pass-through proxy, with no actions taking
919    place:
920   </P
921 ><A
922 NAME="AEN5683"
923 ></A
924 ><BLOCKQUOTE
925 CLASS="BLOCKQUOTE"
926 ><P
927
928     <A
929 HREF="http://config.privoxy.org/toggle"
930 TARGET="_top"
931 >http://config.privoxy.org/toggle</A
932 >
933    </P
934 ></BLOCKQUOTE
935 ><P
936 >   Short cuts. Turn off, then on: 
937   </P
938 ><A
939 NAME="AEN5687"
940 ></A
941 ><BLOCKQUOTE
942 CLASS="BLOCKQUOTE"
943 ><P
944
945      <A
946 HREF="http://config.privoxy.org/toggle?set=disable"
947 TARGET="_top"
948 >http://config.privoxy.org/toggle?set=disable</A
949 >
950    </P
951 ></BLOCKQUOTE
952 ><A
953 NAME="AEN5690"
954 ></A
955 ><BLOCKQUOTE
956 CLASS="BLOCKQUOTE"
957 ><P
958
959      <A
960 HREF="http://config.privoxy.org/toggle?set=enable"
961 TARGET="_top"
962 >http://config.privoxy.org/toggle?set=enable</A
963 >
964    </P
965 ></BLOCKQUOTE
966 ></LI
967 ></UL
968 ></P
969 ><P
970 > These may be bookmarked for quick reference. See next.&#13;</P
971 ><DIV
972 CLASS="SECT3"
973 ><H3
974 CLASS="SECT3"
975 ><A
976 NAME="BOOKMARKLETS"
977 >14.2.1. Bookmarklets</A
978 ></H3
979 ><P
980 > Below are some <SPAN
981 CLASS="QUOTE"
982 >"bookmarklets"</SPAN
983 > to allow you to easily access a
984  <SPAN
985 CLASS="QUOTE"
986 >"mini"</SPAN
987 > version of some of <SPAN
988 CLASS="APPLICATION"
989 >Privoxy's</SPAN
990 >
991  special pages. They are designed for MS Internet Explorer, but should work
992  equally well in Netscape, Mozilla, and other browsers which support
993  JavaScript. They are designed to run directly from your bookmarks - not by
994  clicking the links below (although that should work for testing).</P
995 ><P
996 > To save them, right-click the link and choose <SPAN
997 CLASS="QUOTE"
998 >"Add to Favorites"</SPAN
999 >
1000  (IE) or <SPAN
1001 CLASS="QUOTE"
1002 >"Add Bookmark"</SPAN
1003 > (Netscape). You will get a warning that
1004  the bookmark <SPAN
1005 CLASS="QUOTE"
1006 >"may not be safe"</SPAN
1007 > - just click OK. Then you can run the
1008  Bookmarklet directly from your favorites/bookmarks. For even faster access,
1009  you can put them on the <SPAN
1010 CLASS="QUOTE"
1011 >"Links"</SPAN
1012 > bar (IE) or the <SPAN
1013 CLASS="QUOTE"
1014 >"Personal
1015  Toolbar"</SPAN
1016 > (Netscape), and run them with a single click. </P
1017 ><P
1018 > <P
1019 ></P
1020 ><UL
1021 ><LI
1022 ><P
1023 >    <A
1024 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&#38;set=enabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1025 TARGET="_top"
1026 >Privoxy - Enable</A
1027 >
1028    </P
1029 ></LI
1030 ><LI
1031 ><P
1032 >    <A
1033 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&#38;set=disabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1034 TARGET="_top"
1035 >Privoxy - Disable</A
1036 >
1037    </P
1038 ></LI
1039 ><LI
1040 ><P
1041 >    <A
1042 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&#38;set=toggle','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1043 TARGET="_top"
1044 >Privoxy - Toggle Privoxy</A
1045 > (Toggles between enabled and disabled)
1046    </P
1047 ></LI
1048 ><LI
1049 ><P
1050 >    <A
1051 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y','ijbstatus','width=250,height=2,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1052 TARGET="_top"
1053 >Privoxy- View Status</A
1054 >
1055    </P
1056 ></LI
1057 ><LI
1058 ><P
1059 >    <A
1060 HREF="javascript:void(window.open('http://config.privoxy.org/show-url-info?url='+escape(location.href),'Why').focus());"
1061 TARGET="_top"
1062 >Privoxy - Why?</A
1063 >
1064    </P
1065 ></LI
1066 ></UL
1067 ></P
1068 ><P
1069 > Credit: The site which gave us the general idea for these bookmarklets is
1070  <A
1071 HREF="http://www.bookmarklets.com/"
1072 TARGET="_top"
1073 >www.bookmarklets.com</A
1074 >. They
1075  have more information about bookmarklets. </P
1076 ></DIV
1077 ></DIV
1078 ><DIV
1079 CLASS="SECT2"
1080 ><H2
1081 CLASS="SECT2"
1082 ><A
1083 NAME="CHAIN"
1084 >14.3. Chain of Events</A
1085 ></H2
1086 ><P
1087 > Let's take a quick look at how some of <SPAN
1088 CLASS="APPLICATION"
1089 >Privoxy's</SPAN
1090
1091  core features are triggered, and the ensuing sequence of events when a web
1092  page is requested by your browser:</P
1093 ><P
1094 > <P
1095 ></P
1096 ><UL
1097 ><LI
1098 ><P
1099 >   First, your web browser requests a web page. The browser knows to send 
1100    the request to <SPAN
1101 CLASS="APPLICATION"
1102 >Privoxy</SPAN
1103 >, which will in turn, 
1104    relay the request to the remote web server after passing the following 
1105    tests: 
1106   </P
1107 ></LI
1108 ><LI
1109 ><P
1110 >   <SPAN
1111 CLASS="APPLICATION"
1112 >Privoxy</SPAN
1113 > traps any request for its own internal CGI 
1114    pages (e.g <A
1115 HREF="http://p.p/"
1116 TARGET="_top"
1117 >http://p.p/</A
1118 >) and sends the CGI page back to the browser.
1119   </P
1120 ></LI
1121 ><LI
1122 ><P
1123 >   Next, <SPAN
1124 CLASS="APPLICATION"
1125 >Privoxy</SPAN
1126 > checks to see if the URL 
1127    matches any <A
1128 HREF="actions-file.html#BLOCK"
1129 ><SPAN
1130 CLASS="QUOTE"
1131 >"+block"</SPAN
1132 ></A
1133 > patterns. If
1134    so, the URL is then blocked, and the remote web server will not be contacted.
1135    <A
1136 HREF="actions-file.html#HANDLE-AS-IMAGE"
1137 ><SPAN
1138 CLASS="QUOTE"
1139 >"+handle-as-image"</SPAN
1140 ></A
1141
1142    and 
1143    <A
1144 HREF="actions-file.html#HANDLE-AS-EMPTY-DOCUMENT"
1145 ><SPAN
1146 CLASS="QUOTE"
1147 >"+handle-as-empty-document"</SPAN
1148 ></A
1149 >
1150    are then checked, and if there is no match, an 
1151    HTML <SPAN
1152 CLASS="QUOTE"
1153 >"BLOCKED"</SPAN
1154 > page is sent back to the browser. Otherwise, if
1155    it does match, an image is returned for the former, and an empty text
1156    document for the latter. The type of image would depend on the setting of
1157    <A
1158 HREF="actions-file.html#SET-IMAGE-BLOCKER"
1159 ><SPAN
1160 CLASS="QUOTE"
1161 >"+set-image-blocker"</SPAN
1162 ></A
1163 >
1164    (blank, checkerboard pattern, or an HTTP redirect to an image elsewhere).
1165   </P
1166 ></LI
1167 ><LI
1168 ><P
1169 >   Untrusted URLs are blocked. If URLs are being added to the
1170    <TT
1171 CLASS="FILENAME"
1172 >trust</TT
1173 > file, then that is done.
1174   </P
1175 ></LI
1176 ><LI
1177 ><P
1178 >   If the URL pattern matches the <A
1179 HREF="actions-file.html#FAST-REDIRECTS"
1180 ><SPAN
1181 CLASS="QUOTE"
1182 >"+fast-redirects"</SPAN
1183 ></A
1184 > action,
1185    it is then processed. Unwanted parts of the requested URL are stripped.
1186   </P
1187 ></LI
1188 ><LI
1189 ><P
1190 >   Now the rest of the client browser's request headers are processed. If any
1191    of these match any of the relevant actions (e.g. <A
1192 HREF="actions-file.html#HIDE-USER-AGENT"
1193 ><SPAN
1194 CLASS="QUOTE"
1195 >"+hide-user-agent"</SPAN
1196 ></A
1197 >,
1198    etc.), headers are suppressed or forged as determined by these actions and
1199    their parameters.
1200   </P
1201 ></LI
1202 ><LI
1203 ><P
1204 >   Now the web server starts sending its response back (i.e. typically a web
1205    page).
1206   </P
1207 ></LI
1208 ><LI
1209 ><P
1210 >   First, the server headers are read and processed to determine, among other
1211    things, the MIME type (document type) and encoding. The headers are then
1212    filtered as determined by the 
1213    <A
1214 HREF="actions-file.html#CRUNCH-INCOMING-COOKIES"
1215 ><SPAN
1216 CLASS="QUOTE"
1217 >"+crunch-incoming-cookies"</SPAN
1218 ></A
1219 >,
1220    <A
1221 HREF="actions-file.html#SESSION-COOKIES-ONLY"
1222 ><SPAN
1223 CLASS="QUOTE"
1224 >"+session-cookies-only"</SPAN
1225 ></A
1226 >,
1227    and <A
1228 HREF="actions-file.html#DOWNGRADE-HTTP-VERSION"
1229 ><SPAN
1230 CLASS="QUOTE"
1231 >"+downgrade-http-version"</SPAN
1232 ></A
1233 >
1234    actions.
1235   </P
1236 ></LI
1237 ><LI
1238 ><P
1239 >   If any <A
1240 HREF="actions-file.html#FILTER"
1241 ><SPAN
1242 CLASS="QUOTE"
1243 >"+filter"</SPAN
1244 ></A
1245 > action
1246    or <A
1247 HREF="actions-file.html#DEANIMATE-GIFS"
1248 ><SPAN
1249 CLASS="QUOTE"
1250 >"+deanimate-gifs"</SPAN
1251 ></A
1252 >
1253    action applies (and the document type fits the action), the rest of the page is
1254    read into memory (up to a configurable limit). Then the filter rules (from
1255    <TT
1256 CLASS="FILENAME"
1257 >default.filter</TT
1258 > and any other filter files) are
1259    processed against the buffered content. Filters are applied in the order
1260    they are specified in one of the filter files. Animated GIFs, if present,
1261    are reduced to either the first or last frame, depending on the action
1262    setting.The entire page, which is now filtered, is then sent by
1263    <SPAN
1264 CLASS="APPLICATION"
1265 >Privoxy</SPAN
1266 > back to your browser. 
1267   </P
1268 ><P
1269 >   If neither a <A
1270 HREF="actions-file.html#FILTER"
1271 ><SPAN
1272 CLASS="QUOTE"
1273 >"+filter"</SPAN
1274 ></A
1275 > action
1276    or <A
1277 HREF="actions-file.html#DEANIMATE-GIFS"
1278 ><SPAN
1279 CLASS="QUOTE"
1280 >"+deanimate-gifs"</SPAN
1281 ></A
1282 >
1283    matches, then <SPAN
1284 CLASS="APPLICATION"
1285 >Privoxy</SPAN
1286 > passes the raw data through 
1287    to the client browser as it becomes available.
1288   </P
1289 ></LI
1290 ><LI
1291 ><P
1292 >   As the browser receives the now (possibly filtered) page content, it 
1293    reads and then requests any URLs that may be embedded within the page
1294    source, e.g. ad images, stylesheets, JavaScript, other HTML documents (e.g.
1295    frames), sounds, etc. For each of these objects, the browser issues a
1296    separate request (this is easily viewable in <SPAN
1297 CLASS="APPLICATION"
1298 >Privoxy's</SPAN
1299 >
1300    logs). And each such request is in turn processed just as above. Note that a
1301    complex web page will have many, many such embedded URLs. If these 
1302    secondary requests are to a different server, then quite possibly a very 
1303    differing set of actions is triggered.
1304   </P
1305 ></LI
1306 ></UL
1307 ></P
1308 ><P
1309 > NOTE: This is somewhat of a simplistic overview of what happens with each URL
1310  request. For the sake of brevity and simplicity, we have focused on 
1311  <SPAN
1312 CLASS="APPLICATION"
1313 >Privoxy's</SPAN
1314 > core features only.</P
1315 ></DIV
1316 ><DIV
1317 CLASS="SECT2"
1318 ><H2
1319 CLASS="SECT2"
1320 ><A
1321 NAME="ACTIONSANAT"
1322 >14.4. Troubleshooting: Anatomy of an Action</A
1323 ></H2
1324 ><P
1325 > The way <SPAN
1326 CLASS="APPLICATION"
1327 >Privoxy</SPAN
1328 > applies 
1329  <A
1330 HREF="actions-file.html#ACTIONS"
1331 >actions</A
1332 > and <A
1333 HREF="actions-file.html#FILTER"
1334 >filters</A
1335 >
1336  to any given URL can be complex, and not always so
1337  easy to understand what is happening. And sometimes we need to be able to
1338  <SPAN
1339 CLASS="emphasis"
1340 ><I
1341 CLASS="EMPHASIS"
1342 >see</I
1343 ></SPAN
1344 > just what <SPAN
1345 CLASS="APPLICATION"
1346 >Privoxy</SPAN
1347 > is
1348  doing. Especially, if something <SPAN
1349 CLASS="APPLICATION"
1350 >Privoxy</SPAN
1351 > is doing
1352  is causing us a problem inadvertently. It can be a little daunting to look at
1353  the actions and filters files themselves, since they tend to be filled with
1354  <A
1355 HREF="appendix.html#REGEX"
1356 >regular expressions</A
1357 > whose consequences are not
1358  always so obvious. </P
1359 ><P
1360 > One quick test to see if <SPAN
1361 CLASS="APPLICATION"
1362 >Privoxy</SPAN
1363 > is causing a problem 
1364  or not, is to disable it temporarily. This should be the first troubleshooting 
1365  step. See <A
1366 HREF="appendix.html#BOOKMARKLETS"
1367 >the Bookmarklets</A
1368 > section on a quick 
1369  and easy way to do this (be sure to flush caches afterward!). Looking at the 
1370  logs is a good idea too. (Note that both the toggle feature and logging are 
1371  enabled via <TT
1372 CLASS="FILENAME"
1373 >config</TT
1374 > file settings, and may need to be 
1375  turned <SPAN
1376 CLASS="QUOTE"
1377 >"on"</SPAN
1378 >.)</P
1379 ><P
1380 > Another easy troubleshooting step to try is if you have done any
1381  customization of your installation, revert back to the installed
1382  defaults and see if that helps. There are times the developers get complaints
1383  about one thing or another, and the problem is more related to a customized
1384  configuration issue.</P
1385 ><P
1386 > <SPAN
1387 CLASS="APPLICATION"
1388 >Privoxy</SPAN
1389 > also provides the 
1390  <A
1391 HREF="http://config.privoxy.org/show-url-info"
1392 TARGET="_top"
1393 >http://config.privoxy.org/show-url-info</A
1394 >
1395  page that can show us very specifically how <SPAN
1396 CLASS="APPLICATION"
1397 >actions</SPAN
1398 >
1399  are being applied to any given URL. This is a big help for troubleshooting.</P
1400 ><P
1401 > First, enter one URL (or partial URL) at the prompt, and then
1402  <SPAN
1403 CLASS="APPLICATION"
1404 >Privoxy</SPAN
1405 > will tell us 
1406  how the current configuration will handle it. This will not
1407  help with filtering effects (i.e. the <A
1408 HREF="actions-file.html#FILTER"
1409 ><SPAN
1410 CLASS="QUOTE"
1411 >"+filter"</SPAN
1412 ></A
1413 > action) from
1414  one of the filter files since this is handled very
1415  differently and not so easy to trap! It also will not tell you about any other
1416  URLs that may be embedded within the URL you are testing. For instance, images
1417  such as ads are expressed as URLs within the raw page source of HTML pages. So
1418  you will only get info for the actual URL that is pasted into the prompt area
1419  -- not any sub-URLs. If you want to know about embedded URLs like ads, you
1420  will have to dig those out of the HTML source. Use your browser's <SPAN
1421 CLASS="QUOTE"
1422 >"View
1423  Page Source"</SPAN
1424 > option for this. Or right click on the ad, and grab the
1425  URL.</P
1426 ><P
1427 > Let's try an example, <A
1428 HREF="http://google.com"
1429 TARGET="_top"
1430 >google.com</A
1431 >, 
1432  and look at it one section at a time in a sample configuration (your real 
1433  configuration may vary):</P
1434 ><P
1435 > <TABLE
1436 BORDER="0"
1437 BGCOLOR="#E0E0E0"
1438 WIDTH="100%"
1439 ><TR
1440 ><TD
1441 ><PRE
1442 CLASS="SCREEN"
1443 > Matches for http://www.google.com:
1444
1445  In file: default.action <SPAN
1446 CLASS="GUIBUTTON"
1447 >[ View ]</SPAN
1448 > <SPAN
1449 CLASS="GUIBUTTON"
1450 >[ Edit ]</SPAN
1451 >
1452
1453  {+change-x-forwarded-for{block}
1454  +deanimate-gifs {last}
1455  +fast-redirects {check-decoded-url}
1456  +filter {refresh-tags}
1457  +filter {img-reorder}
1458  +filter {banners-by-size}
1459  +filter {webbugs}
1460  +filter {jumping-windows}
1461  +filter {ie-exploits}
1462  +hide-from-header {block}
1463  +hide-referrer {forge}
1464  +session-cookies-only
1465  +set-image-blocker {pattern}
1466 /
1467  
1468  { -session-cookies-only }
1469  .google.com
1470
1471  { -fast-redirects }
1472  .google.com
1473
1474 In file: user.action <SPAN
1475 CLASS="GUIBUTTON"
1476 >[ View ]</SPAN
1477 > <SPAN
1478 CLASS="GUIBUTTON"
1479 >[ Edit ]</SPAN
1480 >
1481 (no matches in this file)  </PRE
1482 ></TD
1483 ></TR
1484 ></TABLE
1485 ></P
1486 ><P
1487 > This is telling us how we have defined our 
1488  <A
1489 HREF="actions-file.html#ACTIONS"
1490 ><SPAN
1491 CLASS="QUOTE"
1492 >"actions"</SPAN
1493 ></A
1494 >, and
1495  which ones match for our test case, <SPAN
1496 CLASS="QUOTE"
1497 >"google.com"</SPAN
1498 >. 
1499  Displayed is all the actions that are available to us. Remember,
1500  the <TT
1501 CLASS="LITERAL"
1502 >+</TT
1503 > sign denotes <SPAN
1504 CLASS="QUOTE"
1505 >"on"</SPAN
1506 >. <TT
1507 CLASS="LITERAL"
1508 >-</TT
1509 >
1510  denotes <SPAN
1511 CLASS="QUOTE"
1512 >"off"</SPAN
1513 >. So some are <SPAN
1514 CLASS="QUOTE"
1515 >"on"</SPAN
1516 > here, but many 
1517  are <SPAN
1518 CLASS="QUOTE"
1519 >"off"</SPAN
1520 >. Each example we try may provide a slightly different
1521  end result, depending on our configuration directives.</P
1522 ><P
1523 > The first listing
1524   is for our <TT
1525 CLASS="FILENAME"
1526 >default.action</TT
1527 > file. The large, multi-line
1528   listing, is how the actions are set to match for all URLs, i.e. our default
1529   settings. If you look at your <SPAN
1530 CLASS="QUOTE"
1531 >"actions"</SPAN
1532 > file, this would be the
1533   section just below the <SPAN
1534 CLASS="QUOTE"
1535 >"aliases"</SPAN
1536 > section near the top. This
1537   will apply to all URLs as signified by the single forward slash at the end
1538   of the listing -- <SPAN
1539 CLASS="QUOTE"
1540 >" / "</SPAN
1541 >.</P
1542 ><P
1543 > But we have defined additional actions that would be exceptions to these general
1544  rules, and then we list specific URLs (or patterns) that these exceptions
1545  would apply to. Last match wins. Just below this then are two explicit
1546  matches for <SPAN
1547 CLASS="QUOTE"
1548 >".google.com"</SPAN
1549 >. The first is negating our previous
1550  cookie setting, which was for <A
1551 HREF="actions-file.html#SESSION-COOKIES-ONLY"
1552 ><SPAN
1553 CLASS="QUOTE"
1554 >"+session-cookies-only"</SPAN
1555 ></A
1556 >
1557  (i.e. not persistent). So we will allow persistent cookies for google, at
1558  least that is how it is in this example. The second turns
1559  <SPAN
1560 CLASS="emphasis"
1561 ><I
1562 CLASS="EMPHASIS"
1563 >off</I
1564 ></SPAN
1565 > any <A
1566 HREF="actions-file.html#FAST-REDIRECTS"
1567 ><SPAN
1568 CLASS="QUOTE"
1569 >"+fast-redirects"</SPAN
1570 ></A
1571 >
1572  action, allowing this to take place unmolested. Note that there is a leading
1573  dot here -- <SPAN
1574 CLASS="QUOTE"
1575 >".google.com"</SPAN
1576 >. This will match any hosts and
1577  sub-domains, in the google.com domain also, such as
1578  <SPAN
1579 CLASS="QUOTE"
1580 >"www.google.com"</SPAN
1581 > or <SPAN
1582 CLASS="QUOTE"
1583 >"mail.google.com"</SPAN
1584 >. But it would not 
1585  match <SPAN
1586 CLASS="QUOTE"
1587 >"www.google.de"</SPAN
1588 >! So, apparently, we have these two actions
1589  defined as exceptions to the general rules at the top somewhere in the lower
1590  part of our <TT
1591 CLASS="FILENAME"
1592 >default.action</TT
1593 > file, and
1594  <SPAN
1595 CLASS="QUOTE"
1596 >"google.com"</SPAN
1597 > is referenced somewhere in these latter sections.</P
1598 ><P
1599 > Then, for our <TT
1600 CLASS="FILENAME"
1601 >user.action</TT
1602 > file, we again have no hits.
1603  So there is nothing google-specific that we might have added to our own, local
1604  configuration. If there was, those actions would over-rule any actions from 
1605  previously processed files, such as <TT
1606 CLASS="FILENAME"
1607 >default.action</TT
1608 >.
1609  <TT
1610 CLASS="FILENAME"
1611 >user.action</TT
1612 > typically has the last word. This is the
1613  best place to put hard and fast exceptions,</P
1614 ><P
1615 > And finally we pull it all together in the bottom section and summarize how
1616  <SPAN
1617 CLASS="APPLICATION"
1618 >Privoxy</SPAN
1619 > is applying all its <SPAN
1620 CLASS="QUOTE"
1621 >"actions"</SPAN
1622
1623  to <SPAN
1624 CLASS="QUOTE"
1625 >"google.com"</SPAN
1626 >:&#13;</P
1627 ><P
1628 > <TABLE
1629 BORDER="0"
1630 BGCOLOR="#E0E0E0"
1631 WIDTH="100%"
1632 ><TR
1633 ><TD
1634 ><PRE
1635 CLASS="SCREEN"
1636 >&#13; Final results:
1637  
1638  -add-header
1639  -block
1640  +change-x-forwarded-for{block} 
1641  -client-header-filter{hide-tor-exit-notation}
1642  -content-type-overwrite
1643  -crunch-client-header
1644  -crunch-if-none-match
1645  -crunch-incoming-cookies
1646  -crunch-outgoing-cookies
1647  -crunch-server-header
1648  +deanimate-gifs {last}
1649  -downgrade-http-version
1650  -fast-redirects
1651  -filter {js-events}
1652  -filter {content-cookies}
1653  -filter {all-popups}
1654  -filter {banners-by-link}
1655  -filter {tiny-textforms}
1656  -filter {frameset-borders}
1657  -filter {demoronizer}
1658  -filter {shockwave-flash}
1659  -filter {quicktime-kioskmode}
1660  -filter {fun}
1661  -filter {crude-parental}
1662  -filter {site-specifics}
1663  -filter {js-annoyances}
1664  -filter {html-annoyances}
1665  +filter {refresh-tags}
1666  -filter {unsolicited-popups}
1667  +filter {img-reorder}
1668  +filter {banners-by-size}
1669  +filter {webbugs}
1670  +filter {jumping-windows}
1671  +filter {ie-exploits}
1672  -filter {google}
1673  -filter {yahoo}
1674  -filter {msn}
1675  -filter {blogspot}
1676  -filter {no-ping}
1677  -force-text-mode
1678  -handle-as-empty-document
1679  -handle-as-image
1680  -hide-accept-language
1681  -hide-content-disposition
1682  +hide-from-header {block}
1683  -hide-if-modified-since
1684  +hide-referrer {forge}
1685  -hide-user-agent
1686  -limit-connect
1687  -overwrite-last-modified
1688  -prevent-compression
1689  -redirect
1690  -server-header-filter{xml-to-html}
1691  -server-header-filter{html-to-xml} 
1692  -session-cookies-only
1693  +set-image-blocker {pattern} </PRE
1694 ></TD
1695 ></TR
1696 ></TABLE
1697 ></P
1698 ><P
1699 > Notice the only difference here to the previous listing, is to 
1700  <SPAN
1701 CLASS="QUOTE"
1702 >"fast-redirects"</SPAN
1703 > and <SPAN
1704 CLASS="QUOTE"
1705 >"session-cookies-only"</SPAN
1706 >,
1707  which are activated specifically for this site in our configuration, 
1708  and thus show in the <SPAN
1709 CLASS="QUOTE"
1710 >"Final Results"</SPAN
1711 >.</P
1712 ><P
1713 > Now another example, <SPAN
1714 CLASS="QUOTE"
1715 >"ad.doubleclick.net"</SPAN
1716 >:</P
1717 ><P
1718 > <TABLE
1719 BORDER="0"
1720 BGCOLOR="#E0E0E0"
1721 WIDTH="100%"
1722 ><TR
1723 ><TD
1724 ><PRE
1725 CLASS="SCREEN"
1726 >&#13; { +block{Domains starts with "ad"} }
1727   ad*.
1728
1729  { +block{Domain contains "ad"} }
1730   .ad.
1731
1732  { +block{Doubleclick banner server} +handle-as-image }
1733   .[a-vx-z]*.doubleclick.net</PRE
1734 ></TD
1735 ></TR
1736 ></TABLE
1737 ></P
1738 ><P
1739 > We'll just show the interesting part here - the explicit matches. It is 
1740  matched three different times. Two <SPAN
1741 CLASS="QUOTE"
1742 >"+block{}"</SPAN
1743 > sections, 
1744  and a <SPAN
1745 CLASS="QUOTE"
1746 >"+block{} +handle-as-image"</SPAN
1747 >,
1748  which is the expanded form of one of our aliases that had been defined as: 
1749  <SPAN
1750 CLASS="QUOTE"
1751 >"+block-as-image"</SPAN
1752 >. (<A
1753 HREF="actions-file.html#ALIASES"
1754 ><SPAN
1755 CLASS="QUOTE"
1756 >"Aliases"</SPAN
1757 ></A
1758 > are defined in
1759  the first section of the actions file and typically used to combine more 
1760  than one action.)</P
1761 ><P
1762 > Any one of these would have done the trick and blocked this as an unwanted 
1763  image. This is unnecessarily redundant since the last case effectively 
1764  would also cover the first. No point in taking chances with these guys 
1765  though ;-) Note that if you want an ad or obnoxious 
1766  URL to be invisible, it should be defined as <SPAN
1767 CLASS="QUOTE"
1768 >"ad.doubleclick.net"</SPAN
1769 >
1770  is done here -- as both a <A
1771 HREF="actions-file.html#BLOCK"
1772 ><SPAN
1773 CLASS="QUOTE"
1774 >"+block{}"</SPAN
1775 ></A
1776 >
1777  <SPAN
1778 CLASS="emphasis"
1779 ><I
1780 CLASS="EMPHASIS"
1781 >and</I
1782 ></SPAN
1783 > an 
1784  <A
1785 HREF="actions-file.html#HANDLE-AS-IMAGE"
1786 ><SPAN
1787 CLASS="QUOTE"
1788 >"+handle-as-image"</SPAN
1789 ></A
1790 >.
1791  The custom alias <SPAN
1792 CLASS="QUOTE"
1793 >"<TT
1794 CLASS="LITERAL"
1795 >+block-as-image</TT
1796 >"</SPAN
1797 > just
1798  simplifies the process and make it more readable.</P
1799 ><P
1800 > One last example. Let's try <SPAN
1801 CLASS="QUOTE"
1802 >"http://www.example.net/adsl/HOWTO/"</SPAN
1803 >.
1804  This one is giving us problems. We are getting a blank page. Hmmm ...</P
1805 ><P
1806 > <TABLE
1807 BORDER="0"
1808 BGCOLOR="#E0E0E0"
1809 WIDTH="100%"
1810 ><TR
1811 ><TD
1812 ><PRE
1813 CLASS="SCREEN"
1814 >&#13; Matches for http://www.example.net/adsl/HOWTO/:
1815
1816  In file: default.action <SPAN
1817 CLASS="GUIBUTTON"
1818 >[ View ]</SPAN
1819 > <SPAN
1820 CLASS="GUIBUTTON"
1821 >[ Edit ]</SPAN
1822 >
1823
1824  {-add-header 
1825   -block
1826   +change-x-forwarded-for{block} 
1827   -client-header-filter{hide-tor-exit-notation}
1828   -content-type-overwrite
1829   -crunch-client-header
1830   -crunch-if-none-match
1831   -crunch-incoming-cookies
1832   -crunch-outgoing-cookies
1833   -crunch-server-header
1834   +deanimate-gifs 
1835   -downgrade-http-version 
1836   +fast-redirects {check-decoded-url}
1837   -filter {js-events}
1838   -filter {content-cookies}
1839   -filter {all-popups}
1840   -filter {banners-by-link}
1841   -filter {tiny-textforms}
1842   -filter {frameset-borders}
1843   -filter {demoronizer}
1844   -filter {shockwave-flash}
1845   -filter {quicktime-kioskmode}
1846   -filter {fun}
1847   -filter {crude-parental}
1848   -filter {site-specifics}
1849   -filter {js-annoyances}
1850   -filter {html-annoyances}
1851   +filter {refresh-tags}
1852   -filter {unsolicited-popups}
1853   +filter {img-reorder}
1854   +filter {banners-by-size}
1855   +filter {webbugs}
1856   +filter {jumping-windows}
1857   +filter {ie-exploits}
1858   -filter {google}
1859   -filter {yahoo}
1860   -filter {msn}
1861   -filter {blogspot}
1862   -filter {no-ping}
1863   -force-text-mode
1864   -handle-as-empty-document
1865   -handle-as-image 
1866   -hide-accept-language
1867   -hide-content-disposition  
1868   +hide-from-header{block} 
1869   +hide-referer{forge} 
1870   -hide-user-agent 
1871   -overwrite-last-modified
1872   +prevent-compression 
1873   -redirect
1874   -server-header-filter{xml-to-html}
1875   -server-header-filter{html-to-xml} 
1876   +session-cookies-only 
1877   +set-image-blocker{blank} }
1878    /
1879
1880  { +block{Path contains "ads".} +handle-as-image }
1881   /ads</PRE
1882 ></TD
1883 ></TR
1884 ></TABLE
1885 ></P
1886 ><P
1887 > Ooops, the <SPAN
1888 CLASS="QUOTE"
1889 >"/adsl/"</SPAN
1890 > is matching <SPAN
1891 CLASS="QUOTE"
1892 >"/ads"</SPAN
1893 > in our 
1894  configuration! But we did not want this at all! Now we see why we get the
1895  blank page. It is actually triggering two different actions here, and 
1896  the effects are aggregated so that the URL is blocked, and <SPAN
1897 CLASS="APPLICATION"
1898 >Privoxy</SPAN
1899 > is told 
1900  to treat the block as if it were an image. But this is, of course, all wrong.
1901   We could now add a new action below this (or better in our own
1902   <TT
1903 CLASS="FILENAME"
1904 >user.action</TT
1905 > file) that explicitly
1906   <SPAN
1907 CLASS="emphasis"
1908 ><I
1909 CLASS="EMPHASIS"
1910 >un</I
1911 ></SPAN
1912 > blocks (
1913   <A
1914 HREF="actions-file.html#BLOCK"
1915 ><SPAN
1916 CLASS="QUOTE"
1917 >"{-block}"</SPAN
1918 ></A
1919 >) paths with
1920   <SPAN
1921 CLASS="QUOTE"
1922 >"adsl"</SPAN
1923 > in them (remember, last match in the configuration
1924   wins). There are various ways to handle such exceptions. Example:</P
1925 ><P
1926 > <TABLE
1927 BORDER="0"
1928 BGCOLOR="#E0E0E0"
1929 WIDTH="100%"
1930 ><TR
1931 ><TD
1932 ><PRE
1933 CLASS="SCREEN"
1934 >&#13; { -block }
1935   /adsl</PRE
1936 ></TD
1937 ></TR
1938 ></TABLE
1939 ></P
1940 ><P
1941 > Now the page displays ;-) 
1942  Remember to flush your browser's caches when making these kinds of changes to
1943  your configuration to insure that you get a freshly delivered page! Or, try
1944  using <TT
1945 CLASS="LITERAL"
1946 >Shift+Reload</TT
1947 >.</P
1948 ><P
1949 > But now what about a situation where we get no explicit matches like 
1950  we did with:</P
1951 ><P
1952 > <TABLE
1953 BORDER="0"
1954 BGCOLOR="#E0E0E0"
1955 WIDTH="100%"
1956 ><TR
1957 ><TD
1958 ><PRE
1959 CLASS="SCREEN"
1960 >&#13; { +block{Path starts with "ads".} +handle-as-image }
1961  /ads</PRE
1962 ></TD
1963 ></TR
1964 ></TABLE
1965 ></P
1966 ><P
1967 > That actually was very helpful and pointed us quickly to where the problem
1968  was. If you don't get this kind of match, then it means one of the default 
1969  rules in the first section of <TT
1970 CLASS="FILENAME"
1971 >default.action</TT
1972 > is causing
1973  the problem. This would require some guesswork, and maybe a little trial and
1974  error to isolate the offending rule. One likely cause would be one of the
1975  <A
1976 HREF="actions-file.html#FILTER"
1977 ><SPAN
1978 CLASS="QUOTE"
1979 >"+filter"</SPAN
1980 ></A
1981 > actions.
1982  These tend to be harder to troubleshoot.
1983  Try adding the URL for the site to one of aliases that turn off
1984  <A
1985 HREF="actions-file.html#FILTER"
1986 ><SPAN
1987 CLASS="QUOTE"
1988 >"+filter"</SPAN
1989 ></A
1990 >:</P
1991 ><P
1992 > <TABLE
1993 BORDER="0"
1994 BGCOLOR="#E0E0E0"
1995 WIDTH="100%"
1996 ><TR
1997 ><TD
1998 ><PRE
1999 CLASS="SCREEN"
2000 >&#13; { shop }
2001  .quietpc.com
2002  .worldpay.com   # for quietpc.com
2003  .jungle.com
2004  .scan.co.uk
2005  .forbes.com</PRE
2006 ></TD
2007 ></TR
2008 ></TABLE
2009 ></P
2010 ><P
2011 > <SPAN
2012 CLASS="QUOTE"
2013 >"<TT
2014 CLASS="LITERAL"
2015 >{ shop }</TT
2016 >"</SPAN
2017 > is an <SPAN
2018 CLASS="QUOTE"
2019 >"alias"</SPAN
2020 > that expands to 
2021  <SPAN
2022 CLASS="QUOTE"
2023 >"<TT
2024 CLASS="LITERAL"
2025 >{ -filter -session-cookies-only }</TT
2026 >"</SPAN
2027 >.
2028  Or you could do your own exception to negate filtering:&#13;</P
2029 ><P
2030 > <TABLE
2031 BORDER="0"
2032 BGCOLOR="#E0E0E0"
2033 WIDTH="100%"
2034 ><TR
2035 ><TD
2036 ><PRE
2037 CLASS="SCREEN"
2038 >&#13; { -filter }
2039  # Disable ALL filter actions for sites in this section
2040  .forbes.com
2041  developer.ibm.com
2042  localhost</PRE
2043 ></TD
2044 ></TR
2045 ></TABLE
2046 ></P
2047 ><P
2048 > This would turn off all filtering for these sites. This is best
2049  put in <TT
2050 CLASS="FILENAME"
2051 >user.action</TT
2052 >, for local site
2053  exceptions. Note that when a simple domain pattern is used by itself (without
2054  the subsequent path portion), all sub-pages within that domain are included 
2055  automatically in the scope of the action.</P
2056 ><P
2057 > Images that are inexplicably being blocked, may well be hitting the 
2058 <A
2059 HREF="actions-file.html#FILTER-BANNERS-BY-SIZE"
2060 ><SPAN
2061 CLASS="QUOTE"
2062 >"+filter{banners-by-size}"</SPAN
2063 ></A
2064 >
2065  rule, which assumes 
2066  that images of certain sizes are ad banners (works well 
2067  <SPAN
2068 CLASS="emphasis"
2069 ><I
2070 CLASS="EMPHASIS"
2071 >most of the time</I
2072 ></SPAN
2073 >  since these tend to be standardized).</P
2074 ><P
2075 > <SPAN
2076 CLASS="QUOTE"
2077 >"<TT
2078 CLASS="LITERAL"
2079 >{ fragile }</TT
2080 >"</SPAN
2081 > is an alias that disables most
2082  actions that are the most likely to cause trouble. This can be used as a
2083  last resort for problem sites. </P
2084 ><P
2085 > <TABLE
2086 BORDER="0"
2087 BGCOLOR="#E0E0E0"
2088 WIDTH="100%"
2089 ><TR
2090 ><TD
2091 ><PRE
2092 CLASS="SCREEN"
2093 >&#13; { fragile }
2094  # Handle with care: easy to break
2095  mail.google.
2096  mybank.example.com</PRE
2097 ></TD
2098 ></TR
2099 ></TABLE
2100 ></P
2101 ><P
2102 > <SPAN
2103 CLASS="emphasis"
2104 ><I
2105 CLASS="EMPHASIS"
2106 >Remember to flush caches!</I
2107 ></SPAN
2108 > Note that the 
2109  <TT
2110 CLASS="LITERAL"
2111 >mail.google</TT
2112 > reference lacks the TLD portion (e.g. 
2113  <SPAN
2114 CLASS="QUOTE"
2115 >".com"</SPAN
2116 >). This will effectively match any TLD with 
2117  <TT
2118 CLASS="LITERAL"
2119 >google</TT
2120 > in it, such as <TT
2121 CLASS="LITERAL"
2122 >mail.google.de.</TT
2123 >, 
2124  just as an example.</P
2125 ><P
2126
2127  If this still does not work, you will have to go through the remaining
2128  actions one by one to find which one(s) is causing the problem.</P
2129 ></DIV
2130 ></DIV
2131 ><DIV
2132 CLASS="NAVFOOTER"
2133 ><HR
2134 ALIGN="LEFT"
2135 WIDTH="100%"><TABLE
2136 SUMMARY="Footer navigation table"
2137 WIDTH="100%"
2138 BORDER="0"
2139 CELLPADDING="0"
2140 CELLSPACING="0"
2141 ><TR
2142 ><TD
2143 WIDTH="33%"
2144 ALIGN="left"
2145 VALIGN="top"
2146 ><A
2147 HREF="seealso.html"
2148 ACCESSKEY="P"
2149 >Prev</A
2150 ></TD
2151 ><TD
2152 WIDTH="34%"
2153 ALIGN="center"
2154 VALIGN="top"
2155 ><A
2156 HREF="index.html"
2157 ACCESSKEY="H"
2158 >Home</A
2159 ></TD
2160 ><TD
2161 WIDTH="33%"
2162 ALIGN="right"
2163 VALIGN="top"
2164 >&nbsp;</TD
2165 ></TR
2166 ><TR
2167 ><TD
2168 WIDTH="33%"
2169 ALIGN="left"
2170 VALIGN="top"
2171 >See Also</TD
2172 ><TD
2173 WIDTH="34%"
2174 ALIGN="center"
2175 VALIGN="top"
2176 >&nbsp;</TD
2177 ><TD
2178 WIDTH="33%"
2179 ALIGN="right"
2180 VALIGN="top"
2181 >&nbsp;</TD
2182 ></TR
2183 ></TABLE
2184 ></DIV
2185 ></BODY
2186 ></HTML
2187 >