diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 58c6a7888..a92830efc 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -567,7 +567,8 @@ def process_poll_options(v:User, target:Union[Post, Comment]): option_objects = [] for pattern, exclusive in patterns: - for i in pattern.finditer(target.body): + body_html = target.body_html.replace('&', '&') + for i in pattern.finditer(body_html): option_count += 1 if option_count > POLL_MAX_OPTIONS: @@ -583,18 +584,16 @@ def process_poll_options(v:User, target:Union[Post, Comment]): else: cls = CommentOption - body_html=filter_emojis_only(body, strip=False) #dont strip cuz ppl sometimes leave spaces before && or after it, which breaks the replacing logic - existing = g.db.query(cls).filter_by( parent_id=target.id, - body_html=body_html, + body_html=body, exclusive=exclusive, ).first() if not existing: option = cls( parent_id=target.id, - body_html=body_html, + body_html=body, exclusive=exclusive, ) option_objects.append(option) #shitty hack to bypass autoflush diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 83aea3dcf..f79992460 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -9,8 +9,8 @@ NOT_IN_CODE_OR_LINKS = '(?!([^<]*<\/(code|pre|a)>|[^`\n]*`|(.|\n)*```))' valid_username_regex = re.compile("^[\w\-]{3,25}$", flags=re.A) -mention_regex = re.compile('(?)!(everyone)' + NOT_IN_CODE_OR_LINKS, flags=re.A) @@ -32,9 +32,9 @@ valid_sub_regex = re.compile("^[\w\-]{3,25}$", flags=re.A) query_regex = re.compile("(\w+):(\S+)", flags=re.A) -poll_regex = re.compile("(^|\n)\$\$([^\$\n]+)\$\$\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) -bet_regex = re.compile("(^|\n)##([^#\n]+)##\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) -choice_regex = re.compile("(^|\n)&&([^&\n]+)&&\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) +poll_regex = re.compile("(^|\n|>)\$\$([^\$\n]+)\$\$\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) +bet_regex = re.compile("(^|\n|>)##([^#\n]+)##\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) +choice_regex = re.compile("(^|\n|>)&&([^&\n]+)&&\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A) html_comment_regex = re.compile("", flags=re.A)