forked from indymedia/epicyon
Extra checks for bad content format
parent
b0bfb96a49
commit
315afa4bd8
12
content.py
12
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('<p>', '').replace(r'<\p>', '')
|
||||
|
|
10
tests.py
10
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 = \
|
||||
'<p>filepopout=' + \
|
||||
'TemplateAttachmentRichPopout<<\p>'
|
||||
resultText = replaceContentDuplicates(exampleText)
|
||||
print(resultText)
|
||||
assert resultText == \
|
||||
'<p>filepopout=' + \
|
||||
'TemplateAttachmentRichPopout'
|
||||
|
||||
|
||||
def testAddEmoji():
|
||||
print('testAddEmoji')
|
||||
|
|
Loading…
Reference in New Issue