diff --git a/files/classes/comment.py b/files/classes/comment.py index 7303e2d9d..9432f5119 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -458,4 +458,4 @@ class Comment(Base): @property @lazy def complies_with_chud(self): - return re.search(self.author.phrase_regex_pattern, self.body_html.lower()) + return self.author.phrase_regex.search(self.body_html.lower()) diff --git a/files/classes/submission.py b/files/classes/submission.py index 0022cd7d8..a5619f0ce 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -363,4 +363,4 @@ class Submission(Base): @property @lazy def complies_with_chud(self): - return re.search(self.author.phrase_regex_pattern, self.body_html.lower()) + return self.author.phrase_regex.search(self.body_html.lower()) diff --git a/files/classes/user.py b/files/classes/user.py index 37ca4671a..26d4e6f2a 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1,6 +1,7 @@ import random from operator import * from typing import Union +import re import pyotp from sqlalchemy import Column, ForeignKey @@ -1213,5 +1214,5 @@ class User(Base): @property @lazy - def phrase_regex_pattern(self): - return f"

[^<>]*{self.agendaposter_phrase}[^<>]*<\/p>" + def phrase_regex(self): + return re.compile(f"

[^<>]*{self.agendaposter_phrase}[^<>]*<\/p>")