Generated
[privoxy.git] / doc / webserver / user-manual / filter-file.html
index e4a1c5c..2a679e6 100644 (file)
@@ -4,10 +4,9 @@
 >The Filter File</TITLE
 ><META
 NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
-"><LINK
+CONTENT="Modular DocBook HTML Stylesheet Version 1.60"><LINK
 REL="HOME"
-TITLE="Privoxy User Manual"
+TITLE="Privoxy 2.9.16 User Manual"
 HREF="index.html"><LINK
 REL="PREVIOUS"
 TITLE="Actions Files"
@@ -28,7 +27,6 @@ ALINK="#0000FF"
 ><DIV
 CLASS="NAVHEADER"
 ><TABLE
-SUMMARY="Header navigation table"
 WIDTH="100%"
 BORDER="0"
 CELLPADDING="0"
@@ -37,7 +35,7 @@ CELLSPACING="0"
 ><TH
 COLSPAN="3"
 ALIGN="center"
->Privoxy User Manual</TH
+>Privoxy 2.9.16 User Manual</TH
 ></TR
 ><TR
 ><TD
@@ -46,7 +44,6 @@ ALIGN="left"
 VALIGN="bottom"
 ><A
 HREF="actions-file.html"
-ACCESSKEY="P"
 >Prev</A
 ></TD
 ><TD
@@ -60,7 +57,6 @@ ALIGN="right"
 VALIGN="bottom"
 ><A
 HREF="templates.html"
-ACCESSKEY="N"
 >Next</A
 ></TD
 ></TR
@@ -73,7 +69,9 @@ CLASS="SECT1"
 ><H1
 CLASS="SECT1"
 ><A
-NAME="FILTER-FILE">9. The Filter File</H1
+NAME="FILTER-FILE"
+>9. The Filter File</A
+></H1
 ><P
 > All text substitutions that can be invoked through the
  <TT
@@ -120,52 +118,34 @@ CLASS="QUOTE"
 HREF="actions-file.html"
 >actions files</A
 >, the
- filter file is organized in sections, which are called <SPAN
-CLASS="emphasis"
-><I
+ filter file is organized in sections, which are called <I
 CLASS="EMPHASIS"
 >filters</I
-></SPAN
 >
  here. Each filter consists of a heading line, that starts with the
- <SPAN
-CLASS="emphasis"
-><I
+ <I
 CLASS="EMPHASIS"
 >keyword</I
-></SPAN
 > <TT
 CLASS="LITERAL"
 >FILTER:</TT
 >, followed by
- the filter's <SPAN
-CLASS="emphasis"
-><I
+ the filter's <I
 CLASS="EMPHASIS"
 >name</I
-></SPAN
 >, and a short (one line) 
- <SPAN
-CLASS="emphasis"
-><I
+ <I
 CLASS="EMPHASIS"
 >description</I
-></SPAN
 > of what it does. Below that line
- come the <SPAN
-CLASS="emphasis"
-><I
+ come the <I
 CLASS="EMPHASIS"
 >jobs</I
-></SPAN
 >, i.e. lines that define the actual
  text substitutions. By convention, the name of a filter
- should describe what the filter <SPAN
-CLASS="emphasis"
-><I
+ should describe what the filter <I
 CLASS="EMPHASIS"
 >eliminates</I
-></SPAN
 >. The
  comment is used in the <A
 HREF="http://config.privoxy.org/"
@@ -273,7 +253,9 @@ CLASS="SECT2"
 ><H2
 CLASS="SECT2"
 ><A
-NAME="AEN2944">9.1. Filter File Tutorial</H2
+NAME="AEN2983"
+>9.1. Filter File Tutorial</A
+></H2
 ><P
 > Now, let's complete our <SPAN
 CLASS="QUOTE"
@@ -303,12 +285,9 @@ CLASS="SCREEN"
 ></TABLE
 ></P
 ><P
-> But wait! Didn't the comment say that <SPAN
-CLASS="emphasis"
-><I
+> But wait! Didn't the comment say that <I
 CLASS="EMPHASIS"
 >all</I
-></SPAN
 > occurrences
  of <SPAN
 CLASS="QUOTE"
@@ -405,12 +384,9 @@ CLASS="QUOTE"
  matches <SPAN
 CLASS="QUOTE"
 >"&#60;script"</SPAN
->, followed by <SPAN
-CLASS="emphasis"
-><I
+>, followed by <I
 CLASS="EMPHASIS"
 >any</I
-></SPAN
 > text, i.e.
  it matches the whole page, from the start of the first &#60;script&#62; tag.</P
 ><P
@@ -422,24 +398,18 @@ CLASS="LITERAL"
 CLASS="QUOTE"
 >"document.referrer"</SPAN
 >. The dot needed to
- be <SPAN
-CLASS="emphasis"
-><I
+ be <I
 CLASS="EMPHASIS"
 >escaped</I
-></SPAN
 >, i.e. preceded by a backslash, to take away its
  special meaning as a joker, and make it just a regular dot. So far, the meaning is:
  Match from the start of the first &#60;script&#62; tag in a the page, up to, and including,
  the text <SPAN
 CLASS="QUOTE"
 >"document.referrer"</SPAN
->, if <SPAN
-CLASS="emphasis"
-><I
+>, if <I
 CLASS="EMPHASIS"
 >both</I
-></SPAN
 > are present
  in the page (and appear in that order).</P
 ><P
@@ -478,12 +448,9 @@ CLASS="QUOTE"
  text in between <SPAN
 CLASS="QUOTE"
 >"&#60;script"</SPAN
