diff --git a/content.py b/content.py index 5b6b4c2f8..f3c732e6f 100644 --- a/content.py +++ b/content.py @@ -198,8 +198,16 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r replaceMentions[wordStr]="@"+possibleNickname+"" return True return False + possibleNickname=None + possibleDomain=None + if '@' not in possibleHandle: + return False possibleNickname=possibleHandle.split('@')[0] + if not possibleNickname: + return False possibleDomain=possibleHandle.split('@')[1].strip('\n') + if not possibleDomain: + return False if following: for follow in following: if follow.replace('\n','')!=possibleHandle: @@ -215,20 +223,18 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r replaceMentions[wordStr]="@"+possibleNickname+"" return True # @nick@domain - if '@' in possibleHandle: - if not (possibleDomain=='localhost' or '.' in possibleDomain): - return False - recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname - if recipientActor not in recipients: - recipients.append(recipientActor) - tags[wordStr]={ - 'href': recipientActor, - 'name': wordStr, - 'type': 'Mention' - } - replaceMentions[wordStr]="@"+possibleNickname+"" - return True - return False + if not (possibleDomain=='localhost' or '.' in possibleDomain): + return False + recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname + if recipientActor not in recipients: + recipients.append(recipientActor) + tags[wordStr]={ + 'href': recipientActor, + 'name': wordStr, + 'type': 'Mention' + } + replaceMentions[wordStr]="@"+possibleNickname+"" + return True def removeLongWords(content: str,maxWordLength: int,longWordsList: []) -> str: """Breaks up long words so that on mobile screens this doesn't disrupt the layout