[geany/www.geany.org] 2be127: Pastebin: check also author and title for spam words

Enrico Tröger git-noreply at xxxxx
Sun Aug 16 15:00:53 UTC 2020


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 16 Aug 2020 15:00:53 UTC
Commit:      2be127714beea9c72eb05b9c593f1a4a0808805c
             https://github.com/geany/www.geany.org/commit/2be127714beea9c72eb05b9c593f1a4a0808805c

Log Message:
-----------
Pastebin: check also author and title for spam words


Modified Paths:
--------------
    pastebin/forms.py

Modified: pastebin/forms.py
23 lines changed, 18 insertions(+), 5 deletions(-)
===================================================================
@@ -59,13 +59,26 @@ def __init__(self, request, *args, **kwargs):
         self.fields['author'].initial = self.request.session.get('author', '')
 
     # ----------------------------------------------------------------------
-    def clean_content(self):
-        content = self.cleaned_data.get('content')
-        if content:
+    def _clean_field(self, field_name):
+        value = self.cleaned_data.get(field_name)
+        if value:
             regex = Spamword.objects.get_regex()
-            if regex.findall(content.lower()):
+            if regex.findall(value.lower()):
                 raise forms.ValidationError('This snippet was identified as SPAM.')
-        return content
+
+        return value
+
+    # ----------------------------------------------------------------------
+    def clean_author(self):
+        return self._clean_field('author')
+
+    # ----------------------------------------------------------------------
+    def clean_content(self):
+        return self._clean_field('content')
+
+    # ----------------------------------------------------------------------
+    def clean_title(self):
+        return self._clean_field('title')
 
     # ----------------------------------------------------------------------
     def save(self, *args, **kwargs):  # pylint: disable=signature-differs



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list