2010-12-01 Ramon Novoa <rnovoa@artica.es>
* util/pandora_recode_db.pl: Redefine safe_input to avoid loading a buggy one from a 3.1 Tools.pm. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3648 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
7ab7b9ad0a
commit
e83717071e
|
@ -1,3 +1,8 @@
|
|||
2010-12-01 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* util/pandora_recode_db.pl: Redefine safe_input to avoid loading
|
||||
a buggy one from a 3.1 Tools.pm.
|
||||
|
||||
2010-11-29 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||
|
||||
* lib/PandoraFMS/ReconServer.pm: Fixed a problem with HTML entities executing
|
||||
|
|
|
@ -150,6 +150,49 @@ sub help_screen{
|
|||
exit;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
## Convert the $value encode in html entity to clear char string.
|
||||
##########################################################################
|
||||
sub safe_input($) {
|
||||
my $value = shift;
|
||||
|
||||
$value = encode_entities ($value, "'<>&");
|
||||
|
||||
#//Replace the character '\' for the equivalent html entitie
|
||||
$value =~ s/\\/\/gi;
|
||||
|
||||
#// First attempt to avoid SQL Injection based on SQL comments
|
||||
#// Specific for MySQL.
|
||||
$value =~ s/\/\*//*/gi;
|
||||
$value =~ s/\*\//*//gi;
|
||||
|
||||
#//Replace ( for the html entitie
|
||||
$value =~ s/\(/(/gi;
|
||||
|
||||
#//Replace ( for the html entitie
|
||||
$value =~ s/\)/)/gi;
|
||||
|
||||
#//Replace some characteres for html entities
|
||||
for (my $i=0;$i<33;$i++) {
|
||||
my $pattern = chr($i);
|
||||
my $hex = ascii_to_html($i);
|
||||
$value =~ s/$pattern/$hex/gi;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# SUB ascii_to_html (string)
|
||||
# Convert an ascii string to hexadecimal
|
||||
##########################################################################
|
||||
|
||||
sub ascii_to_html($) {
|
||||
my $ascii = shift;
|
||||
|
||||
return "&#x".substr(unpack("H*", pack("N", $ascii)),6,3).";";
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# MAIN
|
||||
|
|
Loading…
Reference in New Issue