Subversion Repositories DevTools

Rev

Rev 1295 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1293 dpurdie 1
package Codestriker::Template::Plugin::StringObfuscator;
2
 
3
# Simple template toolkit plugin module for modifying the string
4
# into a more obfuscated form which spam harvesters can't use for
5
# nabbing email addresses.
6
 
7
use Template::Plugin::Filter;
8
use Codestriker;
9
 
10
use base qw( Template::Plugin::Filter );
11
 
12
sub filter {
13
    my ($self, $text) = @_;
14
 
15
    my $length = length($text);
16
    my $result = "";
17
    for (my $i = 0; $i < $length; $i++) {
18
	my $char = substr $text, $i, 1;
19
	$result .= "\"" unless $i == 0;
20
	$result .= "$char";
21
	$result .= "\"+" unless $i == $length-1;
22
    }
23
 
24
    return $result;
25
}
26
 
27
1;