You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2004/08/10 00:56:38 UTC

svn commit: rev 36136 - spamassassin/trunk/lib/Mail/SpamAssassin/Plugin

Author: jm
Date: Mon Aug  9 15:56:37 2004
New Revision: 36136

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm
Log:
trivial fix: use the claimed value of a hashcash token instead of the computed value, if claimed < computed.  more deterministic this way.  suggestion from Adam Back

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Hashcash.pm	Mon Aug  9 15:56:37 2004
@@ -222,6 +222,14 @@
   my $bitstring = unpack ("B*", sha1($hc));
   $bitstring =~ /^(0+)/ and $value = length $1;
 
+  # hashcash v1 tokens: if the "claimed value" of the token is less than
+  # what the token actually contains (ie. token was accidentally generated
+  # with 24 bits instead of the claimed 20), then cut it down to just the
+  # claimed value.  that way it's a bit tidier and more deterministic.
+  if ($bits && $value > $bits) {
+    $value = $bits;
+  }
+
   dbg ("hashcash token value: $value");
 
   if ($self->was_hashcash_token_double_spent ($scanner, $hc)) {