Re: some help please writing a filter for a phpbb forum
Fabian Keil <[email protected]> Thu, 8 Dec 2022 17:36:16 +0100
| Newsgroups | gmane.comp.web.privoxy.user |
|---|---|
| Message-ID | <[email protected]> |
René J.V. Bertin <[email protected]> wrote on 2022-12-06 at 21:30:45: > I'm active on a forum run by an admin who prefers to let members deal with broken/disabled features rather than setting up the software properly. > > I've been trying to use a privoxy filter to suppress a few buttons of the posting editor which insert unsupported BBCodes. I know what html code to remove and have confirmed that it has the required effect: > > From the line > > ``` > var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[font]', '[/font]', '[anchor]', '[/anchor]', '[goto]', '[/goto]'); > ``` > > the string ", '[anchor]', '[/anchor]', '[goto]', '[/goto]'" should be removed (for good measure) > > And the following 2 button definitions from `<div id="format-buttons" class="format-buttons">` should also be removed: > > ``` > <button type="button" class="button button-secondary bbcode-anchor" name="addbbcode24" value="anchor" onclick="bbstyle(24)" title="Anchor: [anchor]Name of the anchor[/anchor]"> > anchor > </button> > <button type="button" class="button button-secondary bbcode-goto" name="addbbcode26" value="goto" onclick="bbstyle(26)" title="Goto: [goto=Anchor Name]Link tekst[/goto]"> > goto > </button> > ``` > > I'm not exactly familiar with perl, but I had hoped that the following filter definition would do it (as you can see I experimented with a different approach for the 2 buttons: > > ``` > FILTER: delcamp-forbidden-bbcodes Try to hide buttons for forbidden bbcodes on the delcamp cg forum > s|, '\[anchor\]', '\[/anchor\]', '\[goto\]', '\[/goto\]'||Uig > s|<button type="button" class="button button-secondary bbcode-anchor".*\n\ > .*anchor.*\n\ > .*</button>||ig > s|<button type="button" class="button button-secondary bbcode-goto".*</button>||im > > ``` > > My user.action file has > > ``` > > { +filter{delcamp-forbidden-bbcodes} } > .classicalguitardelcamp.com > > > ``` > > somewhere near the end, just above the `fragile` section. I can see that the rule is applied to the forum URLs but I see no trace of it being invoked if I activate debug 64 as suggested. > > Ergo, I must be doing something wrong, or have missed something. Are these the "external filters" mentioned in the description of the `temporary-directory` feature, for instance? I tested your pcrs commands with Privoxy-Filter-Test (available at <https://www.fabiankeil.de/sourcecode/pft/>) and the result was: --- /home/fk/privoxy/privoxy-filter-test/original-851028837104426112-file-received.html Thu Dec 8 17:16:11 2022 +++ /home/fk/privoxy/privoxy-filter-test/filtered-851028837104426112-file-received.html Thu Dec 8 17:16:11 2022 @@ -1,9 +1,7 @@ -var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[font]', '[/font]', '[anchor]', '[/anchor]', '[goto]', '[/goto]'); +var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[font]', '[/font]'); - <button type="button" class="button button-secondary bbcode-anchor" name="addbbcode24" value="anchor" onclick="bbstyle(24)" title="Anchor: [anchor]Name of the anchor[/anchor]"> - anchor - </button> + <button type="button" class="button button-secondary bbcode-goto" name="addbbcode26" value="goto" onclick="bbstyle(26)" title="Goto: [goto=Anchor Name]Link tekst[/goto]"> goto </button> The last pcrs command in your filter doesn't apply because the text is split across multiple lines. It works for me if I add the "s" option: --- /home/fk/privoxy/privoxy-filter-test/original-851028837104426112-file-received.html Thu Dec 8 17:20:09 2022 +++ /home/fk/privoxy/privoxy-filter-test/filtered-851028837104426112-file-received.html Thu Dec 8 17:20:09 2022 @@ -1,9 +1,5 @@ -var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[font]', '[/font]', '[anchor]', '[/anchor]', '[goto]', '[/goto]'); +var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[font]', '[/font]'); - <button type="button" class="button button-secondary bbcode-anchor" name="addbbcode24" value="anchor" onclick="bbstyle(24)" title="Anchor: [anchor]Name of the anchor[/anchor]"> + - anchor + - </button> - <button type="button" class="button button-secondary bbcode-goto" name="addbbcode26" value="goto" onclick="bbstyle(26)" title="Goto: [goto=Anchor Name]Link tekst[/goto]"> - goto - </button> The pcrs commands used were: s|, '\[anchor\]', '\[/anchor\]', '\[goto\]', '\[/goto\]'||Uig s|<button type="button" class="button button-secondary bbcode-anchor".*\n\ .*anchor.*\n\ .*</button>||ig s|<button type="button" class="button button-secondary bbcode-goto".*</button>||ims Note the "s" added at the end of the last line. The website <https://www.classicalguitardelcamp.com/> uses https so you need a Privoxy version compiled with FEATURE_HTTPS_INSPECTION (you can check at <http://config.privoxy.org/show-status>) and enable https inspection which is documented at: <https://www.privoxy.org/user-manual/config.html#HTTPS-INSPECTION-DIRECTIVES> <https://www.privoxy.org/user-manual/actions-file.html#HTTPS-INSPECTION> Do you have https inspection configured already? Fabian _______________________________________________ Privoxy-users mailing list [email protected] https://lists.privoxy.org/mailman/listinfo/privoxy-users
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEETzbBfzgWkTZUoehQaRgikYuiNxwFAmOSEoAACgkQaRgikYui NxxXhBAAgXK+Z3P2hTlZXsB+/v7/wh13NZgbCZRSGAHBuFg4XpoVVdmEgXbanlG4 vJtNMiNFt523Un8FV2F7uJgUhG6TGsxmcEhsbIw2XRNqwOAPvM9QFQAonZwhgBZ9 EUnoAJvxwx3MDJfhZLFf09WbifyG/CwEYlxdqxMXByOgf6zawxSV1dvAahdncZHo kv2ZeAHORbLVQAPwZsO9J/EWu1DvsDgiG3AyOwMem4HnJ8Y3zATLK0Biuc7oowWQ kEGnnH/zDsy0VgSJTbtZshqWE1agbHq7g4LesU31C2Y0Qi6XRBwvVoWP2kUYrCNE yXu39NtMkw93zJ1ZdE86h5grKEJekL28BHFiyAtZq4EqYrk5Mw95K0+R/TKR+RF1 135Ozi1zL3uIWDNxD5JiTLGgZG3lFbV0Ks63U7Hcta9s/z8LxL0i5wAglIvWMM93 psrsei/HWTCzwb9/3CNqb/zWWU2jN8JVvNEiDwTpAgK3gTQJNfyGNDCP7SJuE0uV gvt3PRlifFOicnl/CqCrojqPG5LY1H0YppQvRz6oMAPBSeAhktvbd1K7zCyUwce0 rfLTu3UC54ZwY5Zxk8Cjt6ZJ0h84njUVn83q5UbGUJva++EgBsz0wrmhE3Wh7hSI 2dHaH7Hbd59qa+Bk4ggIDlyZb+hgkg4fYkAOCj1Z9k/+MDQsIjc= =m6J6 -----END PGP SIGNATURE-----