-> and the <SPAN
-CLASS="emphasis"
-><I
+> and the <I
 CLASS="EMPHASIS"
 >first</I
-></SPAN
 > occurrence
  of <SPAN
 CLASS="QUOTE"
@@ -492,12 +459,9 @@ CLASS="QUOTE"
 CLASS="LITERAL"
 >.*</TT
 > will
- only span the text up to the <SPAN
-CLASS="emphasis"
-><I
+ only span the text up to the <I
 CLASS="EMPHASIS"
 >first</I
-></SPAN
 > <SPAN
 CLASS="QUOTE"
 >"&#60;/script&#62;"</SPAN
@@ -542,12 +506,9 @@ CLASS="LITERAL"
  <TT
 CLASS="LITERAL"
 >"Not Your Business!"</TT
-> (<SPAN
-CLASS="emphasis"
-><I
+> (<I
 CLASS="EMPHASIS"
 >including</I
-></SPAN
 >
  the quotation marks!), followed by the text remembered as <TT
 CLASS="LITERAL"
@@ -589,7 +550,7 @@ WIDTH="100%"
 CLASS="SCREEN"
 ># The status bar is for displaying link targets, not pointless blahblah
 #
-s/window\.status\s*=\s*['"].*?['"]/dUmMy=1/ig</PRE
+s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig</PRE
 ></TD
 ></TR
 ></TABLE
@@ -623,14 +584,26 @@ CLASS="LITERAL"
 > construct means: <SPAN
 CLASS="QUOTE"
 >"a single
- <SPAN
-CLASS="emphasis"
-><I
+ <I
 CLASS="EMPHASIS"
 >or</I
-></SPAN
 > a double quote"</SPAN
->.</P
+>. Finally, <TT
+CLASS="LITERAL"
+>\1</TT
+> is
+ a backreference to the first parenthesis just like <TT
+CLASS="LITERAL"
+>$1</TT
+> above,
+ with the difference that in the <I
+CLASS="EMPHASIS"
+>pattern</I
+>, a backslash indicates
+ a backreference, whereas in the <I
+CLASS="EMPHASIS"
+>substitute</I
+>, it's the dollar.</P
 ><P
 > So what does this job do? It replaces assignments of single- or double-quoted
  strings to the <SPAN
@@ -652,7 +625,7 @@ WIDTH="100%"
 CLASS="SCREEN"
 ># Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html
 #
-s/(&#60;body .*)onunload(.*&#62;)/$1never$2/iU</PRE
+s/(&#60;body [^&#62;]*)onunload(.*&#62;)/$1never$2/iU</PRE
 ></TD
 ></TR
 ></TABLE
@@ -664,12 +637,9 @@ HREF="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Even
 TARGET="_top"
 >OnUnload
  event binding</A
-> in the HTML DOM was a <SPAN
-CLASS="emphasis"
-><I
+> in the HTML DOM was a <I
 CLASS="EMPHASIS"
 >CRIME</I
-></SPAN
 >.
  When I close a browser window, I want it to close and die. Basta.
  This job replaces the <SPAN
@@ -687,7 +657,20 @@ CLASS="LITERAL"
 CLASS="LITERAL"
 >i</TT
 > option makes the pattern matching
- case-insensitive.</P
+ case-insensitive. Also note that ungreedy matching alone doesn't always guarantee
+ a minimal match: In the first parenthesis, we had to use <TT
+CLASS="LITERAL"
+>[^&#62;]*</TT
+>
+ instead of <TT
+CLASS="LITERAL"
+>.*</TT
+> to prevent the match from exceeding the 
+ &#60;body&#62; tag if it doesn't contain <SPAN
+CLASS="QUOTE"
+>"OnUnload"</SPAN
+>, but the page's
+ content does.</P
 ><P
 > The last example is from the fun department:</P
 ><P
@@ -736,6 +719,8 @@ CLASS="SCREEN"
 #
 s* industry[ -]leading \
 |  cutting[ -]edge \
+|  customer[ -]focused \
+|  market[ -]driven \
 |  award[ -]winning # Comments are OK, too! \
 |  high[ -]performance \
 |  solutions[ -]based \
@@ -753,7 +738,7 @@ s* industry[ -]leading \
 CLASS="LITERAL"
 >x</TT
 > option in this job turns on extended syntax, and allows for
- e.g. the liberal use of (non-interpreted!) whitespace for nicer formatting.</P
+ e.g. the liberal use of (non-interpreted!) whitespace for nicer formatting. </P
 ><P
 > You get the idea?</P
 ></DIV
@@ -763,7 +748,6 @@ CLASS="NAVFOOTER"
 ><HR
 ALIGN="LEFT"
 WIDTH="100%"><TABLE
-SUMMARY="Footer navigation table"
 WIDTH="100%"
 BORDER="0"
 CELLPADDING="0"
@@ -775,7 +759,6 @@ ALIGN="left"
 VALIGN="top"
 ><A
 HREF="actions-file.html"
-ACCESSKEY="P"
 >Prev</A
 ></TD
 ><TD
@@ -784,7 +767,6 @@ ALIGN="center"
 VALIGN="top"
 ><A
 HREF="index.html"
-ACCESSKEY="H"
 >Home</A
 ></TD
 ><TD
@@ -793,7 +775,6 @@ ALIGN="right"
 VALIGN="top"
 ><A
 HREF="templates.html"
-ACCESSKEY="N"
 >Next</A
 ></TD
 ></TR