Guest User

Untitled

a guest
Jun 20th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. sub straighten_html {
  2. my $body_content = shift;
  3.  
  4. my @allow = qw[ strong em p br li ul i u ol b i];
  5.  
  6. my @rules = (script => 0, img => 0,);
  7. my @default = (
  8. 0 => # default rule, deny all tags
  9. { '*' => 1, # default rule, allow all attributes
  10. 'href' => qr{^(?!(?:java)?script)}i,
  11. 'src' => qr{^(?!(?:java)?script)}i,
  12.  
  13. # If your perl doesn't have qr
  14. # just use a string with length greater than 1
  15. 'cite' => '(?i-xsm:^(?!(?:java)?script))',
  16. 'language' => 0,
  17. 'name' => 1, # could be sneaky, but hey ;)
  18. 'onblur' => 0,
  19. 'onchange' => 0,
  20. 'onclick' => 0,
  21. 'ondblclick' => 0,
  22. 'onerror' => 0,
  23. 'onfocus' => 0,
  24. 'onkeydown' => 0,
  25. 'onkeypress' => 0,
  26. 'onkeyup' => 0,
  27. 'onload' => 0,
  28. 'onmousedown' => 0,
  29. 'onmousemove' => 0,
  30. 'onmouseout' => 0,
  31. 'onmouseover' => 0,
  32. 'onmouseup' => 0,
  33. 'onreset' => 0,
  34. 'onselect' => 0,
  35. 'onsubmit' => 0,
  36. 'onunload' => 0,
  37. 'src' => 0,
  38. 'type' => 0,
  39. });
  40.  
  41. my $scrubber = HTML::Scrubber->new(
  42. allow => \@allow,
  43. rules => \@rules,
  44. default => \@default,
  45. comment => 1,
  46. process => 0,
  47. );
  48. my $bc = $scrubber->scrub($body_content);
  49. return $bc;
  50. }
Add Comment
Please, Sign In to add comment