X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fwebserver%2Fuser-manual%2Fappendix.html;h=96679a291928d20d5fc63baa9d2ee6b27da9c26e;hb=d74ec2c8f9726f42df2ce1e45749d74dee43b781;hp=e5356f36b8b5667998afb95a5785caf955fca7da;hpb=7017546f48d1189837d3b8d6a523328195279e57;p=privoxy.git diff --git a/doc/webserver/user-manual/appendix.html b/doc/webserver/user-manual/appendix.html index e5356f36..96679a29 100644 --- a/doc/webserver/user-manual/appendix.html +++ b/doc/webserver/user-manual/appendix.html @@ -4,10 +4,10 @@ >Appendix
Privoxy User Manual | Privoxy 3.0.4 User Manual||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Prev | 9. Appendix14. Appendix9.1. Regular Expressions14.1. Regular ExpressionsPrivoxy can use "regular expressions" - in various config files. Assuming support for uses Perl-style "pcre" (Perl - Compatible Regular Expressions) is compiled in, which is the default. Such - configuration directives do not require regular expressions, but they can be - used to increase flexibility by matching a pattern with wild-cards against - URLs. "regular + expressions" in its actions + files and filter file, + through the PCRE and + PCRS libraries.If you are reading this, you probably don't understand what "regular expressions" are, or what they can do. So this will be a very brief - introduction only. A full explanation would require a book ;-) book ;-)Regular expressions provide a language to describe patterns that can be + run against strings of characters (letter, numbers, etc), to see if they + match the string or not. The patterns are themselves (sometimes complex) + strings of literal characters, combined with wild-cards, and other special + characters, called meta-characters. The "Regular expressions" is a way of matching one character - expression against another to see if it matches or not. One of the +>"meta-characters" have + special meanings and are used to build complex patterns to be matched against. + Perl Compatible Regular Expressions are an especially convenient "expressions" is a literal string of readable characters - (letter, numbers, etc), and the other is a complex string of literal - characters combined with wild-cards, and other special characters, called - meta-characters. The "meta-characters" have special meanings and - are used to build the complex pattern to be matched against. Perl Compatible - Regular Expressions is an enhanced form of the regular expression language - with backward compatibility. "dialect" of the regular expression language.To make a simple analogy, we do something similar when we use wild-card characters when listing files with the
These are just some of the ones you are likely to use when matching URLs with
/.*/banners/.* - A simple example
that uses the common combination of A now something a little more complex: /.*/adv((er)?ts?|ertis(ing|ements?))?/ -
We have several literal forward slashes again (".*", so we are matching against any conceivable sub-path, just so
- it matches our expression. The only true literal that must
match /.*/advert[0-9]+\.(gif|jpe?g) - Again another path statement with forward slashes. Anything in the square brackets is not in the expression anywhere). s/microsoft(?!.com)/MicroSuck/i - This is - a substitution. "MicroSuck" will replace any occurrence of - "microsoft". The "i" at the end of the expression - means ignore case. The "(?!.com)" means - the match should fail if "microsoft" is followed by - ".com". In other words, this acts like a "NOT" - modifier. In case this is a hyperlink, we don't want to break it ;-). We are barely scratching the surface of regular expressions here so that you can understand the default http://www.perldoc.com/perl5.6/pod/perlre.html For information on regular expression based substitutions and their applications + in filters, please see the filter file tutorial + in this manual. 9.2. 14.2. Privoxy's Internal Pages's Internal Pages Since Alternately, this may be reached at There is a shortcut: http://p.p/, but this
- variation may not work as reliably as the above in some configurations.
+> (But it
+ doesn't provide a fall-back to a real page, in case the request is not
+ sent through Privoxy)
- Show information about the current configuration:
+ Show information about the current configuration, including viewing and
+ editing of actions files:
- Show the client's request headers:
+ Show the browser's request headers:
- Edit the actions list file: - These may be bookmarked for quick reference. These may be bookmarked for quick reference. See next.9.2.1. Bookmarklets14.2.1. BookmarkletsBelow are some "may not be safe" - just click OK. Then you can run the - Bookmarklet directly from your favourites/bookmarks. For even faster access, + Bookmarklet directly from your favorites/bookmarks. For even faster access, you can put them on the "Links" Enable PrivoxyPrivoxy - Enable Disable PrivoxyPrivoxy - Disable Toggle PrivoxyPrivoxy - Toggle Privoxy (Toggles between enabled and disabled) View Privoxy StatusPrivoxy- View StatusActions file feedback systemPrivoxy - Why? Credit: The site which gave me the general idea for these bookmarklets is +> Credit: The site which gave us the general idea for these bookmarklets is www.bookmarklets.com. They @@ -1044,25 +1070,252 @@ CLASS="SECT2" > 9.3. Anatomy of an Action14.3. Chain of EventsThe way Let's take a quick look at the basic sequence of events when a web page is + requested by your browser and Privoxy is on duty:
14.4. Anatomy of an ActionThe way Privoxy applies + actions and filters + to any given URL can be complex, and not always so easy to understand what is happening. And sometimes we need to be able to - see just what PrivoxyPrivoxy is doing - is causing us a problem inadvertantly. It can be a little daunting to look at + is causing us a problem inadvertently. It can be a little daunting to look at the actions and filters files themselves, since they tend to be filled with - "regular expressions" whose consequences are not always - so obvious. regular expressions whose consequences are not + always so obvious. One quick test to see if Privoxy is causing a problem + or not, is to disable it temporarily. This should be the first troubleshooting + step. See the Bookmarklets section on a quick + and easy way to do this (be sure to flush caches afterward!). Looking at the + logs is a good idea too. Privoxy provides the +> also provides the actions - are being applied to any given URL. This is a big help for troubleshooting. - First, enter one URL (or partial URL) at the prompt, and then Privoxy will tell us how the current configuration will handle it. This will not - help with filtering effects from the default.filter file! It - also will not tell you about any other URLs that may be embedded within the - URL you are testing. For instance, images such as ads are expressed as URLs - within the raw page source of HTML pages. So you will only get info for the - actual URL that is pasted into the prompt area -- not any sub-URLs. If you - want to know about embedded URLs like ads, you will have to dig those out of - the HTML source. Use your browser's "View Page Source" option - for this. Or right click on the ad, and grab the URL. Let's look at an example, "+filter" action) from + one of the filter files since this is handled very + differently and not so easy to trap! It also will not tell you about any other + URLs that may be embedded within the URL you are testing. For instance, images + such as ads are expressed as URLs within the raw page source of HTML pages. So + you will only get info for the actual URL that is pasted into the prompt area + -- not any sub-URLs. If you want to know about embedded URLs like ads, you + will have to dig those out of the HTML source. Use your browser's "View + Page Source" option for this. Or right click on the ad, and grab the + URL. Let's try an example, google.com, - one section at a time:
This is the top section, and only tells us of the compiled in defaults. This - is basically what Privoxy would do if there - were not any "actions" defined, i.e. it does nothing. Every action - is disabled. This is not particularly informative for our purposes here. OK, - next section:
This is much more informative, and tells us how we have defined our - This tells us how we have defined our + "actions", and which ones match for our example, - , and + which ones match for our example, "google.com". The first grouping shows our default - settings, which would apply to all URLs. If you look at your . The first listing + is any matches for the standard.action file. No hits at + all here on "standard". Then next is "default", or + our default.action file. The large, multi-line listing, + is how the actions are set to match for all URLs, i.e. our default settings. + If you look at your "actions" - file, this would be the section just below the file, this would be the section + just below the "aliases" section - near the top. This applies to all URLs as signified by the single forward - slash -- section near the top. This will apply to + all URLs as signified by the single forward slash at the end of the listing + -- "/". - .These are the default actions we have enabled. But we can define additional - actions that would be exceptions to these general rules, and then list - specific URLs that these exceptions would apply to. Last match wins. - Just below this then are two explict matches for But we can define additional actions that would be exceptions to these general + rules, and then list specific URLs (or patterns) that these exceptions would + apply to. Last match wins. Just below this then are two explicit matches for + ".google.com". - The first is negating our various cookie blocking actions (i.e. we will allow - cookies here). The second is allowing . The first is negating our previous cookie setting, + which was for "fast-redirects". Note - that there is a leading dot here -- "+session-cookies-only" + (i.e. not persistent). So we will allow persistent cookies for google. The + second turns off any + "+fast-redirects" + action, allowing this to take place unmolested. Note that there is a leading + dot here -- ".google.com". This will - match any hosts and sub-domains, in the google.com domain also, such as +>. This will match any hosts and + sub-domains, in the google.com domain also, such as "www.google.com". So, apparently, we have these actions defined - somewhere in the lower part of our actions file, and - . So, apparently, we have these two actions + defined somewhere in the lower part of our default.action + file, and "google.com" is referenced in these sections. is referenced somewhere in these latter + sections.And now we pull it altogether in the bottom section and summarize how +> Then, for our user.action file, we again have no hits. And finally we pull it all together in the bottom section and summarize how
Privoxy is appying all its is applying all its "actions"
@@ -1258,21 +1579,52 @@ WIDTH="100%"
> |
Notice the only difference here to the previous listing, is to + "fast-redirects" and "session-cookies-only", + which are actived specifically for this site in our configuration.
Now another example, "ad.doubleclick.net"
{ +block +image } +> { +block +handle-as-image } .ad.doubleclick.net - { +block +image } + { +block +handle-as-image } ad*. - { +block +image } - .doubleclick.net - -
Any one of these would have done the trick and blocked this as an unwanted @@ -1325,27 +1678,38 @@ CLASS="QUOTE" CLASS="QUOTE" >"ad.doubleclick.net"
- is done here -- as both a "+block" + and an - an + "+image". The custom alias "+handle-as-image". + The custom alias "+imageblock" does this - for us. just simplifies the process and make + it more readable.One last example. Let's try "http://www.rhapsodyk.net/adsl/HOWTO/". - This one is giving us problems. We are getting a blank page. Hmmm...
{ -block } - /adsl - -{ +block +handle-as-image } + /ads
This would turn off all filtering for that site. This would probably be most + appropriately put in user.action, for local site + exceptions.
Images that are inexplicably being blocked, may well be hitting the + "+filter{banners-by-size}" rule, which assumes + that images of certain sizes are ad banners (works well most of the time + since these tend to be standardized).
"{fragile}"
Home |