forked from indymedia/epicyon
Remove carriage returns
parent
48f6bbf482
commit
e75f1a0abb
15
auth.py
15
auth.py
|
@ -40,7 +40,10 @@ def verifyPassword(storedPassword: str, providedPassword: str) -> bool:
|
||||||
def createBasicAuthHeader(nickname: str, password: str) -> str:
|
def createBasicAuthHeader(nickname: str, password: str) -> str:
|
||||||
"""This is only used by tests
|
"""This is only used by tests
|
||||||
"""
|
"""
|
||||||
authStr = nickname.replace('\n', '') + ':' + password.replace('\n', '')
|
authStr = \
|
||||||
|
nickname.replace('\n', '').replace('\r', '') + \
|
||||||
|
':' + \
|
||||||
|
password.replace('\n', '').replace('\r', '')
|
||||||
return 'Basic ' + base64.b64encode(authStr.encode('utf-8')).decode('utf-8')
|
return 'Basic ' + base64.b64encode(authStr.encode('utf-8')).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +68,8 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
||||||
print('DEBUG: This is not a users endpoint')
|
print('DEBUG: This is not a users endpoint')
|
||||||
return False
|
return False
|
||||||
nicknameFromPath = pathUsersSection.split('/')[0]
|
nicknameFromPath = pathUsersSection.split('/')[0]
|
||||||
base64Str = authHeader.split(' ')[1].replace('\n', '')
|
base64Str = \
|
||||||
|
authHeader.split(' ')[1].replace('\n', '').replace('\r', '')
|
||||||
plain = base64.b64decode(base64Str).decode('utf-8')
|
plain = base64.b64decode(base64Str).decode('utf-8')
|
||||||
if ':' not in plain:
|
if ':' not in plain:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -88,7 +92,8 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
||||||
passfile = open(passwordFile, "r")
|
passfile = open(passwordFile, "r")
|
||||||
for line in passfile:
|
for line in passfile:
|
||||||
if line.startswith(nickname+':'):
|
if line.startswith(nickname+':'):
|
||||||
storedPassword = line.split(':')[1].replace('\n', '')
|
storedPassword = \
|
||||||
|
line.split(':')[1].replace('\n', '').replace('\r', '')
|
||||||
success = verifyPassword(storedPassword, providedPassword)
|
success = verifyPassword(storedPassword, providedPassword)
|
||||||
if not success:
|
if not success:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -104,8 +109,8 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
"""
|
"""
|
||||||
if ':' in nickname or ':' in password:
|
if ':' in nickname or ':' in password:
|
||||||
return False
|
return False
|
||||||
nickname = nickname.replace('\n', '').strip()
|
nickname = nickname.replace('\n', '').replace('\r', '').strip()
|
||||||
password = password.replace('\n', '').strip()
|
password = password.replace('\n', '').replace('\r', '').strip()
|
||||||
|
|
||||||
if not os.path.isdir(baseDir + '/accounts'):
|
if not os.path.isdir(baseDir + '/accounts'):
|
||||||
os.mkdir(baseDir + '/accounts')
|
os.mkdir(baseDir + '/accounts')
|
||||||
|
|
|
@ -69,7 +69,7 @@ def removeGlobalBlock(baseDir: str,
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w') as fpnew:
|
with open(unblockingFilename + '.new', 'w') as fpnew:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
handle = line.replace('\n', '')
|
handle = line.replace('\n', '').replace('\r', '')
|
||||||
if unblockHandle not in line:
|
if unblockHandle not in line:
|
||||||
fpnew.write(handle + '\n')
|
fpnew.write(handle + '\n')
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -82,7 +82,8 @@ def removeGlobalBlock(baseDir: str,
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w') as fpnew:
|
with open(unblockingFilename + '.new', 'w') as fpnew:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
blockLine = line.replace('\n', '')
|
blockLine = \
|
||||||
|
line.replace('\n', '').replace('\r', '')
|
||||||
if unblockHashtag not in line:
|
if unblockHashtag not in line:
|
||||||
fpnew.write(blockLine + '\n')
|
fpnew.write(blockLine + '\n')
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -105,7 +106,7 @@ def removeBlock(baseDir: str, nickname: str, domain: str,
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w') as fpnew:
|
with open(unblockingFilename + '.new', 'w') as fpnew:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
handle = line.replace('\n', '')
|
handle = line.replace('\n', '').replace('\r', '')
|
||||||
if unblockHandle not in line:
|
if unblockHandle not in line:
|
||||||
fpnew.write(handle + '\n')
|
fpnew.write(handle + '\n')
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -119,7 +120,7 @@ def isBlockedHashtag(baseDir: str, hashtag: str) -> bool:
|
||||||
"""
|
"""
|
||||||
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
globalBlockingFilename = baseDir + '/accounts/blocking.txt'
|
||||||
if os.path.isfile(globalBlockingFilename):
|
if os.path.isfile(globalBlockingFilename):
|
||||||
hashtag = hashtag.strip('\n')
|
hashtag = hashtag.strip('\n').strip('\r')
|
||||||
if hashtag + '\n' in open(globalBlockingFilename).read():
|
if hashtag + '\n' in open(globalBlockingFilename).read():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
16
blog.py
16
blog.py
|
@ -59,7 +59,8 @@ def noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
with open(postFilename, "r") as f:
|
with open(postFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for replyPostId in lines:
|
for replyPostId in lines:
|
||||||
replyPostId = replyPostId.replace('\n', '').replace('.json', '')
|
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||||
|
replyPostId = replyPostId.replace('.json', '')
|
||||||
if locatePost(baseDir, nickname, domain, replyPostId):
|
if locatePost(baseDir, nickname, domain, replyPostId):
|
||||||
replyPostId = replyPostId.replace('.replies', '')
|
replyPostId = replyPostId.replace('.replies', '')
|
||||||
replies += 1 + noOfBlogReplies(baseDir, httpPrefix, translate,
|
replies += 1 + noOfBlogReplies(baseDir, httpPrefix, translate,
|
||||||
|
@ -75,7 +76,7 @@ def noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
str(len(removals)) + ' entries')
|
str(len(removals)) + ' entries')
|
||||||
with open(postFilename, "w") as f:
|
with open(postFilename, "w") as f:
|
||||||
for replyPostId in lines:
|
for replyPostId in lines:
|
||||||
replyPostId = replyPostId.replace('\n', '')
|
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||||
if replyPostId not in removals:
|
if replyPostId not in removals:
|
||||||
f.write(replyPostId + '\n')
|
f.write(replyPostId + '\n')
|
||||||
|
|
||||||
|
@ -121,12 +122,13 @@ def getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
repliesStr = ''
|
repliesStr = ''
|
||||||
for replyPostId in lines:
|
for replyPostId in lines:
|
||||||
replyPostId = replyPostId.replace('\n', '').replace('.json', '')
|
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||||
|
replyPostId = replyPostId.replace('.json', '')
|
||||||
replyPostId = replyPostId.replace('.replies', '')
|
replyPostId = replyPostId.replace('.replies', '')
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + \
|
nickname + '@' + domain + \
|
||||||
'/postcache/' + \
|
'/postcache/' + \
|
||||||
replyPostId.replace('\n', '').replace('/', '#') + '.html'
|
replyPostId.replace('/', '#') + '.html'
|
||||||
if not os.path.isfile(postFilename):
|
if not os.path.isfile(postFilename):
|
||||||
continue
|
continue
|
||||||
with open(postFilename, "r") as postFile:
|
with open(postFilename, "r") as postFile:
|
||||||
|
@ -334,7 +336,8 @@ def htmlBlogPage(authorized: bool, session,
|
||||||
noOfItems: int, pageNumber: int) -> str:
|
noOfItems: int, pageNumber: int) -> str:
|
||||||
"""Returns a html blog page containing posts
|
"""Returns a html blog page containing posts
|
||||||
"""
|
"""
|
||||||
if ' ' in nickname or '@' in nickname or '\n' in nickname:
|
if ' ' in nickname or '@' in nickname or \
|
||||||
|
'\n' in nickname or '\r' in nickname:
|
||||||
return None
|
return None
|
||||||
blogStr = ''
|
blogStr = ''
|
||||||
|
|
||||||
|
@ -436,7 +439,8 @@ def htmlBlogPageRSS(authorized: bool, session,
|
||||||
noOfItems: int, pageNumber: int) -> str:
|
noOfItems: int, pageNumber: int) -> str:
|
||||||
"""Returns an rss feed containing posts
|
"""Returns an rss feed containing posts
|
||||||
"""
|
"""
|
||||||
if ' ' in nickname or '@' in nickname or '\n' in nickname:
|
if ' ' in nickname or '@' in nickname or \
|
||||||
|
'\n' in nickname or '\r' in nickname:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
domainFull = domain
|
domainFull = domain
|
||||||
|
|
|
@ -51,7 +51,7 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
bookmarkIndex = postFilename.split('/')[-1].strip()
|
bookmarkIndex = postFilename.split('/')[-1].strip()
|
||||||
else:
|
else:
|
||||||
bookmarkIndex = postFilename.strip()
|
bookmarkIndex = postFilename.strip()
|
||||||
bookmarkIndex = bookmarkIndex.replace('\n', '')
|
bookmarkIndex = bookmarkIndex.replace('\n', '').replace('\r', '')
|
||||||
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
||||||
return
|
return
|
||||||
indexStr = ''
|
indexStr = ''
|
||||||
|
|
15
content.py
15
content.py
|
@ -22,7 +22,7 @@ def switchWords(baseDir: str, nickname: str, domain: str, content: str) -> str:
|
||||||
return content
|
return content
|
||||||
with open(switchWordsFilename, 'r') as fp:
|
with open(switchWordsFilename, 'r') as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
replaceStr = line.replace('\n', '')
|
replaceStr = line.replace('\n', '').replace('\r', '')
|
||||||
wordTransform = None
|
wordTransform = None
|
||||||
if '->' in replaceStr:
|
if '->' in replaceStr:
|
||||||
wordTransform = replaceStr.split('->')
|
wordTransform = replaceStr.split('->')
|
||||||
|
@ -130,6 +130,7 @@ def addWebLinks(content: str) -> str:
|
||||||
return content
|
return content
|
||||||
|
|
||||||
maxLinkLength = 40
|
maxLinkLength = 40
|
||||||
|
content = content.replace('\r', '')
|
||||||
words = content.replace('\n', ' --linebreak-- ').split(' ')
|
words = content.replace('\n', ' --linebreak-- ').split(' ')
|
||||||
replaceDict = {}
|
replaceDict = {}
|
||||||
for w in words:
|
for w in words:
|
||||||
|
@ -231,7 +232,8 @@ def loadEmojiDict(emojiDataFilename: str, emojiDict: {}) -> None:
|
||||||
continue
|
continue
|
||||||
if '..' in emojiUnicode:
|
if '..' in emojiUnicode:
|
||||||
emojiUnicode = emojiUnicode.split('..')[0]
|
emojiUnicode = emojiUnicode.split('..')[0]
|
||||||
emojiName = line.split(')', 1)[1].strip().replace('\n', '')
|
emojiName = line.split(')', 1)[1].strip()
|
||||||
|
emojiName = emojiName.replace('\n', '').replace('\r', '')
|
||||||
emojiName = emojiName.replace(' ', '').replace('-', '')
|
emojiName = emojiName.replace(' ', '').replace('-', '')
|
||||||
if '..' in emojiName:
|
if '..' in emojiName:
|
||||||
emojiName = emojiName.split('..')[0]
|
emojiName = emojiName.split('..')[0]
|
||||||
|
@ -293,7 +295,8 @@ def addMention(wordStr: str, httpPrefix: str, following: str,
|
||||||
possibleNickname = possibleHandle
|
possibleNickname = possibleHandle
|
||||||
for follow in following:
|
for follow in following:
|
||||||
if follow.startswith(possibleNickname + '@'):
|
if follow.startswith(possibleNickname + '@'):
|
||||||
replaceDomain = follow.replace('\n', '').split('@')[1]
|
replaceDomain = \
|
||||||
|
follow.replace('\n', '').replace('\r', '').split('@')[1]
|
||||||
recipientActor = httpPrefix + "://" + \
|
recipientActor = httpPrefix + "://" + \
|
||||||
replaceDomain + "/users/" + possibleNickname
|
replaceDomain + "/users/" + possibleNickname
|
||||||
if recipientActor not in recipients:
|
if recipientActor not in recipients:
|
||||||
|
@ -317,12 +320,13 @@ def addMention(wordStr: str, httpPrefix: str, following: str,
|
||||||
possibleNickname = possibleHandle.split('@')[0]
|
possibleNickname = possibleHandle.split('@')[0]
|
||||||
if not possibleNickname:
|
if not possibleNickname:
|
||||||
return False
|
return False
|
||||||
possibleDomain = possibleHandle.split('@')[1].strip('\n')
|
possibleDomain = \
|
||||||
|
possibleHandle.split('@')[1].strip('\n').strip('\r')
|
||||||
if not possibleDomain:
|
if not possibleDomain:
|
||||||
return False
|
return False
|
||||||
if following:
|
if following:
|
||||||
for follow in following:
|
for follow in following:
|
||||||
if follow.replace('\n', '') != possibleHandle:
|
if follow.replace('\n', '').replace('\r', '') != possibleHandle:
|
||||||
continue
|
continue
|
||||||
recipientActor = httpPrefix + "://" + \
|
recipientActor = httpPrefix + "://" + \
|
||||||
possibleDomain + "/users/" + possibleNickname
|
possibleDomain + "/users/" + possibleNickname
|
||||||
|
@ -451,6 +455,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
||||||
if content.startswith('<p>'):
|
if content.startswith('<p>'):
|
||||||
return content
|
return content
|
||||||
maxWordLength = 40
|
maxWordLength = 40
|
||||||
|
content = content.replace('\r', '')
|
||||||
content = content.replace('\n', ' --linebreak-- ')
|
content = content.replace('\n', ' --linebreak-- ')
|
||||||
content = addMusicTag(content, 'nowplaying')
|
content = addMusicTag(content, 'nowplaying')
|
||||||
words = content.replace(',', ' ').replace(';', ' ').split(' ')
|
words = content.replace(',', ' ').replace(';', ' ').split(' ')
|
||||||
|
|
|
@ -6023,6 +6023,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
searchStr = searchStr.replace('+', ' ')
|
searchStr = searchStr.replace('+', ' ')
|
||||||
searchStr = \
|
searchStr = \
|
||||||
urllib.parse.unquote(searchStr.strip())
|
urllib.parse.unquote(searchStr.strip())
|
||||||
|
searchStr2 = searchStr.lower().strip('\n').strip('\r')
|
||||||
print('searchStr: ' + searchStr)
|
print('searchStr: ' + searchStr)
|
||||||
if searchForEmoji:
|
if searchForEmoji:
|
||||||
searchStr = ':' + searchStr + ':'
|
searchStr = ':' + searchStr + ':'
|
||||||
|
@ -6135,11 +6136,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
elif (searchStr.startswith(':') or
|
elif (searchStr.startswith(':') or
|
||||||
searchStr.lower().strip('\n').endswith(' emoji')):
|
searchStr2.endswith(' emoji')):
|
||||||
# eg. "cat emoji"
|
# eg. "cat emoji"
|
||||||
if searchStr.lower().strip('\n').endswith(' emoji'):
|
if searchStr2.endswith(' emoji'):
|
||||||
searchStr = \
|
searchStr = \
|
||||||
searchStr.lower().strip('\n').replace(' emoji', '')
|
searchStr2.replace(' emoji', '')
|
||||||
# emoji search
|
# emoji search
|
||||||
emojiStr = \
|
emojiStr = \
|
||||||
htmlSearchEmoji(self.server.translate,
|
htmlSearchEmoji(self.server.translate,
|
||||||
|
|
23
epicyon.py
23
epicyon.py
|
@ -628,7 +628,7 @@ if args.followerspending:
|
||||||
if os.path.isfile(approveFollowsFilename):
|
if os.path.isfile(approveFollowsFilename):
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for approve in approvefile:
|
for approve in approvefile:
|
||||||
print(approve.replace('\n', ''))
|
print(approve.replace('\n', '').replace('\r', ''))
|
||||||
approveCtr += 1
|
approveCtr += 1
|
||||||
if approveCtr == 0:
|
if approveCtr == 0:
|
||||||
print('There are no follow requests pending approval.')
|
print('There are no follow requests pending approval.')
|
||||||
|
@ -657,7 +657,8 @@ if args.message:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if '@' in args.sendto:
|
if '@' in args.sendto:
|
||||||
toNickname = args.sendto.split('@')[0]
|
toNickname = args.sendto.split('@')[0]
|
||||||
toDomain = args.sendto.split('@')[1].replace('\n', '')
|
toDomain = args.sendto.split('@')[1]
|
||||||
|
toDomain = toDomain.replace('\n', '').replace('\r', '')
|
||||||
toPort = 443
|
toPort = 443
|
||||||
if ':' in toDomain:
|
if ':' in toDomain:
|
||||||
toPort = toDomain.split(':')[1]
|
toPort = toDomain.split(':')[1]
|
||||||
|
@ -1005,13 +1006,16 @@ if args.actor:
|
||||||
'https://domain/@nick or https://domain/users/nick')
|
'https://domain/@nick or https://domain/users/nick')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if '/users/' in args.actor:
|
if '/users/' in args.actor:
|
||||||
nickname = args.actor.split('/users/')[1].replace('\n', '')
|
nickname = args.actor.split('/users/')[1]
|
||||||
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = args.actor.split('/users/')[0]
|
domain = args.actor.split('/users/')[0]
|
||||||
elif '/profile/' in args.actor:
|
elif '/profile/' in args.actor:
|
||||||
nickname = args.actor.split('/profile/')[1].replace('\n', '')
|
nickname = args.actor.split('/profile/')[1]
|
||||||
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = args.actor.split('/profile/')[0]
|
domain = args.actor.split('/profile/')[0]
|
||||||
else:
|
else:
|
||||||
nickname = args.actor.split('/channel/')[1].replace('\n', '')
|
nickname = args.actor.split('/channel/')[1]
|
||||||
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = args.actor.split('/channel/')[0]
|
domain = args.actor.split('/channel/')[0]
|
||||||
else:
|
else:
|
||||||
# format: @nick@domain
|
# format: @nick@domain
|
||||||
|
@ -1024,7 +1028,8 @@ if args.actor:
|
||||||
print('Syntax: --actor nickname@domain')
|
print('Syntax: --actor nickname@domain')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
nickname = args.actor.split('@')[0]
|
nickname = args.actor.split('@')[0]
|
||||||
domain = args.actor.split('@')[1].replace('\n', '')
|
domain = args.actor.split('@')[1]
|
||||||
|
domain = domain.replace('\n', '').replace('\r', '')
|
||||||
cachedWebfingers = {}
|
cachedWebfingers = {}
|
||||||
if args.http or domain.endswith('.onion'):
|
if args.http or domain.endswith('.onion'):
|
||||||
httpPrefix = 'http'
|
httpPrefix = 'http'
|
||||||
|
@ -1379,7 +1384,8 @@ if args.block:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if '@' in args.block:
|
if '@' in args.block:
|
||||||
blockedDomain = args.block.split('@')[1].replace('\n', '')
|
blockedDomain = args.block.split('@')[1]
|
||||||
|
blockedDomain = blockedDomain.replace('\n', '').replace('\r', '')
|
||||||
blockedNickname = args.block.split('@')[0]
|
blockedNickname = args.block.split('@')[0]
|
||||||
blockedActor = httpPrefix + '://' + blockedDomain + \
|
blockedActor = httpPrefix + '://' + blockedDomain + \
|
||||||
'/users/' + blockedNickname
|
'/users/' + blockedNickname
|
||||||
|
@ -1488,7 +1494,8 @@ if args.unblock:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if '@' in args.unblock:
|
if '@' in args.unblock:
|
||||||
blockedDomain = args.unblock.split('@')[1].replace('\n', '')
|
blockedDomain = args.unblock.split('@')[1]
|
||||||
|
blockedDomain = blockedDomain.replace('\n', '').replace('\r', '')
|
||||||
blockedNickname = args.unblock.split('@')[0]
|
blockedNickname = args.unblock.split('@')[0]
|
||||||
blockedActor = httpPrefix + '://' + blockedDomain + \
|
blockedActor = httpPrefix + '://' + blockedDomain + \
|
||||||
'/users/' + blockedNickname
|
'/users/' + blockedNickname
|
||||||
|
|
|
@ -71,7 +71,7 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
with open(filtersFilename, 'r') as fp:
|
with open(filtersFilename, 'r') as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
filterStr = line.replace('\n', '')
|
filterStr = line.replace('\n', '').replace('\r', '')
|
||||||
if '+' not in filterStr:
|
if '+' not in filterStr:
|
||||||
if filterStr in content:
|
if filterStr in content:
|
||||||
return True
|
return True
|
||||||
|
|
15
follow.py
15
follow.py
|
@ -149,7 +149,9 @@ def getFollowersOfPerson(baseDir: str,
|
||||||
continue
|
continue
|
||||||
with open(filename, 'r') as followingfile:
|
with open(filename, 'r') as followingfile:
|
||||||
for followingHandle in followingfile:
|
for followingHandle in followingfile:
|
||||||
if followingHandle.replace('\n', '') == handle:
|
followingHandle2 = followingHandle.replace('\n', '')
|
||||||
|
followingHandle2 = followingHandle2.replace('\r', '')
|
||||||
|
if followingHandle2 == handle:
|
||||||
if account not in followers:
|
if account not in followers:
|
||||||
followers.append(account)
|
followers.append(account)
|
||||||
break
|
break
|
||||||
|
@ -209,7 +211,7 @@ def unfollowPerson(baseDir: str, nickname: str, domain: str,
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.strip("\n") != handleToUnfollow:
|
if line.strip("\n").strip("\r") != handleToUnfollow:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
# write to an unfollowed file so that if a follow accept
|
# write to an unfollowed file so that if a follow accept
|
||||||
|
@ -389,17 +391,20 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
|
||||||
pageCtr += 1
|
pageCtr += 1
|
||||||
totalCtr += 1
|
totalCtr += 1
|
||||||
if currPage == pageNumber:
|
if currPage == pageNumber:
|
||||||
|
line2 = \
|
||||||
|
line.lower().replace('\n', '').replace('\r', '')
|
||||||
url = httpPrefix + '://' + \
|
url = httpPrefix + '://' + \
|
||||||
line.lower().replace('\n', '').split('@')[1] + \
|
line2.split('@')[1] + \
|
||||||
'/users/' + \
|
'/users/' + \
|
||||||
line.lower().replace('\n', '').split('@')[0]
|
line2.split('@')[0]
|
||||||
following['orderedItems'].append(url)
|
following['orderedItems'].append(url)
|
||||||
elif ((line.startswith('http') or
|
elif ((line.startswith('http') or
|
||||||
line.startswith('dat')) and '/users/' in line):
|
line.startswith('dat')) and '/users/' in line):
|
||||||
pageCtr += 1
|
pageCtr += 1
|
||||||
totalCtr += 1
|
totalCtr += 1
|
||||||
if currPage == pageNumber:
|
if currPage == pageNumber:
|
||||||
appendStr = line.lower().replace('\n', '')
|
appendStr = \
|
||||||
|
line.lower().replace('\n', '').replace('\r', '')
|
||||||
following['orderedItems'].append(appendStr)
|
following['orderedItems'].append(appendStr)
|
||||||
if pageCtr >= followsPerPage:
|
if pageCtr >= followsPerPage:
|
||||||
pageCtr = 0
|
pageCtr = 0
|
||||||
|
|
10
happening.py
10
happening.py
|
@ -70,7 +70,7 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
recreateEventsFile = False
|
recreateEventsFile = False
|
||||||
with open(calendarFilename, 'r') as eventsFile:
|
with open(calendarFilename, 'r') as eventsFile:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId = postId.replace('\n', '')
|
postId = postId.replace('\n', '').replace('\r', '')
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
|
@ -138,7 +138,7 @@ def todaysEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
eventsExist = False
|
eventsExist = False
|
||||||
with open(calendarFilename, 'r') as eventsFile:
|
with open(calendarFilename, 'r') as eventsFile:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId = postId.replace('\n', '')
|
postId = postId.replace('\n', '').replace('\r', '')
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
continue
|
continue
|
||||||
|
@ -185,7 +185,7 @@ def thisWeeksEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
eventsExist = False
|
eventsExist = False
|
||||||
with open(calendarFilename, 'r') as eventsFile:
|
with open(calendarFilename, 'r') as eventsFile:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId = postId.replace('\n', '')
|
postId = postId.replace('\n', '').replace('\r', '')
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
continue
|
continue
|
||||||
|
@ -239,7 +239,7 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
recreateEventsFile = False
|
recreateEventsFile = False
|
||||||
with open(calendarFilename, 'r') as eventsFile:
|
with open(calendarFilename, 'r') as eventsFile:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId = postId.replace('\n', '')
|
postId = postId.replace('\n', '').replace('\r', '')
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
|
@ -324,7 +324,7 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
recreateEventsFile = False
|
recreateEventsFile = False
|
||||||
with open(calendarFilename, 'r') as eventsFile:
|
with open(calendarFilename, 'r') as eventsFile:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId = postId.replace('\n', '')
|
postId = postId.replace('\n', '').replace('\r', '')
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
|
|
|
@ -45,7 +45,8 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
rejectsFile.close()
|
rejectsFile.close()
|
||||||
|
|
||||||
denyNickname = denyHandle.split('@')[0]
|
denyNickname = denyHandle.split('@')[0]
|
||||||
denyDomain = denyHandle.split('@')[1].replace('\n', '')
|
denyDomain = \
|
||||||
|
denyHandle.split('@')[1].replace('\n', '').replace('\r', '')
|
||||||
denyPort = port
|
denyPort = port
|
||||||
if ':' in denyDomain:
|
if ':' in denyDomain:
|
||||||
denyPort = denyDomain.split(':')[1]
|
denyPort = denyDomain.split(':')[1]
|
||||||
|
@ -112,7 +113,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
# is this the approved follow?
|
# is this the approved follow?
|
||||||
if handleOfFollowRequester.startswith(approveHandle):
|
if handleOfFollowRequester.startswith(approveHandle):
|
||||||
handleOfFollowRequester = \
|
handleOfFollowRequester = \
|
||||||
handleOfFollowRequester.replace('\n', '')
|
handleOfFollowRequester.replace('\n', '').replace('\r', '')
|
||||||
port2 = port
|
port2 = port
|
||||||
if ':' in handleOfFollowRequester:
|
if ':' in handleOfFollowRequester:
|
||||||
port2Str = handleOfFollowRequester.split(':')[1]
|
port2Str = handleOfFollowRequester.split(':')[1]
|
||||||
|
@ -125,8 +126,9 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
followJson = loadJson(followActivityfilename)
|
followJson = loadJson(followActivityfilename)
|
||||||
if followJson:
|
if followJson:
|
||||||
approveNickname = approveHandle.split('@')[0]
|
approveNickname = approveHandle.split('@')[0]
|
||||||
|
approveDomain = approveHandle.split('@')[1]
|
||||||
approveDomain = \
|
approveDomain = \
|
||||||
approveHandle.split('@')[1].replace('\n', '')
|
approveDomain.replace('\n', '').replace('\r', '')
|
||||||
approvePort = port2
|
approvePort = port2
|
||||||
if ':' in approveDomain:
|
if ':' in approveDomain:
|
||||||
approvePort = approveDomain.split(':')[1]
|
approvePort = approveDomain.split(':')[1]
|
||||||
|
|
13
person.py
13
person.py
|
@ -52,7 +52,7 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
|
||||||
"""Saves the given image file as an avatar or background
|
"""Saves the given image file as an avatar or background
|
||||||
image for the given person
|
image for the given person
|
||||||
"""
|
"""
|
||||||
imageFilename = imageFilename.replace('\n', '')
|
imageFilename = imageFilename.replace('\n', '').replace('\r', '')
|
||||||
if not (imageFilename.endswith('.png') or
|
if not (imageFilename.endswith('.png') or
|
||||||
imageFilename.endswith('.jpg') or
|
imageFilename.endswith('.jpg') or
|
||||||
imageFilename.endswith('.jpeg') or
|
imageFilename.endswith('.jpeg') or
|
||||||
|
@ -712,7 +712,7 @@ def isSuspended(baseDir: str, nickname: str) -> bool:
|
||||||
with open(suspendedFilename, "r") as f:
|
with open(suspendedFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n') == nickname:
|
if suspended.strip('\n').strip('\r') == nickname:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ def unsuspendAccount(baseDir: str, nickname: str) -> None:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
suspendedFile = open(suspendedFilename, "w+")
|
suspendedFile = open(suspendedFilename, "w+")
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n') != nickname:
|
if suspended.strip('\n').strip('\r') != nickname:
|
||||||
suspendedFile.write(suspended)
|
suspendedFile.write(suspended)
|
||||||
suspendedFile.close()
|
suspendedFile.close()
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
with open(moderatorsFile, "r") as f:
|
with open(moderatorsFile, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
if moderator.strip('\n') == nickname:
|
if moderator.strip('\n').strip('\r') == nickname:
|
||||||
return
|
return
|
||||||
|
|
||||||
saltFilename = baseDir + '/accounts/' + \
|
saltFilename = baseDir + '/accounts/' + \
|
||||||
|
@ -762,7 +762,7 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
with open(suspendedFilename, "r") as f:
|
with open(suspendedFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n') == nickname:
|
if suspended.strip('\n').strip('\r') == nickname:
|
||||||
return
|
return
|
||||||
suspendedFile = open(suspendedFilename, 'a+')
|
suspendedFile = open(suspendedFilename, 'a+')
|
||||||
if suspendedFile:
|
if suspendedFile:
|
||||||
|
@ -949,7 +949,8 @@ def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
|
||||||
for line in snoozedFile:
|
for line in snoozedFile:
|
||||||
# is this the entry for the actor?
|
# is this the entry for the actor?
|
||||||
if line.startswith(snoozeActor + ' '):
|
if line.startswith(snoozeActor + ' '):
|
||||||
snoozedTimeStr = line.split(' ')[1].replace('\n', '')
|
snoozedTimeStr = \
|
||||||
|
line.split(' ')[1].replace('\n', '').replace('\r', '')
|
||||||
# is there a time appended?
|
# is there a time appended?
|
||||||
if snoozedTimeStr.isdigit():
|
if snoozedTimeStr.isdigit():
|
||||||
snoozedTime = int(snoozedTimeStr)
|
snoozedTime = int(snoozedTimeStr)
|
||||||
|
|
25
posts.py
25
posts.py
|
@ -73,7 +73,7 @@ def isModerator(baseDir: str, nickname: str) -> bool:
|
||||||
if getConfigParam(baseDir, 'admin') == nickname:
|
if getConfigParam(baseDir, 'admin') == nickname:
|
||||||
return True
|
return True
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if moderator == nickname:
|
if moderator == nickname:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -91,8 +91,9 @@ def noOfFollowersOnDomain(baseDir: str, handle: str,
|
||||||
with open(filename, "r") as followersFilename:
|
with open(filename, "r") as followersFilename:
|
||||||
for followerHandle in followersFilename:
|
for followerHandle in followersFilename:
|
||||||
if '@' in followerHandle:
|
if '@' in followerHandle:
|
||||||
followerDomain = \
|
followerDomain = followerHandle.split('@')[1]
|
||||||
followerHandle.split('@')[1].replace('\n', '')
|
followerDomain = followerDomain.replace('\n', '')
|
||||||
|
followerDomain = followerDomain.replace('\r', '')
|
||||||
if domain == followerDomain:
|
if domain == followerDomain:
|
||||||
ctr += 1
|
ctr += 1
|
||||||
return ctr
|
return ctr
|
||||||
|
@ -1105,7 +1106,7 @@ def getMentionedPeople(baseDir: str, httpPrefix: str,
|
||||||
externalDomain == 'localhost'):
|
externalDomain == 'localhost'):
|
||||||
continue
|
continue
|
||||||
mentionedNickname = handle.split('@')[0]
|
mentionedNickname = handle.split('@')[0]
|
||||||
mentionedDomain = handle.split('@')[1].strip('\n')
|
mentionedDomain = handle.split('@')[1].strip('\n').strip('\r')
|
||||||
if ':' in mentionedDomain:
|
if ':' in mentionedDomain:
|
||||||
mentionedDomain = mentionedDomain.split(':')[0]
|
mentionedDomain = mentionedDomain.split(':')[0]
|
||||||
if not validNickname(mentionedDomain, mentionedNickname):
|
if not validNickname(mentionedDomain, mentionedNickname):
|
||||||
|
@ -1188,7 +1189,7 @@ def createReportPost(baseDir: str,
|
||||||
if os.path.isfile(moderatorsFile):
|
if os.path.isfile(moderatorsFile):
|
||||||
with open(moderatorsFile, "r") as fileHandler:
|
with open(moderatorsFile, "r") as fileHandler:
|
||||||
for line in fileHandler:
|
for line in fileHandler:
|
||||||
line = line.strip('\n')
|
line = line.strip('\n').strip('\r')
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
if line.startswith('/users/'):
|
if line.startswith('/users/'):
|
||||||
|
@ -1569,7 +1570,8 @@ def groupFollowersByDomain(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
with open(followersFilename, "r") as f:
|
with open(followersFilename, "r") as f:
|
||||||
for followerHandle in f:
|
for followerHandle in f:
|
||||||
if '@' in followerHandle:
|
if '@' in followerHandle:
|
||||||
fHandle = followerHandle.strip().replace('\n', '')
|
fHandle = \
|
||||||
|
followerHandle.strip().replace('\n', '').replace('\r', '')
|
||||||
followerDomain = fHandle.split('@')[1]
|
followerDomain = fHandle.split('@')[1]
|
||||||
if not grouped.get(followerDomain):
|
if not grouped.get(followerDomain):
|
||||||
grouped[followerDomain] = [fHandle]
|
grouped[followerDomain] = [fHandle]
|
||||||
|
@ -2221,7 +2223,7 @@ def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
startLineNumber = 0
|
startLineNumber = 0
|
||||||
lineNumber = startLineNumber
|
lineNumber = startLineNumber
|
||||||
while lineNumber >= endLineNumber:
|
while lineNumber >= endLineNumber:
|
||||||
pageLines.append(lines[lineNumber].strip('\n'))
|
pageLines.append(lines[lineNumber].strip('\n').strip('\r'))
|
||||||
lineNumber -= 1
|
lineNumber -= 1
|
||||||
|
|
||||||
for postUrl in pageLines:
|
for postUrl in pageLines:
|
||||||
|
@ -2555,7 +2557,8 @@ def createBoxIndexed(recentPostsCache: {},
|
||||||
# This should also correspond to any index entry in
|
# This should also correspond to any index entry in
|
||||||
# the posts cache
|
# the posts cache
|
||||||
postUrl = \
|
postUrl = \
|
||||||
postFilename.replace('\n', '').replace('.json', '').strip()
|
postFilename.replace('\n', '').replace('\r', '')
|
||||||
|
postUrl = postUrl.replace('.json', '').strip()
|
||||||
|
|
||||||
# is the post cached in memory?
|
# is the post cached in memory?
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
|
@ -2883,12 +2886,13 @@ def populateRepliesJson(baseDir: str, nickname: str, domain: str,
|
||||||
replyFound = False
|
replyFound = False
|
||||||
# examine inbox and outbox
|
# examine inbox and outbox
|
||||||
for boxname in repliesBoxes:
|
for boxname in repliesBoxes:
|
||||||
|
messageId2 = messageId.replace('\n', '').replace('\r', '')
|
||||||
searchFilename = \
|
searchFilename = \
|
||||||
baseDir + \
|
baseDir + \
|
||||||
'/accounts/' + nickname + '@' + \
|
'/accounts/' + nickname + '@' + \
|
||||||
domain+'/' + \
|
domain+'/' + \
|
||||||
boxname+'/' + \
|
boxname+'/' + \
|
||||||
messageId.replace('\n', '').replace('/', '#') + '.json'
|
messageId2.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
if authorized or \
|
if authorized or \
|
||||||
pubStr in open(searchFilename).read():
|
pubStr in open(searchFilename).read():
|
||||||
|
@ -2910,11 +2914,12 @@ def populateRepliesJson(baseDir: str, nickname: str, domain: str,
|
||||||
break
|
break
|
||||||
# if not in either inbox or outbox then examine the shared inbox
|
# if not in either inbox or outbox then examine the shared inbox
|
||||||
if not replyFound:
|
if not replyFound:
|
||||||
|
messageId2 = messageId.replace('\n', '').replace('\r', '')
|
||||||
searchFilename = \
|
searchFilename = \
|
||||||
baseDir + \
|
baseDir + \
|
||||||
'/accounts/inbox@' + \
|
'/accounts/inbox@' + \
|
||||||
domain+'/inbox/' + \
|
domain+'/inbox/' + \
|
||||||
messageId.replace('\n', '').replace('/', '#') + '.json'
|
messageId2.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
if authorized or \
|
if authorized or \
|
||||||
pubStr in open(searchFilename).read():
|
pubStr in open(searchFilename).read():
|
||||||
|
|
6
roles.py
6
roles.py
|
@ -48,13 +48,13 @@ def addModerator(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
with open(moderatorsFile, "r") as f:
|
with open(moderatorsFile, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if moderator == nickname:
|
if moderator == nickname:
|
||||||
return
|
return
|
||||||
lines.append(nickname)
|
lines.append(nickname)
|
||||||
with open(moderatorsFile, "w") as f:
|
with open(moderatorsFile, "w") as f:
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if len(moderator) > 1:
|
if len(moderator) > 1:
|
||||||
if os.path.isdir(baseDir + '/accounts/' +
|
if os.path.isdir(baseDir + '/accounts/' +
|
||||||
moderator + '@' + domain):
|
moderator + '@' + domain):
|
||||||
|
@ -76,7 +76,7 @@ def removeModerator(baseDir: str, nickname: str):
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(moderatorsFile, "w") as f:
|
with open(moderatorsFile, "w") as f:
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if len(moderator) > 1 and moderator != nickname:
|
if len(moderator) > 1 and moderator != nickname:
|
||||||
f.write(moderator + '\n')
|
f.write(moderator + '\n')
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ def updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
dateStr = line.split(' ')[0]
|
dateStr = line.split(' ')[0]
|
||||||
if 'T' not in dateStr:
|
if 'T' not in dateStr:
|
||||||
continue
|
continue
|
||||||
postId = line.split(' ', 1)[1].replace('\n', '')
|
postId = line.split(' ', 1)[1].replace('\n', '').replace('\r', '')
|
||||||
postFilename = scheduleDir + postId + '.json'
|
postFilename = scheduleDir + postId + '.json'
|
||||||
if deleteSchedulePost:
|
if deleteSchedulePost:
|
||||||
# delete extraneous scheduled posts
|
# delete extraneous scheduled posts
|
||||||
|
|
|
@ -26,7 +26,8 @@ def getValidSharedItemID(displayName: str) -> str:
|
||||||
displayName = displayName.replace(' ', '').replace('+', '-')
|
displayName = displayName.replace(' ', '').replace('+', '-')
|
||||||
displayName = displayName.replace('/', '-').replace('\\', '-')
|
displayName = displayName.replace('/', '-').replace('\\', '-')
|
||||||
displayName = displayName.replace('.', '_').replace('?', '-')
|
displayName = displayName.replace('.', '_').replace('?', '-')
|
||||||
displayName = displayName.replace('\n', '').replace("’", "'")
|
displayName = displayName.replace('\n', '').replace('\r', '')
|
||||||
|
displayName = displayName.replace("’", "'")
|
||||||
return displayName.replace('&', '-')
|
return displayName.replace('&', '-')
|
||||||
|
|
||||||
|
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -997,7 +997,8 @@ def testFollows():
|
||||||
'/following.txt', "r")
|
'/following.txt', "r")
|
||||||
domainFound = False
|
domainFound = False
|
||||||
for followingDomain in f:
|
for followingDomain in f:
|
||||||
testDomain = followingDomain.split('@')[1].replace('\n', '')
|
testDomain = followingDomain.split('@')[1]
|
||||||
|
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
||||||
if testDomain == 'mesh.com':
|
if testDomain == 'mesh.com':
|
||||||
domainFound = True
|
domainFound = True
|
||||||
if testDomain not in federationList:
|
if testDomain not in federationList:
|
||||||
|
@ -1009,7 +1010,8 @@ def testFollows():
|
||||||
|
|
||||||
domainFound = False
|
domainFound = False
|
||||||
for followingDomain in f:
|
for followingDomain in f:
|
||||||
testDomain = followingDomain.split('@')[1].replace('\n', '')
|
testDomain = followingDomain.split('@')[1]
|
||||||
|
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
||||||
if testDomain == 'mesh.com':
|
if testDomain == 'mesh.com':
|
||||||
domainFound = True
|
domainFound = True
|
||||||
assert(domainFound is False)
|
assert(domainFound is False)
|
||||||
|
@ -1029,7 +1031,8 @@ def testFollows():
|
||||||
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
||||||
'/followers.txt', "r")
|
'/followers.txt', "r")
|
||||||
for followerDomain in f:
|
for followerDomain in f:
|
||||||
testDomain = followerDomain.split('@')[1].replace('\n', '')
|
testDomain = followerDomain.split('@')[1]
|
||||||
|
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
||||||
if testDomain not in federationList:
|
if testDomain not in federationList:
|
||||||
print(testDomain)
|
print(testDomain)
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
2
utils.py
2
utils.py
|
@ -395,7 +395,7 @@ def removeModerationPostFromIndex(baseDir: str, postUrl: str,
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(moderationIndexFile, "w+") as f:
|
with open(moderationIndexFile, "w+") as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.strip("\n") != postId:
|
if line.strip("\n").strip("\r") != postId:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -285,7 +285,7 @@ def htmlSearchEmoji(translate: {}, baseDir: str, httpPrefix: str,
|
||||||
copyfile(baseDir + '/emoji/default_emoji.json',
|
copyfile(baseDir + '/emoji/default_emoji.json',
|
||||||
baseDir + '/emoji/emoji.json')
|
baseDir + '/emoji/emoji.json')
|
||||||
|
|
||||||
searchStr = searchStr.lower().replace(':', '').strip('\n')
|
searchStr = searchStr.lower().replace(':', '').strip('\n').strip('\r')
|
||||||
cssFilename = baseDir + '/epicyon-profile.css'
|
cssFilename = baseDir + '/epicyon-profile.css'
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
@ -362,7 +362,7 @@ def htmlSearchSharedItems(translate: {},
|
||||||
ctr = 0
|
ctr = 0
|
||||||
sharedItemsForm = ''
|
sharedItemsForm = ''
|
||||||
searchStrLower = urllib.parse.unquote(searchStr)
|
searchStrLower = urllib.parse.unquote(searchStr)
|
||||||
searchStrLower = searchStrLower.lower().strip('\n')
|
searchStrLower = searchStrLower.lower().strip('\n').strip('\r')
|
||||||
searchStrLowerList = searchStrLower.split('+')
|
searchStrLowerList = searchStrLower.split('+')
|
||||||
cssFilename = baseDir + '/epicyon-profile.css'
|
cssFilename = baseDir + '/epicyon-profile.css'
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
|
@ -647,7 +647,7 @@ def htmlHashtagSearch(nickname: str, domain: str, port: int,
|
||||||
'"></a></center>'
|
'"></a></center>'
|
||||||
index = startIndex
|
index = startIndex
|
||||||
while index <= endIndex:
|
while index <= endIndex:
|
||||||
postId = lines[index].strip('\n')
|
postId = lines[index].strip('\n').strip('\r')
|
||||||
if ' ' not in postId:
|
if ' ' not in postId:
|
||||||
nickname = getNicknameFromActor(postId)
|
nickname = getNicknameFromActor(postId)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
|
@ -710,7 +710,7 @@ def htmlSkillsSearch(translate: {}, baseDir: str,
|
||||||
if skillsearch.startswith('*'):
|
if skillsearch.startswith('*'):
|
||||||
skillsearch = skillsearch[1:].strip()
|
skillsearch = skillsearch[1:].strip()
|
||||||
|
|
||||||
skillsearch = skillsearch.lower().strip('\n')
|
skillsearch = skillsearch.lower().strip('\n').strip('\r')
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
# search instance accounts
|
# search instance accounts
|
||||||
|
@ -846,7 +846,7 @@ def htmlHistorySearch(translate: {}, baseDir: str,
|
||||||
if historysearch.startswith('!'):
|
if historysearch.startswith('!'):
|
||||||
historysearch = historysearch[1:].strip()
|
historysearch = historysearch[1:].strip()
|
||||||
|
|
||||||
historysearch = historysearch.lower().strip('\n')
|
historysearch = historysearch.lower().strip('\n').strip('\r')
|
||||||
|
|
||||||
boxFilenames = \
|
boxFilenames = \
|
||||||
searchBoxPosts(baseDir, nickname, domain,
|
searchBoxPosts(baseDir, nickname, domain,
|
||||||
|
@ -4156,8 +4156,8 @@ def htmlTimeline(defaultTimeline: str,
|
||||||
if os.path.isfile(calendarFile):
|
if os.path.isfile(calendarFile):
|
||||||
calendarImage = 'calendar_notify.png'
|
calendarImage = 'calendar_notify.png'
|
||||||
with open(calendarFile, 'r') as calfile:
|
with open(calendarFile, 'r') as calfile:
|
||||||
calendarPath = \
|
calendarPath = calfile.read().replace('##sent##', '')
|
||||||
calfile.read().replace('##sent##', '').replace('\n', '')
|
calendarPath = calendarPath.replace('\n', '').replace('\r', '')
|
||||||
|
|
||||||
# should the DM button be highlighted?
|
# should the DM button be highlighted?
|
||||||
newDM = False
|
newDM = False
|
||||||
|
|
Loading…
Reference in New Issue