Hi,

On 2024/06/14 5:20, 'JP 99' via Trac Users wrote:
> Hi, ubuntu 22.04/trac-1.6/tracspamfilter-1.5.3/accountmanager-0.6.0
> 
> Account Policy set to RegistrationFilterAdapter.
> 
> Registering a user "test" I get in trac.log:
> 
> Trac[filtersystem] ERROR: Filter strategy <Component 
> tracspamfilter.filters.registration.RegistrationFilterStrategy> raised 
> exception: 'Fragment' object has no attribute 'replace'
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python3.10/dist-packages/tracspamfilter/filters/registration.py",
>  line 81, in test
>     check.validate_registration(req)
>   File "/usr/local/lib/python3.10/dist-packages/acct_mgr/register.py", line 
> 289, in validate_registration
>     raise RegistrationError(tag_(
> acct_mgr.register.RegistrationError: Username <b>test</b> doesn't match local 
> naming policy.
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python3.10/dist-packages/tracspamfilter/filtersystem.py", 
> line 200, in test
>     retval = strategy.test(req, author, content, ip)
>   File 
> "/usr/local/lib/python3.10/dist-packages/tracspamfilter/filters/registration.py",
>  line 84, in test
>     msg = e.message.replace('\n', '')
> AttributeError: 'Fragment' object has no attribute 'replace'

It seems to be an issue of the spam-filter plugin. Please try the following 
patch:

Index: tracspamfilter/filters/registration.py
===================================================================
--- tracspamfilter/filters/registration.py      (revision 17823)
+++ tracspamfilter/filters/registration.py      (working copy)
@@ -16,7 +16,8 @@

 from trac.config import BoolOption, IntOption
 from trac.core import Component, ExtensionPoint, implements
-from trac.util.html import tag
+from trac.util.html import striptags, tag
+from trac.util.text import to_unicode

 from tracspamfilter.api import IFilterStrategy, N_

@@ -81,11 +82,7 @@
                         check.validate_registration(req)
                 except RegistrationError as e:
                     karma -= abs(self.karma_points)
-                    msg = e.message.replace('\n', '')
-                    args = e.msg_args
-                    if args:
-                        msg = msg % args
-                        msg.replace('<b>', '*').replace('</b>', '*')
+                    msg = striptags(to_unicode(e))
                     self.log.debug("Registration check returned %s", msg)
                     checks.append('%s: %s' % (check.__class__.__name__, msg))
                 except Exception as e:


-- 
Jun Omae <[email protected]> (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/f231a8bb-49d1-4a99-9aa3-09595715fc8a%40gmail.com.

Reply via email to