Update for submitting actions.
[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="AEN1613"
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="AEN1628"
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="AEN1635"
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="AEN1640"
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="AEN1645"
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="AEN1650"
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="AEN1656"
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="AEN1660"
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="AEN1663"
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="AEN1668"
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 > Below are some <SPAN
945 CLASS="QUOTE"
946 >"bookmarklets"</SPAN
947 > to allow you to easily access a
948  <SPAN
949 CLASS="QUOTE"
950 >"mini"</SPAN
951 > version of some of <SPAN
952 CLASS="APPLICATION"
953 >Privoxy's</SPAN
954 >
955  special pages. They are designed for MS Internet Explorer, but should work
956  equally well in Netscape, Mozilla, and other browsers which support
957  JavaScript. They are designed to run directly from your bookmarks - not by
958  clicking the links below (although that should work for testing).</P
959 ><P
960 > To save them, right-click the link and choose <SPAN
961 CLASS="QUOTE"
962 >"Add to Favorites"</SPAN
963 >
964  (IE) or <SPAN
965 CLASS="QUOTE"
966 >"Add Bookmark"</SPAN
967 > (Netscape). You will get a warning that
968  the bookmark <SPAN
969 CLASS="QUOTE"
970 >"may not be safe"</SPAN
971 > - just click OK. Then you can run the
972  Bookmarklet directly from your favourites/bookmarks. For even faster access,
973  you can put them on the <SPAN
974 CLASS="QUOTE"
975 >"Links"</SPAN
976 > bar (IE) or the <SPAN
977 CLASS="QUOTE"
978 >"Personal
979  Toolbar"</SPAN
980 > (Netscape), and run them with a single click. </P
981 ><P
982 > <P
983 ></P
984 ><UL
985 ><LI
986 ><P
987 >    <A
988 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());"
989 TARGET="_top"
990 >Enable Privoxy</A
991 >
992    </P
993 ></LI
994 ><LI
995 ><P
996 >    <A
997 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());"
998 TARGET="_top"
999 >Disable Privoxy</A
1000 >
1001    </P
1002 ></LI
1003 ><LI
1004 ><P
1005 >    <A
1006 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());"
1007 TARGET="_top"
1008 >Toggle Privoxy</A
1009 > (Toggles between enabled and disabled)
1010    </P
1011 ></LI
1012 ><LI
1013 ><P
1014 >    <A
1015 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());"
1016 TARGET="_top"
1017 >View Privoxy Status</A
1018 >
1019    </P
1020 ></LI
1021 ><LI
1022 ><P
1023 >    <A
1024 HREF="javascript:w=Math.floor(screen.width/2);h=Math.floor(screen.height*0.9);void(window.open('http://www.privoxy.org/actions','Feedback','screenx='+w+',width='+w+',height='+h+',scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
1025 TARGET="_top"
1026 >Actions file feedback system</A
1027 >
1028    </P
1029 ></LI
1030 ></UL
1031 ></P
1032 ><P
1033 > Credit: The site which gave me the general idea for these bookmarklets is
1034  <A
1035 HREF="http://www.bookmarklets.com"
1036 TARGET="_top"
1037 >www.bookmarklets.com</A
1038 >. They
1039  have more information about bookmarklets. </P
1040 ></DIV
1041 ></DIV
1042 ><DIV
1043 CLASS="SECT2"
1044 ><H2
1045 CLASS="SECT2"
1046 ><A
1047 NAME="ACTIONSANAT"
1048 >9.3. Anatomy of an Action</A
1049 ></H2
1050 ><P
1051 > The way <SPAN
1052 CLASS="APPLICATION"
1053 >Privoxy</SPAN
1054 > applies <SPAN
1055 CLASS="QUOTE"
1056 >"actions"</SPAN
1057 >
1058  and <SPAN
1059 CLASS="QUOTE"
1060 >"filters"</SPAN
1061 > to any given URL can be complex, and not always so
1062  easy to understand what is happening. And sometimes we need to be able to
1063  <I
1064 CLASS="EMPHASIS"
1065 >see</I
1066 > just what <SPAN
1067 CLASS="APPLICATION"
1068 >Privoxy</SPAN
1069 > is
1070  doing. Especially, if something <SPAN
1071 CLASS="APPLICATION"
1072 >Privoxy</SPAN
1073 > is doing
1074  is causing us a problem inadvertantly. It can be a little daunting to look at
1075  the actions and filters files themselves, since they tend to be filled with
1076  <SPAN
1077 CLASS="QUOTE"
1078 >"regular expressions"</SPAN
1079 > whose consequences are not always 
1080  so obvious. <SPAN
1081 CLASS="APPLICATION"
1082 >Privoxy</SPAN
1083 > provides the 
1084  <A
1085 HREF="http://config.privoxy.org/show-url-info"
1086 TARGET="_top"
1087 >http://config.privoxy.org/show-url-info</A
1088 >
1089  page that can show us very specifically how <SPAN
1090 CLASS="APPLICATION"
1091 >actions</SPAN
1092 >
1093  are being applied to any given URL. This is a big help for troubleshooting.
1094  </P
1095 ><P
1096 > First, enter one URL (or partial URL) at the prompt, and then
1097  <SPAN
1098 CLASS="APPLICATION"
1099 >Privoxy</SPAN
1100 > will tell us 
1101  how the current configuration will handle it. This will not
1102  help with filtering effects from the <TT
1103 CLASS="FILENAME"
1104 >default.filter</TT
1105 > file! It
1106  also will not tell you about any other URLs that may be embedded within the
1107  URL you are testing. For instance, images such as ads are expressed as URLs
1108  within the raw page source of HTML pages. So you will only get info for the
1109  actual URL that is pasted into the prompt area -- not any sub-URLs. If you
1110  want to know about embedded URLs like ads, you will have to dig those out of
1111  the HTML source. Use your browser's <SPAN
1112 CLASS="QUOTE"
1113 >"View Page Source"</SPAN
1114 > option
1115  for this. Or right click on the ad, and grab the URL.</P
1116 ><P
1117 > Let's look at an example, <A
1118 HREF="http://google.com"
1119 TARGET="_top"
1120 >google.com</A
1121 >, 
1122  one section at a time:</P
1123 ><P
1124 > <TABLE
1125 BORDER="0"
1126 BGCOLOR="#E0E0E0"
1127 WIDTH="100%"
1128 ><TR
1129 ><TD
1130 ><PRE
1131 CLASS="SCREEN"
1132 > System default actions:
1133
1134  { -add-header -block -deanimate-gifs -downgrade -fast-redirects -filter 
1135    -hide-forwarded -hide-from -hide-referer -hide-user-agent -image 
1136    -image-blocker -limit-connect -no-compression -no-cookies-keep 
1137    -no-cookies-read -no-cookies-set -no-popups -vanilla-wafer -wafer }
1138  
1139  </PRE
1140 ></TD
1141 ></TR
1142 ></TABLE
1143 ></P
1144 ><P
1145 > This is the top section, and only tells us of the compiled in defaults. This 
1146  is basically what <SPAN
1147 CLASS="APPLICATION"
1148 >Privoxy</SPAN
1149 > would do if there 
1150  were not any <SPAN
1151 CLASS="QUOTE"
1152 >"actions"</SPAN
1153 > defined, i.e. it does nothing. Every action 
1154  is disabled. This is not particularly informative for our purposes here. OK,
1155  next section:</P
1156 ><P
1157 > <TABLE
1158 BORDER="0"
1159 BGCOLOR="#E0E0E0"
1160 WIDTH="100%"
1161 ><TR
1162 ><TD
1163 ><PRE
1164 CLASS="SCREEN"
1165 >&#13; Matches for http://google.com:
1166
1167  { -add-header -block +deanimate-gifs -downgrade +fast-redirects 
1168    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1169    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1170    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1171    -hide-user-agent -image +image-blocker{blank} +no-compression 
1172    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups 
1173    -vanilla-wafer -wafer }
1174    /
1175
1176  { -no-cookies-keep -no-cookies-read -no-cookies-set }
1177   .google.com
1178
1179  { -fast-redirects }
1180   .google.com
1181
1182  </PRE
1183 ></TD
1184 ></TR
1185 ></TABLE
1186 ></P
1187 ><P
1188 > This is much more informative, and tells us how we have defined our 
1189  <SPAN
1190 CLASS="QUOTE"
1191 >"actions"</SPAN
1192 >, and which ones match for our example, 
1193  <SPAN
1194 CLASS="QUOTE"
1195 >"google.com"</SPAN
1196 >. The first grouping shows our default 
1197  settings, which would apply to all URLs. If you look at your <SPAN
1198 CLASS="QUOTE"
1199 >"actions"</SPAN
1200 >
1201  file, this would be the section just below the <SPAN
1202 CLASS="QUOTE"
1203 >"aliases"</SPAN
1204 > section 
1205  near the top. This applies to all URLs as signified by the single forward
1206  slash -- <SPAN
1207 CLASS="QUOTE"
1208 >"/"</SPAN
1209 >.
1210  </P
1211 ><P
1212 > These are the default actions we have enabled. But we can define additional
1213  actions that would be exceptions to these general rules, and then list 
1214  specific URLs that these exceptions would apply to. Last match wins.
1215  Just below this then are two explict matches for <SPAN
1216 CLASS="QUOTE"
1217 >".google.com"</SPAN
1218 >.
1219  The first is negating our various cookie blocking actions (i.e. we will allow
1220  cookies here). The second is allowing <SPAN
1221 CLASS="QUOTE"
1222 >"fast-redirects"</SPAN
1223 >. Note
1224  that there is a leading dot here -- <SPAN
1225 CLASS="QUOTE"
1226 >".google.com"</SPAN
1227 >. This will
1228  match any hosts and sub-domains, in the google.com domain also, such as
1229  <SPAN
1230 CLASS="QUOTE"
1231 >"www.google.com"</SPAN
1232 >. So, apparently, we have these actions defined
1233  somewhere in the lower part of our actions file, and
1234  <SPAN
1235 CLASS="QUOTE"
1236 >"google.com"</SPAN
1237 > is referenced in these sections.&#13;</P
1238 ><P
1239 > And now we pull it altogether in the bottom section and summarize how
1240  <SPAN
1241 CLASS="APPLICATION"
1242 >Privoxy</SPAN
1243 > is appying all its <SPAN
1244 CLASS="QUOTE"
1245 >"actions"</SPAN
1246
1247  to <SPAN
1248 CLASS="QUOTE"
1249 >"google.com"</SPAN
1250 >:&#13;</P
1251 ><P
1252 > <TABLE
1253 BORDER="0"
1254 BGCOLOR="#E0E0E0"
1255 WIDTH="100%"
1256 ><TR
1257 ><TD
1258 ><PRE
1259 CLASS="SCREEN"
1260 >&#13; Final results:
1261
1262  -add-header -block -deanimate-gifs -downgrade -fast-redirects 
1263  +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1264  +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1265  +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1266  -hide-user-agent -image +image-blocker{blank} -limit-connect +no-compression 
1267  -no-cookies-keep -no-cookies-read -no-cookies-set +no-popups -vanilla-wafer 
1268  -wafer
1269
1270  </PRE
1271 ></TD
1272 ></TR
1273 ></TABLE
1274 ></P
1275 ><P
1276 > Now another example, <SPAN
1277 CLASS="QUOTE"
1278 >"ad.doubleclick.net"</SPAN
1279 >:</P
1280 ><P
1281 > <TABLE
1282 BORDER="0"
1283 BGCOLOR="#E0E0E0"
1284 WIDTH="100%"
1285 ><TR
1286 ><TD
1287 ><PRE
1288 CLASS="SCREEN"
1289 >&#13; { +block +image }
1290   .ad.doubleclick.net
1291
1292  { +block +image }
1293   ad*.
1294
1295  { +block +image }
1296   .doubleclick.net
1297
1298  </PRE
1299 ></TD
1300 ></TR
1301 ></TABLE
1302 ></P
1303 ><P
1304 > We'll just show the interesting part here, the explicit matches. It is 
1305  matched three different times. Each as an <SPAN
1306 CLASS="QUOTE"
1307 >"+block +image"</SPAN
1308 >,
1309  which is the expanded form of one of our aliases that had been defined as: 
1310  <SPAN
1311 CLASS="QUOTE"
1312 >"+imageblock"</SPAN
1313 >. (<SPAN
1314 CLASS="QUOTE"
1315 >"Aliases"</SPAN
1316 > are defined in the 
1317  first section of the actions file and typically used to combine more 
1318  than one action.)</P
1319 ><P
1320 > Any one of these would have done the trick and blocked this as an unwanted 
1321  image. This is unnecessarily redundant since the last case effectively 
1322  would also cover the first. No point in taking chances with these guys 
1323  though ;-) Note that if you want an ad or obnoxious 
1324  URL to be invisible, it should be defined as <SPAN
1325 CLASS="QUOTE"
1326 >"ad.doubleclick.net"</SPAN
1327 >
1328  is done here -- as both a <SPAN
1329 CLASS="QUOTE"
1330 >"+block"</SPAN
1331 > <I
1332 CLASS="EMPHASIS"
1333 >and</I
1334 > an
1335  <SPAN
1336 CLASS="QUOTE"
1337 >"+image"</SPAN
1338 >. The custom alias <SPAN
1339 CLASS="QUOTE"
1340 >"+imageblock"</SPAN
1341 > does this
1342  for us.</P
1343 ><P
1344 > One last example. Let's try <SPAN
1345 CLASS="QUOTE"
1346 >"http://www.rhapsodyk.net/adsl/HOWTO/"</SPAN
1347 >.
1348  This one is giving us problems. We are getting a blank page. Hmmm...</P
1349 ><P
1350 > <TABLE
1351 BORDER="0"
1352 BGCOLOR="#E0E0E0"
1353 WIDTH="100%"
1354 ><TR
1355 ><TD
1356 ><PRE
1357 CLASS="SCREEN"
1358 >&#13; Matches for http://www.rhapsodyk.net/adsl/HOWTO/:
1359
1360  { -add-header -block +deanimate-gifs -downgrade +fast-redirects 
1361    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups} 
1362    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal} 
1363    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge} 
1364    -hide-user-agent -image +image-blocker{blank} +no-compression 
1365    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups 
1366    -vanilla-wafer -wafer }
1367    /
1368
1369  { +block +image }
1370   /ads
1371
1372  </PRE
1373 ></TD
1374 ></TR
1375 ></TABLE
1376 ></P
1377 ><P
1378 > Ooops, the <SPAN
1379 CLASS="QUOTE"
1380 >"/adsl/"</SPAN
1381 > is matching <SPAN
1382 CLASS="QUOTE"
1383 >"/ads"</SPAN
1384 >! But 
1385  we did not want this at all! Now we see why we get the blank page. We could
1386  now add a new action below this that explictly does <I
1387 CLASS="EMPHASIS"
1388 >not</I
1389 >
1390  block (-block) pages with <SPAN
1391 CLASS="QUOTE"
1392 >"adsl"</SPAN
1393 >. There are various ways to
1394  handle such exceptions. Example:</P
1395 ><P
1396 > <TABLE
1397 BORDER="0"
1398 BGCOLOR="#E0E0E0"
1399 WIDTH="100%"
1400 ><TR
1401 ><TD
1402 ><PRE
1403 CLASS="SCREEN"
1404 >&#13; { -block }
1405   /adsl
1406  
1407  </PRE
1408 ></TD
1409 ></TR
1410 ></TABLE
1411 ></P
1412 ><P
1413 > Now the page displays ;-) Be sure to flush your browser's caches when 
1414  making such changes. Or, try using <TT
1415 CLASS="LITERAL"
1416 >Shift+Reload</TT
1417 >.</P
1418 ><P
1419 > But now what about a situation where we get no explicit matches like 
1420  we did with:</P
1421 ><P
1422 > <TABLE
1423 BORDER="0"
1424 BGCOLOR="#E0E0E0"
1425 WIDTH="100%"
1426 ><TR
1427 ><TD
1428 ><PRE
1429 CLASS="SCREEN"
1430 >&#13; { -block }
1431   /adsl
1432  
1433  </PRE
1434 ></TD
1435 ></TR
1436 ></TABLE
1437 ></P
1438 ><P
1439 > That actually was very telling and pointed us quickly to where the problem
1440  was. If you don't get this kind of match, then it means one of the default 
1441  rules in the first section is causing the problem. This would require some 
1442  guesswork, and maybe a little trial and error to isolate the offending rule.
1443  One likely cause would be one of the <SPAN
1444 CLASS="QUOTE"
1445 >"{+filter}"</SPAN
1446 > actions. Try 
1447  adding the URL for the site to one of aliases that turn off <SPAN
1448 CLASS="QUOTE"
1449 >"+filter"</SPAN
1450 >:</P
1451 ><P
1452 > <TABLE
1453 BORDER="0"
1454 BGCOLOR="#E0E0E0"
1455 WIDTH="100%"
1456 ><TR
1457 ><TD
1458 ><PRE
1459 CLASS="SCREEN"
1460 >&#13; {shop}
1461  .quietpc.com
1462  .worldpay.com   # for quietpc.com
1463  .jungle.com
1464  .scan.co.uk
1465  .forbes.com
1466  
1467  </PRE
1468 ></TD
1469 ></TR
1470 ></TABLE
1471 ></P
1472 ><P
1473 > <SPAN
1474 CLASS="QUOTE"
1475 >"{shop}"</SPAN
1476 > is an <SPAN
1477 CLASS="QUOTE"
1478 >"alias"</SPAN
1479 > that expands to 
1480  <SPAN
1481 CLASS="QUOTE"
1482 >"{ -filter -no-cookies -no-cookies-keep }"</SPAN
1483 >. Or you could do 
1484  your own exception to negate filtering:&#13;</P
1485 ><P
1486 > <TABLE
1487 BORDER="0"
1488 BGCOLOR="#E0E0E0"
1489 WIDTH="100%"
1490 ><TR
1491 ><TD
1492 ><PRE
1493 CLASS="SCREEN"
1494 >&#13; {-filter}
1495  .forbes.com
1496  
1497  </PRE
1498 ></TD
1499 ></TR
1500 ></TABLE
1501 ></P
1502 ><P
1503 > <SPAN
1504 CLASS="QUOTE"
1505 >"{fragile}"</SPAN
1506 > is an alias that disables most actions. This can be 
1507  used as a last resort for problem sites. Remember to flush caches! If this 
1508  still does not work, you will have to go through the remaining actions one by
1509  one to find which one(s) is causing the problem.</P
1510 ></DIV
1511 ></DIV
1512 ><DIV
1513 CLASS="NAVFOOTER"
1514 ><HR
1515 ALIGN="LEFT"
1516 WIDTH="100%"><TABLE
1517 WIDTH="100%"
1518 BORDER="0"
1519 CELLPADDING="0"
1520 CELLSPACING="0"
1521 ><TR
1522 ><TD
1523 WIDTH="33%"
1524 ALIGN="left"
1525 VALIGN="top"
1526 ><A
1527 HREF="seealso.html"
1528 >Prev</A
1529 ></TD
1530 ><TD
1531 WIDTH="34%"
1532 ALIGN="center"
1533 VALIGN="top"
1534 ><A
1535 HREF="index.html"
1536 >Home</A
1537 ></TD
1538 ><TD
1539 WIDTH="33%"
1540 ALIGN="right"
1541 VALIGN="top"
1542 >&nbsp;</TD
1543 ></TR
1544 ><TR
1545 ><TD
1546 WIDTH="33%"
1547 ALIGN="left"
1548 VALIGN="top"
1549 >See Also</TD
1550 ><TD
1551 WIDTH="34%"
1552 ALIGN="center"
1553 VALIGN="top"
1554 >&nbsp;</TD
1555 ><TD
1556 WIDTH="33%"
1557 ALIGN="right"
1558 VALIGN="top"
1559 >&nbsp;</TD
1560 ></TR
1561 ></TABLE
1562 ></DIV
1563 ></BODY
1564 ></HTML
1565 >