Strip improper chars from control pass auth

This commit is contained in:
Et0h 2014-10-17 16:45:50 +01:00
parent a06b691f29
commit cbf509b057
2 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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"]