Improve mpv doublequote sanitisation

This commit is contained in:
Etoh 2017-05-07 17:21:22 +01:00
parent 2da8e84bba
commit 551ad965aa
2 changed files with 6 additions and 0 deletions

View File

@ -357,6 +357,7 @@ function handle_enter()
if line == '' then
return
end
line = string.gsub(line,"\"", "\\\"")
mp.command('print-text "<chat>'..line..'</chat>"')
clear()
end

View File

@ -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("\\\"", "<SYNCPLAY_QUOTE>")
text = text.replace("\"", "<SYNCPLAY_QUOTE>")
text = text.replace("\\", u"\\\\\\uFEFF")
text = text.replace("{", "\\\\{")
text = text.replace("}", "\\\\}")
text = text.replace("}", "\\\\}")
text = text.replace("<SYNCPLAY_QUOTE>","\\\"")
return text
def _quoteArg(self, arg):