diff --git a/content.py b/content.py index 0d6d655f6..e39befba9 100644 --- a/content.py +++ b/content.py @@ -355,11 +355,23 @@ def addMention(wordStr: str, httpPrefix: str, following: str, return True +def replaceContentDuplicates(content: str) -> str: + """Replaces invalid duplicates within content + """ + while '<<' in content: + content = content.replace('<<', '<') + while '>>' in content: + content = content.replace('>>', '>') + content = content.replace('<\p>', '') + return content + + def removeLongWords(content: str, maxWordLength: int, longWordsList: []) -> str: """Breaks up long words so that on mobile screens this doesn't disrupt the layout """ + content = replaceContentDuplicates(content) if ' ' not in content: # handle a single very long string with no spaces contentStr = content.replace('
', '').replace(r'<\p>', '') diff --git a/tests.py b/tests.py index 8c1025411..3a7ca39f7 100644 --- a/tests.py +++ b/tests.py @@ -66,6 +66,7 @@ from content import addWebLinks from content import replaceEmojiFromTags from content import addHtmlTags from content import removeLongWords +from content import replaceContentDuplicates from theme import setCSSparam testServerAliceRunning = False @@ -1641,6 +1642,15 @@ def testWebLinks(): assert resultText == exampleText assert 'ellipsis' not in resultText + exampleText = \ + '
filepopout=' + \ + 'TemplateAttachmentRichPopout<<\p>' + resultText = replaceContentDuplicates(exampleText) + print(resultText) + assert resultText == \ + '
filepopout=' + \ + 'TemplateAttachmentRichPopout' + def testAddEmoji(): print('testAddEmoji')