debian/0000755000000000000000000000000011542077714007176 5ustar debian/control0000644000000000000000000000161311542077713010601 0ustar Source: trac-spamfilter Section: python Priority: optional Maintainer: Chris Lamb Build-Depends: debhelper (>= 7.0.50~) Build-Depends-Indep: python-support, python-setuptools Standards-Version: 3.9.1 Vcs-Git: git://github.com/lamby/pkg-trac-spamfilter.git Vcs-Browser: https://github.com/lamby/pkg-trac-spamfilter Homepage: http://trac.edgewall.org/wiki/SpamFilter Package: trac-spamfilter Architecture: all Depends: ${python:Depends}, ${misc:Depends}, trac (>= 0.10), python-pkg-resources Recommends: python-dnspython (>= 1.3.5), spambayes Description: Spam-prevention plugin for Trac This plugin attempts to reject contributions to Trac environments that contain spam. It can use the following techniques: . * Regular expressions * Akismet web service * IP throttling * IP blacklisting (requires python-dnspython package) * Bayesian filtering (requires spambayes package) debian/rules0000755000000000000000000000072411542077713010260 0ustar #!/usr/bin/make -f get-orig-source: set -e ; \ svn co http://svn.edgewall.com/repos/trac/sandbox/spam-filter trac-spamfilter-svn ; \ REVISION=`svnversion trac-spamfilter-svn/` ; \ find trac-spamfilter-svn/ -depth -type d -name ".svn" -print0 | xargs -0 rm -rf ; \ tar cfz trac-spamfilter_0.2.1+svn$$REVISION.orig.tar.gz trac-spamfilter-svn/ ; \ rm -rf trac-spamfilter-svn/ %: dh $@ override_dh_auto_clean: dh_auto_clean rm -rf TracSpamFilter.egg-info debian/compat0000644000000000000000000000000211542077713010373 0ustar 7 debian/docs0000644000000000000000000000001311542077713010042 0ustar README.txt debian/source/0000755000000000000000000000000011542077713010475 5ustar debian/source/format0000644000000000000000000000001411542077713011703 0ustar 3.0 (quilt) debian/README.Debian0000644000000000000000000000260311542077713011237 0ustar trac-spamfilter for Debian -------------------------- CONTENTS 1. Enabling trac-spamfilter globally 2. Enabling trac-spamfilter per project 3. Configuring the Akismet plugin Enabling trac-spamfilter globally ================================= To enable, create or edit /etc/trac.ini and add: [components] tracspamfilter.* = enabled You must restart tracd or your webserver for your changes to take effect. You may also need to perform "trac-admin upgrade ". Enabling trac-spamfilter per project ==================================== Edit the /conf/trac.ini file and the following: [components] tracspamfilter.* = enabled You must restart tracd or your webserver for the changes to take effect. You may also need to run "trac-admin upgrade ". Configuring the Akismet plugin ============================== You can use trac-spamfilter with the Akismet web service to check content for spam. For more information, please see . This filter requires a Wordpress API key. To configure your key, create or edit the following section in /conf/trac.ini or /etc/trac.ini: [spam-filter] akismet_api_key = 1234567890 You must restart tracd or your webserver for the changes to take effect. -- Chris Lamb Tue, 22 Apr 2008 05:30:41 +0100 debian/changelog0000644000000000000000000000267611542077713011062 0ustar trac-spamfilter (0.2.1+svn6871-4) unstable; urgency=low * Apply patch to avoid crash when invalid UTF-8 is used. Thanks to Vincent Bernat . (Closes: #615817) * Update Vcs-{Git,Browser}. * Bump Standards-Version to 3.9.1. * Move to '3.0 (quilt)' source package format. -- Chris Lamb Tue, 22 Mar 2011 10:53:46 +0000 trac-spamfilter (0.2.1+svn6871-3) unstable; urgency=low * Replace Depends on python-setuptools with python-pkg-resources. (Closes: #546425) * Bump Standards-Version to 3.8.3. * Move to minimal dh7 rules file. -- Chris Lamb Sun, 13 Sep 2009 21:52:11 +0100 trac-spamfilter (0.2.1+svn6871-2) unstable; urgency=low * New maintainer email address. * Add ${misc:Depends} to trac-spamfilter Depends. * Move a number of packages from Build-Depends to Build-Depends-Indep. * Tidy debian/rules. * Add dummy debian/watch file. * Use © symbol instead of (C) in debian/copyright to appease lintian. * Bump Standards-Version to 3.8.0; no changes. * Add description for 01-disable-spambayes-depends patch. * Move to debhelper 7; no changes. * Drop versioned dependency on Python 2.4. * Update Git repository locations. -- Chris Lamb Mon, 16 Feb 2009 02:41:11 +0000 trac-spamfilter (0.2.1+svn6871-1) unstable; urgency=low * Initial release (Closes: #422441). -- Chris Lamb Tue, 22 Apr 2008 04:12:33 +0100 debian/watch0000644000000000000000000000006011542077713010222 0ustar # Upstream development is done entirely in SVN. debian/copyright0000644000000000000000000000400011542077713011122 0ustar This package was debianized by Chris Lamb on Tue, 22 Apr 2008 05:35:17 +0100. It was downloaded from . Upstream Authors: Matthew Good Christopher Lenz Edgewall Software Copyright: Copyright © 2005-2006 Matthew Good Copyright © 2006 Christopher Lenz Copyright © 2006 Edgewall Software License: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the author nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The Debian packaging is © 2008-2009, Chris Lamb and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. debian/patches/0000755000000000000000000000000011542077714010625 5ustar debian/patches/02-fix-encoding-errors0000644000000000000000000000425511542077713014660 0ustar diff -urNad /tmp/bp-build/trac-spamfilter-svn.orig/tracspamfilter/filters/bayes.py /tmp/bp-build/trac-spamfilter-svn/tracspamfilter/filters/bayes.py --- trac-spamfilter-svn.orig/tracspamfilter/filters/bayes.py 2011-03-22 10:47:07.905191151 +0000 +++ trac-spamfilter-svn/tracspamfilter/filters/bayes.py 2011-03-22 10:49:12.253401794 +0000 @@ -75,7 +75,7 @@ spam and 'spam' or 'ham') hammie = self._get_hammie() - hammie.train(content.encode('utf-8'), spam) + hammie.train(content.encode('utf-8', 'ignore'), spam) hammie.store() # Internal methods @@ -103,7 +103,14 @@ else: # new database self.nspam = self.nham = 0 + def _sanitize(self, text): + """Remove invalid byte sequences from utf-8 encoded text""" + if isinstance(text, unicode): + return text + return text.decode('utf-8', 'ignore') + def _get_row(self, word): + word = self._sanitize(word) cursor = self.db.cursor() cursor.execute("SELECT nspam,nham FROM spamfilter_bayes WHERE word=%s", (word,)) @@ -114,6 +121,7 @@ return {'nspam': row[0], 'nham': row[1]} def _set_row(self, word, nspam, nham): + word = self._sanitize(word) cursor = self.db.cursor() if self._has_key(word): cursor.execute("UPDATE spamfilter_bayes SET nspam=%s,nham=%s " @@ -124,11 +132,13 @@ self.db.commit() def _delete_row(self, word): + word = self._sanitize(word) cursor = self.db.cursor() cursor.execute("DELETE FROM spamfilter_bayes WHERE word=%s", (word,)) self.db.commit() def _has_key(self, key): + key = self._sanitize(key) cursor = self.db.cursor() cursor.execute("SELECT COUNT(*) FROM spamfilter_bayes WHERE word=%s", (key,)) @@ -136,9 +146,6 @@ def _wordinfoget(self, word): # See http://mail.python.org/pipermail/spambayes-dev/2006-July/003684.html - if isinstance(word, unicode): - word = word.encode("utf-8") - row = self._get_row(word) if row: item = self.WordInfoClass() debian/patches/series0000644000000000000000000000006411542077713012041 0ustar 01-disable-spambayes-depends 02-fix-encoding-errors debian/patches/01-disable-spambayes-depends0000644000000000000000000000154711542077713016001 0ustar # We don't strictly depend on the SpamBayes package as it's an optional # component. dpkg already takes care of this stuff anyway. Index: spam-filter/setup.py =================================================================== --- spam-filter.orig/setup.py 2007-11-28 03:28:46.000000000 +0000 +++ spam-filter/setup.py 2007-11-28 03:28:57.000000000 +0000 @@ -44,7 +44,7 @@ spamfilter.admin = tracspamfilter.admin spamfilter.adapters = tracspamfilter.adapters spamfilter.akismet = tracspamfilter.filters.akismet - spamfilter.bayes = tracspamfilter.filters.bayes[SpamBayes] + spamfilter.bayes = tracspamfilter.filters.bayes spamfilter.extlinks = tracspamfilter.filters.extlinks spamfilter.ip_blacklist = tracspamfilter.filters.ip_blacklist[DNS] spamfilter.ip_throttle = tracspamfilter.filters.ip_throttle