Version updated, etc.
[privoxy.git] / doc / webserver / user-manual / appendix.html
1 <HTML
2 ><HEAD
3 ><TITLE
4 >Appendix</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
8 "><LINK
9 REL="HOME"
10 TITLE="Privoxy 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"></HEAD
18 ><BODY
19 CLASS="SECT1"
20 BGCOLOR="#EEEEEE"
21 TEXT="#000000"
22 LINK="#0000FF"
23 VLINK="#840084"
24 ALINK="#0000FF"
25 ><DIV
26 CLASS="NAVHEADER"
27 ><TABLE
28 WIDTH="100%"
29 BORDER="0"
30 CELLPADDING="0"
31 CELLSPACING="0"
32 ><TR
33 ><TH
34 COLSPAN="3"
35 ALIGN="center"
36 >Privoxy User Manual</TH
37 ></TR
38 ><TR
39 ><TD
40 WIDTH="10%"
41 ALIGN="left"
42 VALIGN="bottom"
43 ><A
44 HREF="seealso.html"
45 >Prev</A
46 ></TD
47 ><TD
48 WIDTH="80%"
49 ALIGN="center"
50 VALIGN="bottom"
51 ></TD
52 ><TD
53 WIDTH="10%"
54 ALIGN="right"
55 VALIGN="bottom"
56 >&nbsp;</TD
57 ></TR
58 ></TABLE
59 ><HR
60 ALIGN="LEFT"
61 WIDTH="100%"></DIV
62 ><DIV
63 CLASS="SECT1"
64 ><H1
65 CLASS="SECT1"
66 ><A
67 NAME="APPENDIX"
68 >9. Appendix</A
69 ></H1
70 ><DIV
71 CLASS="SECT2"
72 ><H2
73 CLASS="SECT2"
74 ><A
75 NAME="REGEX"
76 >9.1. Regular Expressions</A
77 ></H2
78 ><P
79 > <SPAN
80 CLASS="APPLICATION"
81 >Privoxy</SPAN
82 > can use <SPAN
83 CLASS="QUOTE"
84 >"regular expressions"</SPAN
85
86  in various config files. Assuming support for <SPAN
87 CLASS="QUOTE"
88 >"pcre"</SPAN
89 > (Perl
90  Compatible Regular Expressions) is compiled in, which is the default. Such
91  configuration directives do not require regular expressions, but they can be
92  used to increase flexibility by matching a pattern with wild-cards against
93  URLs.</P
94 ><P
95 > If you are reading this, you probably don't understand what <SPAN
96 CLASS="QUOTE"
97 >"regular
98  expressions"</SPAN
99 > are, or what they can do. So this will be a very brief
100  introduction only. A full explanation would require a book ;-)</P
101 ><P
102 > <SPAN
103 CLASS="QUOTE"
104 >"Regular expressions"</SPAN
105 > is a way of matching one character
106  expression against another to see if it matches or not. One of the
107  <SPAN
108 CLASS="QUOTE"
109 >"expressions"</SPAN
110 > is a literal string of readable characters
111  (letter, numbers, etc), and the other is a complex string of literal
112  characters combined with wild-cards, and other special characters, called
113  meta-characters. The <SPAN
114 CLASS="QUOTE"
115 >"meta-characters"</SPAN
116 > have special meanings and
117  are used to build the complex pattern to be matched against. Perl Compatible
118  Regular Expressions is an enhanced form of the regular expression language
119  with backward compatibility.</P
120 ><P
121 > To make a simple analogy, we do something similar when we use wild-card
122  characters when listing files with the <B
123 CLASS="COMMAND"
124 >dir</B
125 > command in DOS. 
126  <TT
127 CLASS="LITERAL"
128 >*.*</TT
129 > matches all filenames. The <SPAN
130 CLASS="QUOTE"
131 >"special"</SPAN
132 >
133  character here is the asterisk which matches any and all characters. We can be
134  more specific and use <TT
135 CLASS="LITERAL"
136 >?</TT
137 > to match just individual
138  characters. So <SPAN
139 CLASS="QUOTE"
140 >"dir file?.text"</SPAN
141 > would match
142  <SPAN
143 CLASS="QUOTE"
144 >"file1.txt"</SPAN
145 >, <SPAN
146 CLASS="QUOTE"
147 >"file2.txt"</SPAN
148 >, etc. We are pattern
149  matching, using a similar technique to <SPAN
150 CLASS="QUOTE"
151 >"regular expressions"</SPAN
152 >!</P
153 ><P
154 > Regular expressions do essentially the same thing, but are much, much more
155  powerful. There are many more <SPAN
156 CLASS="QUOTE"
157 >"special characters"</SPAN
158 > and ways of 
159  building complex patterns however. Let's look at a few of the common ones,
160  and then some examples:</P
161 ><P
162 ></P
163 ><TABLE
164 BORDER="0"
165 ><TBODY
166 ><TR
167 ><TD
168 >  <I
169 CLASS="EMPHASIS"
170 >.</I
171 > - Matches any single character, e.g. <SPAN
172 CLASS="QUOTE"
173 >"a"</SPAN
174 >,
175   <SPAN
176 CLASS="QUOTE"
177 >"A"</SPAN
178 >, <SPAN
179 CLASS="QUOTE"
180 >"4"</SPAN
181 >, <SPAN
182 CLASS="QUOTE"
183 >":"</SPAN
184 >, or <SPAN
185 CLASS="QUOTE"
186 >"@"</SPAN
187 >.
188  </TD
189 ></TR
190 ></TBODY
191 ></TABLE
192 ><P
193 ></P
194 ><P
195 ></P
196 ><TABLE
197 BORDER="0"
198 ><TBODY
199 ><TR
200 ><TD
201 >  <I
202 CLASS="EMPHASIS"
203 >?</I
204 > - The preceding character or expression is matched ZERO or ONE
205   times. Either/or.
206  </TD
207 ></TR
208 ></TBODY
209 ></TABLE
210 ><P
211 ></P
212 ><P
213 ></P
214 ><TABLE
215 BORDER="0"
216 ><TBODY
217 ><TR
218 ><TD
219 >  <I
220 CLASS="EMPHASIS"
221 >+</I
222 > - The preceding character or expression is matched ONE or MORE
223   times.
224  </TD
225 ></TR
226 ></TBODY
227 ></TABLE
228 ><P
229 ></P
230 ><P
231 ></P
232 ><TABLE
233 BORDER="0"
234 ><TBODY
235 ><TR
236 ><TD
237 >  <I
238 CLASS="EMPHASIS"
239 >*</I
240 > - The preceding character or expression is matched ZERO or MORE
241   times.
242  </TD
243 ></TR
244 ></TBODY
245 ></TABLE
246 ><P
247 ></P
248 ><P
249 ></P
250 ><TABLE
251 BORDER="0"
252 ><TBODY
253 ><TR
254 ><TD
255 >  <I
256 CLASS="EMPHASIS"
257 >\</I
258 > - The <SPAN
259 CLASS="QUOTE"
260 >"escape"</SPAN
261 > character denotes that
262   the following character should be taken literally. This is used where one of the 
263   special characters (e.g. <SPAN
264 CLASS="QUOTE"
265 >"."</SPAN
266 >) needs to be taken literally and
267   not as a special meta-character.
268  </TD
269 ></TR
270 ></TBODY
271 ></TABLE
272 ><P
273 ></P
274 ><P
275 ></P
276 ><TABLE
277 BORDER="0"
278 ><TBODY
279 ><TR
280 ><TD
281 >  <I
282 CLASS="EMPHASIS"
283 >[]</I
284 > - Characters enclosed in brackets will be matched if
285   any of the enclosed characters are encountered.
286  </TD
287 ></TR
288 ></TBODY
289 ></TABLE
290 ><P
291 ></P
292 ><P
293 ></P
294 ><TABLE
295 BORDER="0"
296 ><TBODY
297 ><TR
298 ><TD
299 >  <I
300 CLASS="EMPHASIS"
301 >()</I
302 > - parentheses are used to group a sub-expression,
303   or multiple sub-expressions.
304  </TD
305 ></TR
306 ></TBODY
307 ></TABLE
308 ><P
309 ></P
310 ><P
311 ></P
312 ><TABLE
313 BORDER="0"
314 ><TBODY
315 ><TR
316 ><TD
317 >  <I
318 CLASS="EMPHASIS"
319 >|</I
320 > - The <SPAN
321 CLASS="QUOTE"
322 >"bar"</SPAN
323 > character works like an
324   <SPAN
325 CLASS="QUOTE"
326 >"or"</SPAN
327 > conditional statement. A match is successful if the
328   sub-expression on either side of <SPAN
329 CLASS="QUOTE"
330 >"|"</SPAN
331 > matches.
332  </TD
333 ></TR
334 ></TBODY
335 ></TABLE
336 ><P
337 ></P
338 ><P
339 ></P
340 ><TABLE
341 BORDER="0"
342 ><TBODY
343 ><TR
344 ><TD
345 >  <I
346 CLASS="EMPHASIS"
347 >s/string1/string2/g</I
348 > - This is used to rewrite strings of text. 
349   <SPAN
350 CLASS="QUOTE"
351 >"string1"</SPAN
352 > is replaced by <SPAN
353 CLASS="QUOTE"
354 >"string2"</SPAN
355 > in this
356   example.
357  </TD
358 ></TR
359 ></TBODY
360 ></TABLE
361 ><P
362 ></P
363 ><P
364 > These are just some of the ones you are likely to use when matching URLs with 
365  <SPAN
366 CLASS="APPLICATION"
367 >Privoxy</SPAN
368 >, and is a long way from a definitive
369  list. This is enough to get us started with a few simple examples which may
370  be more illuminating:</P
371 ><P
372 > <I
373 CLASS="EMPHASIS"
374 ><TT
375 CLASS="LITERAL"
376 >/.*/banners/.*</TT
377 ></I
378 > - A  simple example
379  that uses the common combination of <SPAN
380 CLASS="QUOTE"
381 >"."</SPAN
382 > and <SPAN
383 CLASS="QUOTE"
384 >"*"</SPAN
385 > to 
386  denote any character, zero or more times. In other words, any string at all.
387  So we start with a literal forward slash, then our regular expression pattern 
388  (<SPAN
389 CLASS="QUOTE"
390 >".*"</SPAN
391 >) another literal forward slash, the string
392  <SPAN
393 CLASS="QUOTE"
394 >"banners"</SPAN
395 >, another forward slash, and lastly another
396  <SPAN
397 CLASS="QUOTE"
398 >".*"</SPAN
399 >. We are building 
400  a directory path here. This will match any file with the path that has a
401  directory named <SPAN
402 CLASS="QUOTE"
403 >"banners"</SPAN
404 > in it. The <SPAN
405 CLASS="QUOTE"
406 >".*"</SPAN
407 > matches
408  any characters, and this could conceivably be more forward slashes, so it
409  might expand into a much longer looking path. For example, this could match:
410  <SPAN
411 CLASS="QUOTE"
412 >"/eye/hate/spammers/banners/annoy_me_please.gif"</SPAN
413 >, or just
414  <SPAN
415 CLASS="QUOTE"
416 >"/banners/annoying.html"</SPAN
417 >, or almost an infinite number of other
418  possible combinations, just so it has <SPAN
419 CLASS="QUOTE"
420 >"banners"</SPAN
421 > in the path
422  somewhere.</P
423 ><P
424 > A now something a little more complex:</P
425 ><P
426 > <I
427 CLASS="EMPHASIS"
428 ><TT
429 CLASS="LITERAL"
430 >/.*/adv((er)?ts?|ertis(ing|ements?))?/</TT
431 ></I
432 > - 
433  We have several literal forward slashes again (<SPAN
434 CLASS="QUOTE"
435 >"/"</SPAN
436 >), so we are
437  building another expression that is a file path statement. We have another 
438  <SPAN
439 CLASS="QUOTE"
440 >".*"</SPAN
441 >, so we are matching against any conceivable sub-path, just so
442  it matches our expression. The only true literal that <I
443 CLASS="EMPHASIS"
444 >must
445  match</I
446 > our pattern is <SPAN
447 CLASS="APPLICATION"
448 >adv</SPAN
449 >, together with
450  the forward slashes. What comes after the <SPAN
451 CLASS="QUOTE"
452 >"adv"</SPAN
453 > string is the
454  interesting part. </P
455 ><P
456 > Remember the <SPAN
457 CLASS="QUOTE"
458 >"?"</SPAN
459 > means the preceding expression (either a
460  literal character or anything grouped with <SPAN
461 CLASS="QUOTE"
462 >"(...)"</SPAN
463 > in this case)
464  can exist or not, since this means either zero or one match. So
465  <SPAN
466 CLASS="QUOTE"
467 >"((er)?ts?|ertis(ing|ements?))"</SPAN
468 > is optional, as are the
469  individual sub-expressions: <SPAN
470 CLASS="QUOTE"
471 >"(er)"</SPAN
472 >,
473  <SPAN
474 CLASS="QUOTE"
475 >"(ing|ements?)"</SPAN
476 >, and the <SPAN
477 CLASS="QUOTE"
478 >"s"</SPAN
479 >. The <SPAN
480 CLASS="QUOTE"
481 >"|"</SPAN
482 >
483  means <SPAN
484 CLASS="QUOTE"
485 >"or"</SPAN
486 >. We have two of those. For instance, 
487  <SPAN
488 CLASS="QUOTE"
489 >"(ing|ements?)"</SPAN
490 >, can expand to match either <SPAN
491 CLASS="QUOTE"
492 >"ing"</SPAN
493
494  <I
495 CLASS="EMPHASIS"
496 >OR</I
497 > <SPAN
498 CLASS="QUOTE"
499 >"ements?"</SPAN
500 >. What is being done here, is an
501  attempt at matching as many variations of <SPAN
502 CLASS="QUOTE"
503 >"advertisement"</SPAN
504 >, and 
505  similar, as possible. So this would expand to match just <SPAN
506 CLASS="QUOTE"
507 >"adv"</SPAN
508 >,
509  or <SPAN
510 CLASS="QUOTE"
511 >"advert"</SPAN
512 >, or <SPAN
513 CLASS="QUOTE"
514 >"adverts"</SPAN
515 >, or
516  <SPAN
517 CLASS="QUOTE"
518 >"advertising"</SPAN
519 >, or <SPAN
520 CLASS="QUOTE"
521 >"advertisement"</SPAN
522 >, or
523  <SPAN
524 CLASS="QUOTE"
525 >"advertisements"</SPAN
526 >. You get the idea. But it would not match 
527  <SPAN
528 CLASS="QUOTE"
529 >"advertizements"</SPAN
530 > (with a <SPAN
531 CLASS="QUOTE"
532 >"z"</SPAN
533 >). We could fix that by
534  changing our regular expression to: 
535  <SPAN
536 CLASS="QUOTE"
537 >"/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/"</SPAN
538 >, which would then match
539  either spelling.</P
540 ><P
541 > <I
542 CLASS="EMPHASIS"
543 ><TT
544 CLASS="LITERAL"
545 >/.*/advert[0-9]+\.(gif|jpe?g)</TT
546 ></I
547 > - Again 
548  another path statement with forward slashes. Anything in the square brackets 
549  <SPAN
550 CLASS="QUOTE"
551 >"[]"</SPAN
552 > can be matched. This is using <SPAN
553 CLASS="QUOTE"
554 >"0-9"</SPAN
555 > as a
556  shorthand expression to mean any digit one through nine. It is the same as
557  saying <SPAN
558 CLASS="QUOTE"
559 >"0123456789"</SPAN
560 >. So any digit matches. The <SPAN
561 CLASS="QUOTE"
562 >"+"</SPAN
563 >
564  means one or more of the preceding expression must be included. The preceding 
565  expression here is what is in the square brackets -- in this case, any digit 
566  one through nine. Then, at the end, we have a grouping: <SPAN
567 CLASS="QUOTE"
568 >"(gif|jpe?g)"</SPAN
569 >. 
570  This includes a <SPAN
571 CLASS="QUOTE"
572 >"|"</SPAN
573 >, so this needs to match the expression on
574  either side of that bar character also. A simple <SPAN
575 CLASS="QUOTE"
576 >"gif"</SPAN
577 > on one side, and the other
578  side will in turn match either <SPAN
579 CLASS="QUOTE"
580 >"jpeg"</SPAN
581 > or <SPAN
582 CLASS="QUOTE"
583 >"jpg"</SPAN
584 >,
585  since the <SPAN
586 CLASS="QUOTE"
587 >"?"</SPAN
588 > means the letter <SPAN
589 CLASS="QUOTE"
590 >"e"</SPAN
591 > is optional and
592  can be matched once or not at all. So we are building an expression here to
593  match image GIF or JPEG type image file. It must include the literal
594  string <SPAN
595 CLASS="QUOTE"
596 >"advert"</SPAN
597 >, then one or more digits, and a <SPAN
598 CLASS="QUOTE"
599 >"."</SPAN
600 >
601  (which is now a literal, and not a special character, since it is escaped
602  with <SPAN
603 CLASS="QUOTE"
604 >"\"</SPAN
605 >), and lastly either <SPAN
606 CLASS="QUOTE"
607 >"gif"</SPAN
608 >, or
609  <SPAN
610 CLASS="QUOTE"
611 >"jpeg"</SPAN
612 >, or <SPAN
613 CLASS="QUOTE"
614 >"jpg"</SPAN
615 >. Some possible matches would
616  include: <SPAN
617 CLASS="QUOTE"
618 >"//advert1.jpg"</SPAN
619 >,
620  <SPAN
621 CLASS="QUOTE"
622 >"/nasty/ads/advert1234.gif"</SPAN
623 >,
624  <SPAN
625 CLASS="QUOTE"
626 >"/banners/from/hell/advert99.jpg"</SPAN
627 >. It would not match
628  <SPAN
629 CLASS="QUOTE"
630 >"advert1.gif"</SPAN
631 > (no leading slash), or
632  <SPAN
633 CLASS="QUOTE"
634 >"/adverts232.jpg"</SPAN
635 > (the expression does not include an
636  <SPAN
637 CLASS="QUOTE"
638 >"s"</SPAN
639 >), or <SPAN
640 CLASS="QUOTE"
641 >"/advert1.jsp"</SPAN
642 > (<SPAN
643 CLASS="QUOTE"
644 >"jsp"</SPAN
645 > is not
646  in the expression anywhere).</P
647 ><P
648 > <I
649 CLASS="EMPHASIS"
650 ><TT
651 CLASS="LITERAL"
652 >s/microsoft(?!.com)/MicroSuck/i</TT
653 ></I
654 > - This is 
655  a substitution. <SPAN
656 CLASS="QUOTE"
657 >"MicroSuck"</SPAN
658 > will replace any occurrence of 
659  <SPAN
660 CLASS="QUOTE"
661 >"microsoft"</SPAN
662 >.  The <SPAN
663 CLASS="QUOTE"
664 >"i"</SPAN
665 > at the end of the expression
666  means ignore case. The <SPAN
667 CLASS="QUOTE"
668 >"(?!.com)"</SPAN
669 > means 
670  the match should fail if <SPAN
671 CLASS="QUOTE"
672 >"microsoft"</SPAN
673 > is followed by
674  <SPAN
675 CLASS="QUOTE"
676 >".com"</SPAN
677 >. In other words, this acts like a <SPAN
678 CLASS="QUOTE"
679 >"NOT"</SPAN
680 >
681  modifier. In case this is a hyperlink, we don't want to break it ;-).</P
682 ><P
683 > We are barely scratching the surface of regular expressions here so that you
684  can understand the default <SPAN
685 CLASS="APPLICATION"
686 >Privoxy</SPAN
687 >
688  configuration files, and maybe use this knowledge to customize your own
689  installation. There is much, much more that can be done with regular
690  expressions. Now that you know enough to get started, you can learn more on
691  your own :/</P
692 ><P
693 > More reading on Perl Compatible Regular expressions: 
694  <A
695 HREF="http://www.perldoc.com/perl5.6/pod/perlre.html"
696 TARGET="_top"
697 >http://www.perldoc.com/perl5.6/pod/perlre.html</A
698 ></P
699 ></DIV
700 ><DIV
701 CLASS="SECT2"
702 ><H2
703 CLASS="SECT2"
704 ><A
705 NAME="AEN1587"
706 >9.2. <SPAN
707 CLASS="APPLICATION"
708 >Privoxy</SPAN
709 >'s Internal Pages</A
710 ></H2
711 ><P
712 > Since <SPAN
713 CLASS="APPLICATION"
714 >Privoxy</SPAN
715 > proxies each requested 
716  web page, it is easy for <SPAN
717 CLASS="APPLICATION"
718 >Privoxy</SPAN
719 > to 
720  trap certain special URLs. In this way, we can talk directly to
721  <SPAN
722 CLASS="APPLICATION"
723 >Privoxy</SPAN
724 >, and see how it is 
725  configured, see how our rules are being applied, change these 
726  rules and other configuration options, and even turn
727  <SPAN
728 CLASS="APPLICATION"
729 >Privoxy's</SPAN
730 > filtering off, all with 
731  a web browser.&#13;</P
732 ><P
733 > The URLs listed below are the special ones that allow direct access 
734  to <SPAN
735 CLASS="APPLICATION"
736 >Privoxy</SPAN
737 >. Of course,
738  <SPAN
739 CLASS="APPLICATION"
740 >Privoxy</SPAN
741 > must be running to access these. If 
742  not, you will get a friendly error message. Internet access is not 
743  necessary either.</P
744 ><P
745 > <P
746 ></P
747 ><UL
748 ><LI
749 ><P
750 >  
751    Privoxy main page: 
752   </P
753 ><A
754 NAME="AEN1602"
755 ></A
756 ><BLOCKQUOTE
757 CLASS="BLOCKQUOTE"
758 ><P
759
760      <A
761 HREF="http://config.privoxy.org/"
762 TARGET="_top"
763 >http://config.privoxy.org/</A
764 >
765    </P
766 ></BLOCKQUOTE
767 ><P
768 >   Alternately, this may be reached at <A
769 HREF="http://p.p/"
770 TARGET="_top"
771 >http://p.p/</A
772 >, but this
773    variation may not work as reliably as the above in some configurations.
774   </P
775 ></LI
776 ><LI
777 ><P
778 >  
779     Show information about the current configuration: 
780   </P
781 ><A
782 NAME="AEN1609"
783 ></A
784 ><BLOCKQUOTE
785 CLASS="BLOCKQUOTE"
786 ><P
787
788     <A
789 HREF="http://config.privoxy.org/show-status"
790 TARGET="_top"
791 >http://config.privoxy.org/show-status</A
792 >
793    </P
794 ></BLOCKQUOTE
795 ></LI
796 ><LI
797 ><P
798 >  
799     Show the source code version numbers:
800   </P
801 ><A
802 NAME="AEN1614"
803 ></A
804 ><BLOCKQUOTE
805 CLASS="BLOCKQUOTE"
806 ><P
807
808     <A
809 HREF="http://config.privoxy.org/show-version"
810 TARGET="_top"
811 >http://config.privoxy.org/show-version</A
812 >
813    </P
814 ></BLOCKQUOTE
815 ></LI
816 ><LI
817 ><P
818 >  
819    Show the client's request headers:
820   </P
821 ><A
822 NAME="AEN1619"
823 ></A
824 ><BLOCKQUOTE
825 CLASS="BLOCKQUOTE"
826 ><P
827
828     <A
829 HREF="http://config.privoxy.org/show-request"
830 TARGET="_top"
831 >http://config.privoxy.org/show-request</A
832 >
833    </P
834 ></BLOCKQUOTE
835 ></LI
836 ><LI
837 ><P
838 >  
839    Show which actions apply to a URL and why:
840   </P
841 ><A
842 NAME="AEN1624"
843 ></A
844 ><BLOCKQUOTE
845 CLASS="BLOCKQUOTE"
846 ><P
847
848     <A
849 HREF="http://config.privoxy.org/show-url-info"
850 TARGET="_top"
851 >http://config.privoxy.org/show-url-info</A
852 >
853    </P
854 ></BLOCKQUOTE
855 ></LI
856 ><LI
857 ><P
858 >  
859    Toggle Privoxy on or off. In this case, <SPAN
860 CLASS="QUOTE"
861 >"Privoxy"</SPAN
862 > continues 
863    to run, but only as a pass-through proxy, with no actions taking place:
864   </P
865 ><A
866 NAME="AEN1630"
867 ></A
868 ><BLOCKQUOTE
869 CLASS="BLOCKQUOTE"
870 ><P
871
872     <A
873 HREF="http://config.privoxy.org/toggle"
874 TARGET="_top"
875 >http://config.privoxy.org/toggle</A
876 >
877    </P
878 ></BLOCKQUOTE
879 ><P
880 >   Short cuts. Turn off, then on: 
881   </P
882 ><A
883 NAME="AEN1634"
884 ></A
885 ><BLOCKQUOTE
886 CLASS="BLOCKQUOTE"
887 ><P
888
889      <A
890 HREF="http://config.privoxy.org/toggle?set=disable"
891 TARGET="_top"
892 >http://config.privoxy.org/toggle?set=disable</A
893 >
894    </P
895 ></BLOCKQUOTE
896 ><A
897 NAME="AEN1637"
898 ></A
899 ><BLOCKQUOTE
900 CLASS="BLOCKQUOTE"
901 ><P
902
903      <A
904 HREF="http://config.privoxy.org/toggle?set=enable"
905 TARGET="_top"
906 >http://config.privoxy.org/toggle?set=enable</A
907 >
908    </P
909 ></BLOCKQUOTE
910 ></LI
911 ><LI
912 ><P
913 >  
914    Edit the actions list file:
915   </P
916 ><A
917 NAME="AEN1642"
918 ></A
919 ><BLOCKQUOTE
920 CLASS="BLOCKQUOTE"
921 ><P
922
923     <A
924 HREF="http://config.privoxy.org/edit-actions"
925 TARGET="_top"
926 >http://config.privoxy.org/edit-actions</A
927 >
928    </P
929 ></BLOCKQUOTE
930 ></LI
931 ></UL
932 ></P
933 ><P
934 > These may be bookmarked for quick reference.&#13;</P
935 ><DIV
936 CLASS="SECT3"
937 ><H3
938 CLASS="SECT3"
939 ><A
940 NAME="BOOKMARKLETS"
941 >9.2.1. Bookmarklets</A
942 ></H3
943 ><P
944 > Here are some bookmarklets to allow you to easily access a
945  <SPAN
946 CLASS="QUOTE"
947 >"mini"</SPAN
948 > version of this page. They are designed for MS Internet
949  Explorer, but should work equally well in Netscape, Mozilla, and other
950  browsers which support JavaScript. They are designed to run directly from
951  your bookmarks - not by clicking the links below (although that will work for
952  testing).</P
953 ><P
954 > To save them, right-click the link and choose <SPAN
955 CLASS="QUOTE"
956 >"Add to Favorites"</SPAN
957 >
958  (IE) or <SPAN
959 CLASS="QUOTE"
960 >"Add Bookmark"</SPAN
961 > (Netscape). You will get a warning that
962  the bookmark <SPAN
963 CLASS="QUOTE"
964 >"may not be safe"</SPAN
965 > - just click OK. Then you can run the
966  Bookmarklet directly from your favourites/bookmarks. For even faster access,
967  you can put them on the <SPAN
968 CLASS="QUOTE"
969 >"Links"</SPAN
970 > bar (IE) or the <SPAN
971 CLASS="QUOTE"
972 >"Personal
973  Toolbar"</SPAN
974 > (Netscape), and run them with a single click. </P
975 ><P
976 > <P
977 ></P
978 ><UL
979 ><LI
980 ><P
981 >    <A
982 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=enabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
983 TARGET="_top"
984 >Enable Privoxy</A
985 >
986    </P
987 ></LI
988 ><LI
989 ><P
990 >    <A
991 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=disabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
992 TARGET="_top"
993 >Disable Privoxy</A
994 >
995    </P
996 ></LI
997 ><LI
998 ><P
999 >    <A
1000 HREF="javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=toggle','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1001 TARGET="_top"
1002 >Toggle Privoxy</A
1003 > (Toggles between enabled and disabled)
1004    </P
1005 ></LI
1006 ><LI
1007 ><P
1008 >    <A
1009 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());"
1010 TARGET="_top"
1011 >View Privoxy Status</A
1012 >
1013    </P
1014 ></LI
1015 ></UL
1016 ></P
1017 ><P
1018 > Credit: The site which gave me the general idea for these bookmarklets is
1019  <A
1020 HREF="http://www.bookmarklets.com"
1021 TARGET="_top"
1022 >www.bookmarklets.com</A
1023 >. They
1024  have more information about bookmarklets. </P
1025 ></DIV
1026 ></DIV
1027 ><DIV
1028 CLASS="SECT2"
1029 ><H2
1030 CLASS="SECT2"
1031 ><A
1032 NAME="ACTIONSANAT"
1033 >9.3. Anatomy of an Action</A
1034 ></H2
1035 ><P
1036 > The way <SPAN
1037 CLASS="APPLICATION"
1038 >Privoxy</SPAN
1039 > applies <SPAN
1040 CLASS="QUOTE"
1041 >"actions"</SPAN
1042 >
1043  and <SPAN
1044 CLASS="QUOTE"
1045 >"filters"</SPAN
1046 > to any given URL can be complex, and not always so
1047  easy to understand what is happening. And sometimes we need to be able to
1048  <I
1049 CLASS="EMPHASIS"
1050 >see</I
1051 > just what <SPAN
1052 CLASS="APPLICATION"
1053 >Privoxy</SPAN
1054 > is
1055  doing. Especially, if something <SPAN
1056 CLASS="APPLICATION"
1057 >Privoxy</SPAN
1058 > is doing
1059  is causing us a problem inadvertantly. It can be a little daunting to look at
1060  the actions and filters files themselves, since they tend to be filled with
1061  <SPAN
1062 CLASS="QUOTE"
1063 >"regular expressions"</SPAN
1064 > whose consequences are not always 
1065  so obvious. <SPAN
1066 CLASS="APPLICATION"
1067 >Privoxy</SPAN
1068 > provides the 
1069  <A
1070 HREF="http://config.privoxy.org/show-url-info"
1071 TARGET="_top"
1072 >http://config.privoxy.org/show-url-info</A
1073 >
1074  page that can show us very specifically how <SPAN
1075 CLASS="APPLICATION"
1076 >actions</SPAN
1077 >
1078  are being applied to any given URL. This is a big help for troubleshooting.
1079  </P
1080 ><P
1081 > First, enter one URL (or partial URL) at the prompt, and then
1082  <SPAN
1083 CLASS="APPLICATION"
1084 >Privoxy</SPAN
1085 > will tell us 
1086  how the current configuration will handle it. This will not
1087  help with filtering effects from the <TT
1088 CLASS="FILENAME"
1089 >default.filter</TT
1090 > file! It
1091  also will not tell you about any other URLs that may be embedded within the
1092  URL you are testing. For instance, images such as ads are expressed as URLs
1093  within the raw page source of HTML pages. So you will only get info for the
1094  actual URL that is pasted into the prompt area -- not any sub-URLs. If you
1095  want to know about embedded URLs like ads, you will have to dig those out of
1096  the HTML source. Use your browser's <SPAN
1097 CLASS="QUOTE"
1098 >"View Page Source"</SPAN
1099 > option
1100  for this. Or right click on the ad, and grab the URL.</P
1101 ><P
1102 > Let's look at an example, <A
1103 HREF="http://google.com"
1104 TARGET="_top"
1105 >google.com</A
1106 >, 
1107  one section at a time:</P
1108 ><P
1109 > <TABLE
1110 BORDER="0"
1111 BGCOLOR="#E0E0E0"
1112 WIDTH="100%"
1113 ><TR
1114 ><TD
1115 ><PRE
1116 CLASS="SCREEN"
1117 > System default actions:
1118
1119  { -add-header -block -deanimate-gifs -downgrade -fast-redirects -filter 
1120    -hide-forwarded -hide-from -hide-referer -hide-user-agent -image 
1121    -image-blocker -limit-connect -no-compression -no-cookies-keep 
1122    -no-cookies-read -no-cookies-set -no-popups -vanilla-wafer -wafer }
1123  
1124  </PRE
1125 ></TD
1126 ></TR
1127 ></TABLE
1128 ></P
1129 ><P
1130 > This is the top section, and only tells us of the compiled in defaults. This 
1131  is basically what <SPAN
1132 CLASS="APPLICATION"
1133 >Privoxy</SPAN
1134 > would do if there 
1135  were not any <SPAN
1136 CLASS="QUOTE"
1137 >"actions"</SPAN
1138 > defined, i.e. it does nothing. Every action 
1139  is disabled. This is not particularly informative for our purposes here. OK,
1140  next section:</P
1141 ><P
1142 > <TABLE
1143 BORDER="0"
1144 BGCOLOR="#E0E0E0"
1145 WIDTH="100%"
1146 ><TR
1147 ><TD
1148 ><PRE
1149 CLASS="SCREEN"
1150 >&#13; Matches for http://google.com:
1151
1152  { -add-header -block +deanimate-gifs -downgrade +fast-redirects 
1153    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1154    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1155    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1156    -hide-user-agent -image +image-blocker{blank} +no-compression 
1157    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups 
1158    -vanilla-wafer -wafer }
1159    /
1160
1161  { -no-cookies-keep -no-cookies-read -no-cookies-set }
1162   .google.com
1163
1164  { -fast-redirects }
1165   .google.com
1166
1167  </PRE
1168 ></TD
1169 ></TR
1170 ></TABLE
1171 ></P
1172 ><P
1173 > This is much more informative, and tells us how we have defined our 
1174  <SPAN
1175 CLASS="QUOTE"
1176 >"actions"</SPAN
1177 >, and which ones match for our example, 
1178  <SPAN
1179 CLASS="QUOTE"
1180 >"google.com"</SPAN
1181 >. The first grouping shows our default 
1182  settings, which would apply to all URLs. If you look at your <SPAN
1183 CLASS="QUOTE"
1184 >"actions"</SPAN
1185 >
1186  file, this would be the section just below the <SPAN
1187 CLASS="QUOTE"
1188 >"aliases"</SPAN
1189 > section 
1190  near the top. This applies to all URLs as signified by the single forward
1191  slash -- <SPAN
1192 CLASS="QUOTE"
1193 >"/"</SPAN
1194 >.
1195  </P
1196 ><P
1197 > These are the default actions we have enabled. But we can define additional
1198  actions that would be exceptions to these general rules, and then list 
1199  specific URLs that these exceptions would apply to. Last match wins.
1200  Just below this then are two explict matches for <SPAN
1201 CLASS="QUOTE"
1202 >".google.com"</SPAN
1203 >.
1204  The first is negating our various cookie blocking actions (i.e. we will allow
1205  cookies here). The second is allowing <SPAN
1206 CLASS="QUOTE"
1207 >"fast-redirects"</SPAN
1208 >. Note
1209  that there is a leading dot here -- <SPAN
1210 CLASS="QUOTE"
1211 >".google.com"</SPAN
1212 >. This will
1213  match any hosts and sub-domains, in the google.com domain also, such as
1214  <SPAN
1215 CLASS="QUOTE"
1216 >"www.google.com"</SPAN
1217 >. So, apparently, we have these actions defined
1218  somewhere in the lower part of our actions file, and
1219  <SPAN
1220 CLASS="QUOTE"
1221 >"google.com"</SPAN
1222 > is referenced in these sections.&#13;</P
1223 ><P
1224 > And now we pull it altogether in the bottom section and summarize how
1225  <SPAN
1226 CLASS="APPLICATION"
1227 >Privoxy</SPAN
1228 > is appying all its <SPAN
1229 CLASS="QUOTE"
1230 >"actions"</SPAN
1231
1232  to <SPAN
1233 CLASS="QUOTE"
1234 >"google.com"</SPAN
1235 >:&#13;</P
1236 ><P
1237 > <TABLE
1238 BORDER="0"
1239 BGCOLOR="#E0E0E0"
1240 WIDTH="100%"
1241 ><TR
1242 ><TD
1243 ><PRE
1244 CLASS="SCREEN"
1245 >&#13; Final results:
1246
1247  -add-header -block -deanimate-gifs -downgrade -fast-redirects 
1248  +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1249  +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1250  +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1251  -hide-user-agent -image +image-blocker{blank} -limit-connect +no-compression 
1252  -no-cookies-keep -no-cookies-read -no-cookies-set +no-popups -vanilla-wafer 
1253  -wafer
1254
1255  </PRE
1256 ></TD
1257 ></TR
1258 ></TABLE
1259 ></P
1260 ><P
1261 > Now another example, <SPAN
1262 CLASS="QUOTE"
1263 >"ad.doubleclick.net"</SPAN
1264 >:</P
1265 ><P
1266 > <TABLE
1267 BORDER="0"
1268 BGCOLOR="#E0E0E0"
1269 WIDTH="100%"
1270 ><TR
1271 ><TD
1272 ><PRE
1273 CLASS="SCREEN"
1274 >&#13; { +block +image }
1275   .ad.doubleclick.net
1276
1277  { +block +image }
1278   ad*.
1279
1280  { +block +image }
1281   .doubleclick.net
1282
1283  </PRE
1284 ></TD
1285 ></TR
1286 ></TABLE
1287 ></P
1288 ><P
1289 > We'll just show the interesting part here, the explicit matches. It is 
1290  matched three different times. Each as an <SPAN
1291 CLASS="QUOTE"
1292 >"+block +image"</SPAN
1293 >,
1294  which is the expanded form of one of our aliases that had been defined as: 
1295  <SPAN
1296 CLASS="QUOTE"
1297 >"+imageblock"</SPAN
1298 >. (<SPAN
1299 CLASS="QUOTE"
1300 >"Aliases"</SPAN
1301 > are defined in the 
1302  first section of the actions file and typically used to combine more 
1303  than one action.)</P
1304 ><P
1305 > Any one of these would have done the trick and blocked this as an unwanted 
1306  image. This is unnecessarily redundant since the last case effectively 
1307  would also cover the first. No point in taking chances with these guys 
1308  though ;-) Note that if you want an ad or obnoxious 
1309  URL to be invisible, it should be defined as <SPAN
1310 CLASS="QUOTE"
1311 >"ad.doubleclick.net"</SPAN
1312 >
1313  is done here -- as both a <SPAN
1314 CLASS="QUOTE"
1315 >"+block"</SPAN
1316 > <I
1317 CLASS="EMPHASIS"
1318 >and</I
1319 > an
1320  <SPAN
1321 CLASS="QUOTE"
1322 >"+image"</SPAN
1323 >. The custom alias <SPAN
1324 CLASS="QUOTE"
1325 >"+imageblock"</SPAN
1326 > does this
1327  for us.</P
1328 ><P
1329 > One last example. Let's try <SPAN
1330 CLASS="QUOTE"
1331 >"http://www.rhapsodyk.net/adsl/HOWTO/"</SPAN
1332 >.
1333  This one is giving us problems. We are getting a blank page. Hmmm...</P
1334 ><P
1335 > <TABLE
1336 BORDER="0"
1337 BGCOLOR="#E0E0E0"
1338 WIDTH="100%"
1339 ><TR
1340 ><TD
1341 ><PRE
1342 CLASS="SCREEN"
1343 >&#13; Matches for http://www.rhapsodyk.net/adsl/HOWTO/:
1344
1345  { -add-header -block +deanimate-gifs -downgrade +fast-redirects 
1346    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1347    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1348    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1349    -hide-user-agent -image +image-blocker{blank} +no-compression 
1350    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups 
1351    -vanilla-wafer -wafer }
1352    /
1353
1354  { +block +image }
1355   /ads
1356
1357  </PRE
1358 ></TD
1359 ></TR
1360 ></TABLE
1361 ></P
1362 ><P
1363 > Ooops, the <SPAN
1364 CLASS="QUOTE"
1365 >"/adsl/"</SPAN
1366 > is matching <SPAN
1367 CLASS="QUOTE"
1368 >"/ads"</SPAN
1369 >! But 
1370  we did not want this at all! Now we see why we get the blank page. We could
1371  now add a new action below this that explictly does <I
1372 CLASS="EMPHASIS"
1373 >not</I
1374 >
1375  block (-block) pages with <SPAN
1376 CLASS="QUOTE"
1377 >"adsl"</SPAN
1378 >. There are various ways to
1379  handle such exceptions. Example:</P
1380 ><P
1381 > <TABLE
1382 BORDER="0"
1383 BGCOLOR="#E0E0E0"
1384 WIDTH="100%"
1385 ><TR
1386 ><TD
1387 ><PRE
1388 CLASS="SCREEN"
1389 >&#13; { -block }
1390   /adsl
1391  
1392  </PRE
1393 ></TD
1394 ></TR
1395 ></TABLE
1396 ></P
1397 ><P
1398 > Now the page displays ;-) Be sure to flush your browser's caches when 
1399  making such changes. Or, try using <TT
1400 CLASS="LITERAL"
1401 >Shift+Reload</TT
1402 >.</P
1403 ><P
1404 > But now what about a situation where we get no explicit matches like 
1405  we did with:</P
1406 ><P
1407 > <TABLE
1408 BORDER="0"
1409 BGCOLOR="#E0E0E0"
1410 WIDTH="100%"
1411 ><TR
1412 ><TD
1413 ><PRE
1414 CLASS="SCREEN"
1415 >&#13; { -block }
1416   /adsl
1417  
1418  </PRE
1419 ></TD
1420 ></TR
1421 ></TABLE
1422 ></P
1423 ><P
1424 > That actually was very telling and pointed us quickly to where the problem
1425  was. If you don't get this kind of match, then it means one of the default 
1426  rules in the first section is causing the problem. This would require some 
1427  guesswork, and maybe a little trial and error to isolate the offending rule.
1428  One likely cause would be one of the <SPAN
1429 CLASS="QUOTE"
1430 >"{+filter}"</SPAN
1431 > actions. Try 
1432  adding the URL for the site to one of aliases that turn off <SPAN
1433 CLASS="QUOTE"
1434 >"+filter"</SPAN
1435 >:</P
1436 ><P
1437 > <TABLE
1438 BORDER="0"
1439 BGCOLOR="#E0E0E0"
1440 WIDTH="100%"
1441 ><TR
1442 ><TD
1443 ><PRE
1444 CLASS="SCREEN"
1445 >&#13; {shop}
1446  .quietpc.com
1447  .worldpay.com   # for quietpc.com
1448  .jungle.com
1449  .scan.co.uk
1450  .forbes.com
1451  
1452  </PRE
1453 ></TD
1454 ></TR
1455 ></TABLE
1456 ></P
1457 ><P
1458 > <SPAN
1459 CLASS="QUOTE"
1460 >"{shop}"</SPAN
1461 > is an <SPAN
1462 CLASS="QUOTE"
1463 >"alias"</SPAN
1464 > that expands to 
1465  <SPAN
1466 CLASS="QUOTE"
1467 >"{ -filter -no-cookies -no-cookies-keep }"</SPAN
1468 >. Or you could do 
1469  your own exception to negate filtering:&#13;</P
1470 ><P
1471 > <TABLE
1472 BORDER="0"
1473 BGCOLOR="#E0E0E0"
1474 WIDTH="100%"
1475 ><TR
1476 ><TD
1477 ><PRE
1478 CLASS="SCREEN"
1479 >&#13; {-filter}
1480  .forbes.com
1481  
1482  </PRE
1483 ></TD
1484 ></TR
1485 ></TABLE
1486 ></P
1487 ><P
1488 > <SPAN
1489 CLASS="QUOTE"
1490 >"{fragile}"</SPAN
1491 > is an alias that disables most actions. This can be 
1492  used as a last resort for problem sites. Remember to flush caches! If this 
1493  still does not work, you will have to go through the remaining actions one by
1494  one to find which one(s) is causing the problem.</P
1495 ></DIV
1496 ></DIV
1497 ><DIV
1498 CLASS="NAVFOOTER"
1499 ><HR
1500 ALIGN="LEFT"
1501 WIDTH="100%"><TABLE
1502 WIDTH="100%"
1503 BORDER="0"
1504 CELLPADDING="0"
1505 CELLSPACING="0"
1506 ><TR
1507 ><TD
1508 WIDTH="33%"
1509 ALIGN="left"
1510 VALIGN="top"
1511 ><A
1512 HREF="seealso.html"
1513 >Prev</A
1514 ></TD
1515 ><TD
1516 WIDTH="34%"
1517 ALIGN="center"
1518 VALIGN="top"
1519 ><A
1520 HREF="index.html"
1521 >Home</A
1522 ></TD
1523 ><TD
1524 WIDTH="33%"
1525 ALIGN="right"
1526 VALIGN="top"
1527 >&nbsp;</TD
1528 ></TR
1529 ><TR
1530 ><TD
1531 WIDTH="33%"
1532 ALIGN="left"
1533 VALIGN="top"
1534 >See Also</TD
1535 ><TD
1536 WIDTH="34%"
1537 ALIGN="center"
1538 VALIGN="top"
1539 >&nbsp;</TD
1540 ><TD
1541 WIDTH="33%"
1542 ALIGN="right"
1543 VALIGN="top"
1544 >&nbsp;</TD
1545 ></TR
1546 ></TABLE
1547 ></DIV
1548 ></BODY
1549 ></HTML
1550 >