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