forked from indymedia/epicyon
Don't replace emoji within json content
parent
ded29f2527
commit
14d7e2e2b2
|
@ -254,7 +254,7 @@ def removeLongWords(content: str,maxWordLength: int,longWordsList: []) -> str:
|
|||
|
||||
def addHtmlTags(baseDir: str,httpPrefix: str, \
|
||||
nickname: str,domain: str,content: str, \
|
||||
recipients: [],hashtags: {}) -> str:
|
||||
recipients: [],hashtags: {},isJsonContent=False) -> str:
|
||||
""" Replaces plaintext mentions such as @nick@domain into html
|
||||
by matching against known following accounts
|
||||
"""
|
||||
|
@ -340,9 +340,10 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \
|
|||
content=content.replace(wordStr,replaceStr)
|
||||
for wordStr,replaceStr in replaceHashTags.items():
|
||||
content=content.replace(wordStr,replaceStr)
|
||||
for wordStr,replaceStr in replaceEmoji.items():
|
||||
content=content.replace(wordStr,replaceStr)
|
||||
|
||||
if not isJsonContent:
|
||||
for wordStr,replaceStr in replaceEmoji.items():
|
||||
content=content.replace(wordStr,replaceStr)
|
||||
|
||||
content=addWebLinks(content)
|
||||
if longWordsList:
|
||||
content=removeLongWords(content,maxWordLength,longWordsList)
|
||||
|
|
2
posts.py
2
posts.py
|
@ -483,7 +483,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
|||
addHtmlTags(baseDir,httpPrefix, \
|
||||
nickname,domain,content, \
|
||||
mentionedRecipients, \
|
||||
hashtagsDict)
|
||||
hashtagsDict,True)
|
||||
|
||||
statusNumber,published = getStatusNumber()
|
||||
postTo='https://www.w3.org/ns/activitystreams#Public'
|
||||
|
|
4
tests.py
4
tests.py
|
@ -1559,13 +1559,15 @@ def testAddEmoji():
|
|||
contentModified= \
|
||||
addHtmlTags(baseDir,httpPrefix, \
|
||||
nickname,domain,content, \
|
||||
recipients,hashtags)
|
||||
recipients,hashtags,True)
|
||||
assert ':lemon:' in contentModified
|
||||
tags=[]
|
||||
for tagName,tag in hashtags.items():
|
||||
tags.append(tag)
|
||||
content=contentModified
|
||||
contentModified=replaceEmojiFromTags(content,tags,'content')
|
||||
assert 'img src' in contentModified
|
||||
assert ':lemon:' not in contentModified
|
||||
|
||||
os.chdir(baseDirOriginal)
|
||||
shutil.rmtree(baseDirOriginal+'/.tests')
|
||||
|
|
Loading…
Reference in New Issue