Remove possibly unsafe characters from spoken strings

main
Bob Mottram 2021-03-16 12:35:53 +00:00
parent 2674a7d7f3
commit b8f98ff042
1 changed files with 11 additions and 0 deletions

View File

@ -336,6 +336,12 @@ def _getSpeakerJsonFromIndex(boxName: str, index: int) -> {}:
return loadJson(speakerJsonFilename)
def _safeMessage(content: str) -> str:
"""Removes anything potentially unsafe from a string
"""
return content.replace('`', '').replace('$(', '$ (')
def _readLocalBoxPost(boxName: str, index: int,
systemLanguage: str,
screenreader: str, espeak) -> {}:
@ -374,6 +380,9 @@ def _readLocalBoxPost(boxName: str, index: int,
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
return
_safeMessage(content)
_safeMessage(messageStr)
time.sleep(2)
# say the speaker's name
@ -886,6 +895,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
time.sleep(2)
# speak the post content
_safeMessage(content)
_safeMessage(messageStr)
_sayCommand(content, messageStr, screenreader,
systemLanguage, espeak,
nameStr, gender)