Modify ↓
Opened 13 years ago
Closed 13 years ago
#10493 closed defect (fixed)
Problem with spam plugin admin panel when API keys are not set
Reported by: | 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 , 13 years ago
comment:2 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
In r10888.