Plagger::Plugin::Filter::Profanity - Profanity filter for entry body


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

NAME

Top

Plagger::Plugin::Filter::Profanity - Profanity filter for entry body

SYNOPSIS

Top

  - module: Filter::Profanity
    config:
      text_only: 1

DESCRIPTION

Top

This plugin filters bad English terms into something like !@$~ using Regexp::Common::profanity_us.

CONFIG

Top

text_only

When set to 1, uses HTML::Parser to avoid replacing bad terms inside HTML tags.

AUTHOR

Top

Tatsuhiko Miyagawa

SEE ALSO

Top

Plagger, Regexp::Common::profanity_us


Plagger documentation Contained in the Plagger distribution.

package Plagger::Plugin::Filter::Profanity;
use strict;
use base qw( Plagger::Plugin::Filter::Base );

use Regexp::Common qw(profanity_us);

our $RE = $RE{profanity}{us}{normal}{label}{-keep}{-dist=>3};
our @Bogus = ('!','@','$','*','%','#','~','=');

sub filter {
    my($self, $body) = @_;
    my $count = $body =~ s/$RE/bogus_string(length($1))/eg;
    return ($count, $body);
}

sub bogus_string {
    my $len = shift;
    return join '', map $Bogus[$_ % $#Bogus], 0..$len-1;
}

1;

__END__