[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] find binary junk in a database
Here's a buggy, craptastic program I wrote in 10m to find binary junk
that somehow got shoved into our database:
(This is probably a superb example of poor coding. -grin-)
j
------------------
#!/usr/bin/perl
use Omni::DB;
my $dbh = Omni::DB::connect_prod();
my $strsql = <<EOT;
select prop, gds_sys, seamless_bk_code,
disp_line1, disp_line2, disp_line3
from smls_bk_codes2
EOT
my $sth = $dbh->prepare($strsql);
$sth->execute;
my ($prop, $gds_sys, $seamless_bk_code, @row);
while (($prop, $gds_sys, $seamless_bk_code, @row) = $sth->fetchrow) {
foreach $column qw( disp_line1 disp_line2 disp_line3 ) {
$data = join "|", @row;
if ($data =~ /[^ -~]/) {
my ($evil) = ($data =~ /([^ -~])/);
my $notsoevil = ord($evil);
$data =~ s/$evil/\*\*\*ASCII_$notsoevil\*\*\*/g;
print "$prop $gds_sys $seamless_bk_code\n";
print " $data\n";
}
}
}
$sth->finish;
$dbh->disconnect;
Output (see those ASCII 150's in the data!? Those are bad. -grin-):
ATLCNN WB XDRREV
RENDEZVOUS FOR TWO ULTIMATE |DELUXE ACCOMMODATIONS
***ASCII_150*** REQUEST 1 KING, 1 QUEEN|BREAKFAST - CHOCOLATES -
CHAMPAGNE AND ROSES
ATLCNN WB XDRREV
RENDEZVOUS FOR TWO ULTIMATE |DELUXE ACCOMMODATIONS
***ASCII_150*** REQUEST 1 KING, 1 QUEEN|BREAKFAST - CHOCOLATES -
CHAMPAGNE AND ROSES