# HG changeset patch # User 'Karl O. Pinc' # Date 1409860116 18000 # Node ID 4dbfb3fec02a4bfab97e3d61736704085b95bcbf # Parent 082b1a458d55253d92646b6b0c4351efda9149b6# Parent e1e9c0f9d7dd08060c36502f9565f7878b0db3f1 merge upstream diff -r 082b1a458d55 -r 4dbfb3fec02a MoinMoin/security/textcha.py --- a/MoinMoin/security/textcha.py Thu Sep 04 14:18:56 2014 -0500 +++ b/MoinMoin/security/textcha.py Thu Sep 04 14:48:36 2014 -0500 @@ -130,26 +130,34 @@ def check_answer(self, given_answer, timestamp, signature): """ check if the given answer to the question is correct and within the correct timeframe""" if self.is_enabled(): + reason = 'ok' if self.answer_re is not None: success = self.answer_re.match(given_answer.strip()) is not None + if not success: + reason = 'answer_re did not match' else: # someone trying to cheat!? success = False + reason = 'answer_re is None' if not timestamp or timestamp + self.expiry_time < time(): success = False + reason = 'textcha expired' try: if not safe_str_equal(self._compute_signature(self.question, timestamp), signature): success = False + reason = 'signature mismatch' except TypeError: success = False + reason = 'TypeError during signature check' success_status = success and u"success" or u"failure" - logging.info(u"TextCha: %s (u='%s', a='%s', re='%s', q='%s')" % ( + logging.info(u"TextCha: %s (u='%s', a='%s', re='%s', q='%s', rsn='%s')" % ( success_status, self.user_info, given_answer, self.answer_regex, self.question, + reason, )) return success else: