Check string types

main
Bob Mottram 2021-07-09 21:00:02 +01:00
parent 0118168173
commit c8b39b0449
2 changed files with 31 additions and 28 deletions

View File

@ -733,10 +733,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_header('Host', callingDomain)
self.send_header('InstanceID', self.server.instanceId)
self.send_header('Content-Length', '0')
# self.send_header('X-Robots-Tag',
# 'noindex, nofollow, noarchive, nosnippet')
# self.send_header('Cache-Control', 'public')
# self.send_header('Referrer-Policy', 'origin')
self.end_headers()
def _httpReturnCode(self, httpCode: int, httpDescription: str,
@ -756,10 +752,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_header('Content-Type', 'text/html; charset=utf-8')
msgLenStr = str(len(msg))
self.send_header('Content-Length', msgLenStr)
# self.send_header('X-Robots-Tag',
# 'noindex, nofollow, noarchive, nosnippet')
# self.send_header('Cache-Control', 'public')
# self.send_header('Referrer-Policy', 'origin')
self.end_headers()
if not self._write(msg):
print('Error when showing ' + str(httpCode))

View File

@ -692,29 +692,40 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
if hasObjectDict(postJsonObject2):
if postJsonObject2['object'].get('attributedTo') and \
postJsonObject2['object'].get('content'):
actor = postJsonObject2['object']['attributedTo']
nameStr += ' ' + translate['announces'] + ' ' + \
getNicknameFromActor(actor)
sayStr = nameStr
_sayCommand(sayStr, sayStr, screenreader,
systemLanguage, espeak)
print('')
if screenreader:
time.sleep(2)
content = \
_textOnlyContent(postJsonObject2['object']['content'])
content += _getImageDescription(postJsonObject2)
messageStr, detectedLinks = \
speakableText(baseDir, content, translate)
sayStr = content
_sayCommand(sayStr, messageStr, screenreader,
systemLanguage, espeak)
return postJsonObject2
attributedTo = postJsonObject2['object']['attributedTo']
content = postJsonObject2['object']['content']
if isinstance(attributedTo, str) and \
isinstance(content, str):
actor = attributedTo
nameStr += ' ' + translate['announces'] + ' ' + \
getNicknameFromActor(actor)
sayStr = nameStr
_sayCommand(sayStr, sayStr, screenreader,
systemLanguage, espeak)
print('')
if screenreader:
time.sleep(2)
content = \
_textOnlyContent(content)
content += _getImageDescription(postJsonObject2)
messageStr, detectedLinks = \
speakableText(baseDir, content, translate)
sayStr = content
_sayCommand(sayStr, messageStr, screenreader,
systemLanguage, espeak)
return postJsonObject2
return {}
actor = postJsonObject['object']['attributedTo']
attributedTo = postJsonObject['object']['attributedTo']
if not attributedTo:
return {}
content = postJsonObject['object']['content']
if not isinstance(attributedTo, str) or \
not isinstance(content, str):
return {}
actor = attributedTo
nameStr = getNicknameFromActor(actor)
content = _textOnlyContent(postJsonObject['object']['content'])
content = _textOnlyContent(content)
content += _getImageDescription(postJsonObject)
if isPGPEncrypted(content):