diff --git a/syncplay/client.py b/syncplay/client.py index 8854850..821d08b 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -3,6 +3,7 @@ import os.path import random import string import time +import re from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task from syncplay.protocols import SyncClientProtocol @@ -427,7 +428,14 @@ class SyncplayClient(object): self._protocol.requestControlledRoom(controlPassword) self.ui.updateRoomName(roomName) + def stripControlPassword(self, controlPassword): + if controlPassword: + return re.sub(constants.CONTROL_PASSWORD_STRIP_REGEX, "", controlPassword).upper() + else: + return "" + def identifyAsController(self, controlPassword): + controlPassword = self.stripControlPassword(controlPassword) self.ui.showMessage(u"Identifying as room controller with password '{}'...".format(controlPassword)) self._protocol.requestControlledRoom(controlPassword) diff --git a/syncplay/constants.py b/syncplay/constants.py index 0e6b66d..c2473ad 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -40,6 +40,7 @@ MERGE_PLAYPAUSE_BUTTONS = False SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players #Usually there's no need to adjust these FILENAME_STRIP_REGEX = u"[-~_\.\[\](): ]" +CONTROL_PASSWORD_STRIP_REGEX = u"[^a-zA-Z0-9\-]" COMMANDS_UNDO = ["u", "undo", "revert"] COMMANDS_LIST = ["l", "list", "users"] COMMANDS_PAUSE = ["p", "play", "pause"]