3 #############################################################################
4 # This is a reference script to validate the checksum in downloadable #
5 # subscription. This performs the same validation as Adblock Plus when it #
6 # downloads the subscription. #
8 # To validate a subscription file, run the script like this: #
10 # perl validateChecksum.pl subscription.txt #
12 # Note: your subscription file should be saved in UTF-8 encoding, otherwise #
13 # the validation result might be incorrect. #
15 # 20100418: Stolen from ABP with minor modification for AutoProxy project #
16 #############################################################################
20 use Digest
::MD5
qw(md5_base64);
22 die "Usage: $^X $0 subscription.txt\n" unless @ARGV;
25 my $data = readFile
($file);
34 $data =~ s/^\s*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//mi
;
36 die "Error: couldn't find a checksum in the file\n" unless $checksum;
38 # Calculate new checksum
39 my $checksumExpected = md5_base64
($data);
42 die "Error: invalid checksum\n" unless $checksum eq $checksumExpected;
48 open(local *FILE
, "<", $file) || die "Error: could not read file '$file'";