From: Fabian K. <fk...@fa...> - 2011-01-24 15:22:20
|
Hitesh Shah <chi...@gm...> wrote: > I'm using Privoxy 3.0.17 on a Windows XP SP3 system. I have no complaints at > all but just one thing I need help with. > > I want to replace the 4x4 px based checkerboard pattern with my own 4x4 px > PNG or GIF file. Is it possible? > > I replaced > { +set-image-blocker{http://config.privoxy.org/send-banner?type=pattern} } > #/ > > with > { +set-image-blocker{ > http://config.privoxy.org/send-banner?type=file:///C:/Documents%20and%20Settings/Hits/Desktop/4x42red.gif} > } > / > > but I still get the built-in checkerboard pattern. > > I also made a .png version but that gave the same result. > > I'm obviously doing something wrong and would appreciate knowing the correct > way. The URL you pass to the set-image-blocker action isn't interpreted or modified by Privoxy itself. If you can't access the URL in your browser when you type it in manually, it will not work with the set-image-blocker action either. The URL http://config.privoxy.org/send-banner?type=pattern gets you the pattern image because Privoxy's CGI handler recognizes the type "pattern" (actually it only looks at the first character, but the result is the same). The URL http://config.privoxy.org/send-banner?type=file:///C:/Docum... also results in Privoxy serving the pattern image, but this time because Privoxy uses it by default for unknown types and "file:///C:/Documents%20and%20Settings/Hits/Desktop/4x42red.gif" is not a valid type (more precisely: f is not a character used by any valid type). If you use something like: {+set-image-blocker{file:///C:/Documents%20and%20Settings/Hits/Desktop/4x42red.gif}\ } / Privoxy will generate a redirect to the file:/// URL, but the rest is up to the client. As file:/// is not a properly standardized protocol and can additionally lead to security problems, most clients either don't support it in general, or only support it in certain circumstances (usually not for redirects, though). In Firefox 3.6.13 on FreeBSD, the redirect is properly recognised but not followed for security reasons. On the console where I started Firefox I get the error message: Security Error: Content at http://example.org/wp-content/plugins/social-bookmarks/images/twitter.png may not load or link to file:///C:/Documents%20and%20Settings/Hits/Desktop/4x42red.gif. while the browser windows displays the URL of the request that caused the redirect as content. xxxterm 1.282 complains about an invalid URL scheme: (twitter.png:50485): libsoup-CRITICAL **: soup_uri_uses_default_port: assertion `uri->scheme == SOUP_URI_SCHEME_HTTP || uri->scheme == SOUP_URI_SCHEME_HTTPS || uri->scheme == SOUP_URI_SCHEME_FTP' failed forwards the request to Privoxy and then displays Privoxy's error message "Invalid header received from client." which it gets because Privoxy doesn't recognise file:/// URLs either. curl correctly refuses the redirect: fk@r500 ~ $curl --location --head http://example.org/wp-content/plugins/social-bookmarks/images/twitter.png HTTP/1.1 302 Local Redirect from Privoxy Location: file:///C:/Documents%20and%20Settings/Hits/Desktop/4x42red.gif Content-Length: 0 Date: Mon, 24 Jan 2011 14:49:30 GMT curl: (1) Protocol file not supported or disabled in libcurl While fetch behaves like xxxterm: fk@r500 ~ $fetch http://example.org/wp-content/plugins/social-bookmarks/images/twitter.png fetch: http://example.org/wp-content/plugins/social-bookmarks/images/twitter.png: Bad Request which is interesting because fetch actually supports file:/// URLs when passed on the command line: fk@r500 ~/test/privoxy/test $echo blah > file fk@r500 ~/test/privoxy/test $fetch -o - -q file:///home/fk/test/privoxy/test/file blah > I can get the "blank" to work by following the standard instructions: > { +set-image-blocker{http://config.privoxy.org/send-banner?type=blank} } > / > > But I would like to see what I've blocked. If you make your image available on a web server, you should be able to redirect to its URL. If you convert it to jpeg, you could also let Privoxy itself serve the image, after dropping it into the user-manual directory and enabling user-manual delivery: http://www.privoxy.org/user-manual/config.html#USER-MANUAL It's a bit of a hack, but supposed to work. While Privoxy will also serve images in other formats, it uses the file extension to signal the proper Content-Type and serves everything but files with the extensions .css or .jpeg as text/html. This may lead to problems if the browser doesn't do its own detection magic. Improving this is already on the TODO list: | 84) Flesh out the user-manual delivery to serve pages from | other directories, too. http://ijbswa.cvs.sourceforge.net/viewvc/ijbswa/current/TODO?view=markup Fabian |