Spamassassin fails to escape backslashes for latest postgres input syntax

Bug #375490 reported by Ian Turner on 2009-05-12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
spamassassin (Ubuntu)

Bug Description

- Spamassassin
- Postgres
- DBD:Pg

I get the following error when attempting to sa-learn --restore:

[24850] dbg: bayes: tok_get: SQL error: ERROR: invalid input syntax for type bytea
[24850] dbg: bayes: _put_token: SQL error: ERROR: invalid input syntax for type bytea
[24850] dbg: bayes: error inserting token for line: t 1 0 1240037056 0178865c33

When run with DBI_TRACE=3, I get the following output:

    -> execute for DBD::Pg::st (DBI::st=HASH(0x99b9c24)~0x99c6f60 '8' '.^M<E4>\<8C>') thr#
dbdpg: ERROR: invalid input syntax for type bytea

The problem is that Postgres 8.3 is expecting the backslash to be escaped if it represents a literal backslash. The following patch seems to resolve the problem, and I think it is backward-compatible, though not necessarily compatible with SQLite or MySql:

--- spamassassin-3.2.3-0.volatile/lib/Mail/SpamAssassin/BayesStore/ 2009-05-12 14:58:28.000000000 +0000
+++ spamassassin-fixed/lib/Mail/SpamAssassin/BayesStore/ 2009-05-12 14:07:21.000000
000 +0000
@@ -1522,6 +1522,8 @@
       else {
        # turn unpacked binary token back into binary value
        $token = pack("H*",$token);
+ # Escape backslashes for DB's benefit
+ $token =~ s/\\/\\0134/g;

       unless ($self->_put_token($token, $spam_count, $ham_count, $atime)) {

Kenyon Ralph (kralph) wrote :

Looks like maybe this upstream bug:

If so, then this should be fixed in spamassassin 3.2.5, which is in hardy-backports (if you're using hardy... although I don't see a spamassassin 3.2.3 published in any current Ubuntu release). Ian, has this been fixed for you?

Changed in spamassassin (Ubuntu):
status: New → Incomplete
Scott Kitterman (kitterman) wrote :

Gutsy was released with 3.2.3-0ubuntu1, but it looks like the reporter was using packages from Debian Volatile:

Chuck Short (zulcss) wrote :

We'd like to figure out what's causing this bug for you, but we haven't heard back from you in a while. Could you please provide the requested information? Thanks!

Ian Turner (vectro) wrote :

I fixed this issue by applying the patch in Update#0, but if this is fixed in 3.2.5, then this bug can be closed.

Chuck Short (zulcss) wrote :

Closing as per user.


Changed in spamassassin (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.