forked from NCIP/pathway-interaction-database
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Scan.pm
executable file
·72 lines (62 loc) · 2.03 KB
/
Scan.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
######################################################################
# Scan.pm
######################################################################
# Copyright SRA International
#
# Distributed under the OSI-approved BSD 3-Clause License.
# See http://ncip.github.com/pathway-interaction-database/LICENSE.txt for details.
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw (
Scan
);
######################################################################
sub Scan {
my $ret_val = 0;
for my $input (@_) {
my $ret = exam($input);
$ret_val = $ret_val + $ret;
}
return $ret_val;
}
######################################################################
sub exam {
my ($inp) = @_;
my $input = $inp;
my $ret_val = 0;
## if( ($input =~ /javascript/i) or ($input =~ /<script>.+<\/script>/i) ) {
if( ($input =~ /javascript/i) or ($input =~ /\<script\>/i) or ($input =~ /\<\/script\>/i) or ($input =~ /vbscript/i) ) {
## print "<br><b><center>Error in input: $input</b>!</center>";
print "<br><b><center>Error in input</b>!</center>";
return 1;
}
if( $input =~ /=/ ) {
my @tmp = split "=", $input;
for (my $i=0; $i<@tmp; $i+2) {
$tmp[$i] =~ s/\s+$//;
my @left = split /\s+/, $tmp[$i];
$tmp[$i+1] =~ s/^\s+//;
my @right = split /\s+/, $tmp[$i+1];
my $left_index = @left;
if( $left[$left_index-1] eq $right[0] ) {
print "<br><b><center>Error in input</b>!</center>";
## print "<br><b><center>Error in input: $input</b>!</center>";
return 1;
}
}
}
if( $input =~ /\|\|/ ) {
print "<br><b><center>Error in input</b>!</center>";
## print "<br><b><center>Error in input: $input</b>!</center>";
return 1 ;
}
## if( ($input =~ /\'\-\-/) or ($input =~ /\'\s+\-\-/) ) {
if( $input =~ /\-\-/ ) {
print "<br><b><center>Error in input</b>!</center>";
## print "<br><b><center>Error in input: $input</b>!</center>";
return 1;
}
return $ret_val;
}
######################################################################
1;