[Bast-commits] r9287 - ironman/branches/mk-ii/Perlanet-IronMan/lib/Perlanet

castaway at dev.catalyst.perl.org castaway at dev.catalyst.perl.org
Sun May 2 15:40:56 GMT 2010


Author: castaway
Date: 2010-05-02 16:40:56 +0100 (Sun, 02 May 2010)
New Revision: 9287

Modified:
   ironman/branches/mk-ii/Perlanet-IronMan/lib/Perlanet/IronMan.pm
Log:
Add the scrubber defs from plagger version


Modified: ironman/branches/mk-ii/Perlanet-IronMan/lib/Perlanet/IronMan.pm
===================================================================
--- ironman/branches/mk-ii/Perlanet-IronMan/lib/Perlanet/IronMan.pm	2010-05-02 15:40:13 UTC (rev 9286)
+++ ironman/branches/mk-ii/Perlanet-IronMan/lib/Perlanet/IronMan.pm	2010-05-02 15:40:56 UTC (rev 9287)
@@ -27,7 +27,6 @@
 =head1 SYNOPSIS
 
 
-
 =head1 DESCRIPTION
 
 This module uses an IronMan::Schema database to define feeds, collect the feeds
@@ -49,6 +48,58 @@
     lazy_build => 1
 );
 
+sub _build_scrubber {
+  my $self = shift;
+  
+  my %scrub_rules = (
+      img => {
+          src => qr{^http://},    # only URL with http://
+          alt => 1,               # alt attributes allowed
+          '*' => 0,               # deny all others
+        },
+      style  => 0,
+      script => 0,
+  );
+    
+  # Definitions for HTML::Scrub
+  my %scrub_def = (
+      '*'    => 1,                        # default rule, allow all attributes
+      'href' => qr{^(?!(?:java)?script)}i,
+      'src'  => qr{^(?!(?:java)?script)}i,
+      'cite'     => '(?i-xsm:^(?!(?:java)?script))',
+      'language' => 0,
+      'name'        => 1,                 # could be sneaky, but hey ;)
+      'onblur'      => 0,
+      'onchange'    => 0,
+        'onclick'     => 0,
+        'ondblclick'  => 0,
+        'onerror'     => 0,
+        'onfocus'     => 0,
+        'onkeydown'   => 0,
+        'onkeypress'  => 0,
+        'onkeyup'     => 0,
+        'onload'      => 0,
+        'onmousedown' => 0,
+        'onmousemove' => 0,
+        'onmouseout'  => 0,
+        'onmouseover' => 0,
+        'onmouseup'   => 0,
+        'onreset'     => 0,
+        'onselect'    => 0,
+        'onsubmit'    => 0,
+        'onunload'    => 0,
+        'src'         => 0,
+        'type'        => 0,
+        'style'       => 0,
+  );
+
+  my $scrub = HTML::Scrubber->new;
+  $scrub->rules(%scrub_rules);
+  $scrub->default(1, \%scrub_def);
+  
+  return $scrub;
+}
+
 =head2 select_entries
 
 The select entries function takes an array of Perlanet::Feed objects and




More information about the Bast-commits mailing list