Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

#10493 closed defect (fixed)

Problem with spam plugin admin panel when API keys are not set

Reported by: manuel.holtgrewe@… Owned by: Dirk Stöcker
Priority: normal Milestone:
Component: plugin/spamfilter Version:
Severity: major Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When the API keys are not set in the configuration, the current spam plugin tries to connect to the services with NULL keys. This results in errors, e.g. when the web server is not allowed to connect to the hosts (and probably also when the spam detection service then rejects the empty API key).

The following small patch uses the "empty strings coerce to False" Python idiom to circumvent this problem.

Index: tracspamfilter/admin.py
===================================================================
--- tracspamfilter/admin.py	(revision 10886)
+++ tracspamfilter/admin.py	(working copy)
@@ -318,13 +318,13 @@
             use_external = 'use_external' in req.args
             train_external = 'train_external' in req.args
             try:
-                if akismet_api_key != "" and not akismet.verify_key(req, akismet_api_url, akismet_api_key):
+                if akismet_api_key and not akismet.verify_key(req, akismet_api_url, akismet_api_key):
                     data['akismeterror'] = 'The API key is invalid'
                     data['error'] = 1
-                elif typepad_api_key != "" and not typepad.verify_key(req, typepad_api_url, typepad_api_key):
+                elif typepad_api_key and not typepad.verify_key(req, typepad_api_url, typepad_api_key):
                     data['typepaderror'] = 'The API key is invalid'
                     data['error'] = 1
-                elif defensio and defensio_api_key != "" and not defensio.verify_key(req, defensio_api_url, defensio_api_key):
+                elif defensio and defensio_api_key and not defensio.verify_key(req, defensio_api_url, defensio_api_key):
                     data['defensioerror'] = 'The API key is invalid'
                     data['error'] = 1
                 else:
@@ -500,7 +500,7 @@
                     data['unknownsourceerror'] = 'Numeric image values are no numbers'
                     data['error'] = 1
             try:
-                if captcha_recaptcha_private_key != "" and not recaptcha.verify_key(
+                if captcha_recaptcha_private_key and not recaptcha.verify_key(
                     captcha_recaptcha_private_key, captcha_recaptcha_public_key):
                     data['recaptchaerror'] = 'The keys are invalid'
                     data['error'] = 1

Attachments (0)

Change History (2)

comment:1 by Dirk Stöcker, 12 years ago

In r10888.

comment:2 by Dirk Stöcker, 12 years ago

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dirk Stöcker.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Dirk Stöcker to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.