Avoid matching hashtags with contains operator

merge-requests/8/head
Bob Mottram 2020-10-25 12:15:41 +00:00
parent 15cf3f9ee0
commit 8aecc5827b
1 changed files with 6 additions and 2 deletions

View File

@ -95,13 +95,17 @@ def hashtagRuleResolve(tree: [], hashtags: [], moderated: bool,
if matchStr.startswith('"') and matchStr.endswith('"'):
matchStr = matchStr[1:]
matchStr = matchStr[:len(matchStr) - 1]
return matchStr.lower() in content
matchStrLower = matchStr.lower()
contentWithoutTags = content.replace('#' + matchStrLower, '')
return matchStrLower in contentWithoutTags
elif isinstance(tree[1], list):
matchStr = tree[1][0]
if matchStr.startswith('"') and matchStr.endswith('"'):
matchStr = matchStr[1:]
matchStr = matchStr[:len(matchStr) - 1]
return matchStr.lower() in content
matchStrLower = matchStr.lower()
contentWithoutTags = content.replace('#' + matchStrLower, '')
return matchStrLower in contentWithoutTags
elif tree[0] == 'from':
if len(tree) == 2:
if isinstance(tree[1], str):