From 2674a7d7f3f6f0336c9715b30db0277a5fee0536 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 12:17:27 +0000 Subject: [PATCH 1/2] Remove newline --- notifications_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/notifications_client.py b/notifications_client.py index 33a911e13..0aa85fb57 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -438,7 +438,6 @@ def _showLocalBox(notifyJson: {}, boxName: str, print(indent + titleStr + '\n') if not index: - print('') sayStr = indent + 'You have no ' + boxName + ' posts yet.' _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) print('') From b8f98ff0428370f3430c2046749e440d04eb806b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 12:35:53 +0000 Subject: [PATCH 2/2] Remove possibly unsafe characters from spoken strings --- notifications_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/notifications_client.py b/notifications_client.py index 0aa85fb57..50ed15844 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -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)