line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Validate::WithYAML::Plugin::NoSpam; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1227180
|
use warnings; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
100
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
58
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
664
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Plugin to check that a given text is no spam. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.04; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub check { |
14
|
5
|
|
|
5
|
1
|
1385
|
my ($class, $value) = @_; |
15
|
|
|
|
|
|
|
|
16
|
5
|
100
|
|
|
|
185
|
croak "no value to check" unless defined $value; |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
36
|
if ( $value =~ /(?:\[url|<a href)/ ) { |
|
|
100
|
|
|
|
|
|
19
|
2
|
|
|
|
|
7
|
return 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ( $value =~ /viagra|cialis/i ) { |
22
|
1
|
|
|
|
|
3
|
return 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
6
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; # End of Data::Validate::WithYAML::Plugin::NoSpam |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Data::Validate::WithYAML::Plugin::NoSpam - Plugin to check that a given text is no spam. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 0.04 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The check is done with heuristics. It checks that there are no |
47
|
|
|
|
|
|
|
<a href="..."> or [url=""] tags in the text... |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Data::Validate::WithYAML::Plugin::NoSpam; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $foo = Data::Validate::WithYAML::Plugin::NoSpam->check( |
52
|
|
|
|
|
|
|
'This is a <a href="anything">Spam-Link</a>', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
... |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# use the plugin via Data::Validate::WithYAML |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Data::Validate::WithYAML; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $text = 'This is a <a href="anything">Spam-Link</a>'; |
61
|
|
|
|
|
|
|
my $validator = Data::Validate::WithYAML->new( 'test.yml' ); |
62
|
|
|
|
|
|
|
print "yes" if $validator->check( 'textfield', $text ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
test.yml |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
--- |
67
|
|
|
|
|
|
|
step1: |
68
|
|
|
|
|
|
|
textfield: |
69
|
|
|
|
|
|
|
plugin: NoSpam |
70
|
|
|
|
|
|
|
type: required |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SUBROUTINES |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 check |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Renee Baecker <module@renee-baecker.de> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Renee Baecker. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software, licensed under: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |