Edgewall Software

Changeset 17730

Timestamp:
Oct 28, 2023, 2:27:59 PM (9 months ago)
Author:
Dirk Stöcker
Message:

fix #13031 - add notice about operator precende, add trash words, Jinja2ify captcha dialog

Location:
plugins/trunk/spam-filter/tracspamfilter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/trunk/spam-filter/tracspamfilter/captcha/api.py

    r17729 r17730  
    144144            else:
    145145                data['error'] = _("CAPTCHA verification failed")
    146         else:
     146        el:
    147147            data['error'] = Markup(req.session.get("captcha_reject_reason"))
    148148        # cleanup old values
     
    160160            req.session['captcha_expected'] = result
    161161        req.session.save()
    162         return 'verify_captcha.html', data, None
     162        return 'verify_captcha.html', data,
    163163
    164164    def pre_process_request(self, req, handler):
  • plugins/trunk/spam-filter/tracspamfilter/captcha/expression.py

    r17729 r17730  
    1818
    1919from trac.core import Component, TracError, implements
    20 from trac.config import IntOption
     20from trac.config import IntOption,ListOption
     21from trac.util.html import html
    2122
    2223from tracspamfilter.captcha import ICaptchaMethod
     
    3435    terms = IntOption('spam-filter', 'captcha_expression_terms', 3,
    3536            """Number of terms in numeric CAPTCHA expression.""",
     37
     38
     39
     40
     41
    3642            doc_domain='tracspamfilter')
    3743
     
    7177                        [gettext(self.operations[o]) for o in operations])),
    7278                    ())[:-1]
    73         return expression, ' '.join(map(str, human))
     79        if self.trash:
     80            human = list(human)
     81            for i in range(random.randrange(1, self.terms)):
     82                pos = random.randrange(0, len(human))
     83                elem = _(random.choice(self.trash))
     84                human.insert(pos, elem)
     85         
     86        return expression, html.div(html.div(_('Compute the expression (ignoring operator precendence) and enter result. Ignore any addional text.')),html.p(' '.join(map(str, human))))
    7487
    7588    def verify_captcha(self, req):
  • plugins/trunk/spam-filter/tracspamfilter/templates/verify_captcha.html

    r14842 r17730  
    1 <!DOCTYPE html
    2     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    3     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    4 <html xmlns="http://www.w3.org/1999/xhtml"
    5       xmlns:xi="http://www.w3.org/2001/XInclude"
    6       xmlns:py="http://genshi.edgewall.org/"
    7       xmlns:i18n="http://genshi.edgewall.org/i18n" i18n:domain="tracspamfilter">
    8   <xi:include href="layout.html" />
    9   <head></head>
     1{# Copyright (C) 2023 Dirk Stöcker
     2
     3  This software is licensed as described in the file COPYING, which
     4  you should have received as part of this distribution. The terms
     5  are also available at https://trac.edgewall.org/wiki/TracLicense.
     6
     7  This software consists of voluntary contributions made by many
     8  individuals. For the exact contribution history, see the revision
     9  history and logs, available at https://trac.edgewall.org/.
     10#}
     11# extends 'layout.html'
     12<html>
    1013  <body>
     14
    1115    <div id="content" class="${error and 'error' or 'traccaptcha'}">
    12       <py:if test="error">
    13         <h1>Captcha Error</h1>
    14         <div class="message">${error}</div>
    15       </py:if>
     16     
     17      </h1>
     18      <div class="message">${error}</div>
     19     
    1620      <form method="post" action="${href.captcha()}">
    17         <p>Trac thinks your submission might be Spam.
    18            To prove otherwise please provide a response to the following.</p>
    19         <p py:if="random">Note - the captcha method is choosen randomly. Retry if the captcha does not work on your system!</p>
    20         <py:if test="defaultform">
    21            <blockquote><p>${challenge}</p></blockquote>
    22            <p>
    23            Response: <input type="text" name="captcha_response"/>
    24                   <input type="submit" value="${dgettext('traspamfilter', 'Submit')}"/>
    25            </p>
    26         </py:if>
    27         <py:if test="not defaultform">
    28             ${challenge}
    29         </py:if>
     21        <p>
     22       
     23        <p>Note - the captcha method is choosen randomly. Retry if the captcha does not work on your system!</p>
     24       
     25       
     26        >
     27        >
     28        "/>
     29           >
     30        </p>
     31       
     32        ${challenge}
     33       
    3034      </form>
    3135    </div>
     36
    3237  </body>
    3338</html>
Note: See TracChangeset for help on using the changeset viewer.