Articulate/Validation/NoScript.pm

filter: Statementstmt 100% 13 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 18 / 18 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Articulate/Storage/DBIC/Simple/Schema/Result/Articulate/Item.pm ↑ Summary
1 package Articulate::Validation::NoScript;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Articulate::Validation::NoScript
9  
10 =head1 DESCRIPTION
11  
12 An example validator to do a rudimentary check to see if the content has the text "<script" in it, to prevent users from injecting scripts directly into your application.
13  
14 It doesn't thoroughly prevent Javascript injection, an onload attribute might do just as well.
15  
16 =head1 METHODS
17  
18 =head3 validate
19  
20 Returns true if the content contains qr/<script/i; false otherwise.
21  
22 It does not look at the meta to determine content type so might behave unexpectedly, e.g. if called on plain text.
23  
24 =cut
25  
26 sub validate {
27 2 ▶ my $self = shift;
Subroutine validate: called CC=1 SCAR=0.0
Pod documented
28 2 my $item = shift;
29 2 return ( $item->content !~ /<script/i );
30 }
31  
32 2 1;
« Articulate/Storage/DBIC/Simple/Schema/Result/Articulate/Item.pm ↑ Summary