From 551ad965aa149bb989d78a50c9f7d2d74bc62fc5 Mon Sep 17 00:00:00 2001 From: Etoh Date: Sun, 7 May 2017 17:21:22 +0100 Subject: [PATCH] Improve mpv doublequote sanitisation --- resources/syncplayintf.lua | 1 + syncplay/players/mplayer.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/resources/syncplayintf.lua b/resources/syncplayintf.lua index 805e5bf..57b290c 100644 --- a/resources/syncplayintf.lua +++ b/resources/syncplayintf.lua @@ -357,6 +357,7 @@ function handle_enter() if line == '' then return end + line = string.gsub(line,"\"", "\\\"") mp.command('print-text "'..line..'"') clear() end diff --git a/syncplay/players/mplayer.py b/syncplay/players/mplayer.py index 99bf7f4..2214f18 100644 --- a/syncplay/players/mplayer.py +++ b/syncplay/players/mplayer.py @@ -96,6 +96,7 @@ class MplayerPlayer(BasePlayer): username = self._sanitizeText(username) message = self._sanitizeText(message) messageString = u"<{}> {}".format(username, message) + messageString = self._sanitizeText(messageString) self._listener.sendLine(u'script-message-to syncplayintf chat "{}"'.format(messageString)) def setSpeed(self, value): @@ -140,9 +141,13 @@ class MplayerPlayer(BasePlayer): def _sanitizeText(self, text): text = text.replace("\r", "") text = text.replace("\n", "") + text = text.replace("\\\"", "") + text = text.replace("\"", "") text = text.replace("\\", u"\\\\\\uFEFF") text = text.replace("{", "\\\\{") text = text.replace("}", "\\\\}") + text = text.replace("}", "\\\\}") + text = text.replace("","\\\"") return text def _quoteArg(self, arg):