From 1de40303bdabf20410791800b466aaf236e6bbd6 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 8 May 2016 13:48:42 +0100 Subject: [PATCH] Only auto-switch to trusted domains by default --- syncplay/client.py | 20 ++++++++++++-------- syncplay/constants.py | 3 +++ syncplay/messages_de.py | 2 ++ syncplay/messages_en.py | 2 ++ syncplay/messages_ru.py | 2 ++ syncplay/ui/ConfigurationGetter.py | 10 +++++----- syncplay/ui/GuiConfiguration.py | 16 ++++++++++++++++ 7 files changed, 42 insertions(+), 13 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index bc3a2ef..a619c39 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -453,14 +453,18 @@ class SyncplayClient(object): self.playlist.changeToPlaylistIndexFromFilename(filename) def isURITrusted(self, URIToTest): - if self._config['onlySwitchToTrustedURIs']: - if self._config['trustedURIs']: - for URI in self._config['trustedURIs']: - if URIToTest.startswith(URI): - return True - return False - else: - return True + for trustedProtocol in constants.TRUSTABLE_WEB_PROTOCOLS: + if URIToTest.startswith(trustedProtocol): + if self._config['onlySwitchToTrustedDomains']: + if self._config['trustedDomains']: + for trustedDomain in self._config['trustedDomains']: + trustableURI = ''.join([trustedProtocol,trustedDomain,u"/"]) + if URIToTest.startswith(trustableURI): + return True + return False + else: + return True + return False def openFile(self, filePath, resetPosition=False): self._player.openFile(filePath, resetPosition) diff --git a/syncplay/constants.py b/syncplay/constants.py index 6c06c09..7c6326d 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -187,4 +187,7 @@ SYNCPLAY_UPDATE_URL = u"http://syncplay.pl/checkforupdate?{}" # Params SYNCPLAY_DOWNLOAD_URL = "http://syncplay.pl/download/" SYNCPLAY_PUBLIC_SERVER_LIST_URL = u"http://syncplay.pl/listpublicservers?{}" # Params +DEFAULT_TRUSTED_DOMAINS = [u"youtube.com",u"youtu.be",u"vimeo.com"] +TRUSTABLE_WEB_PROTOCOLS = [u"http://www.",u"https://www.",u"http://",u"https://"] + PRIVATE_FILE_FIELDS = ["path"] \ No newline at end of file diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 56ba962..d87d9c8 100644 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -220,6 +220,7 @@ de = { "unpause-ifothersready-option" : u"Wiedergeben wenn bereits als Bereit gesetzt oder alle anderen bereit sind (Standard)", "unpause-ifminusersready-option" : u"Wiedergeben wenn bereits als Bereit gesetzt oder die minimale Anzahl anderer Nutzer bereit ist", "unpause-always" : u"Immer wiedergeben", + "syncplay-trusteddomains-title": u"Trusted domains (for streaming services and hosted content)", # TODO: Translate into German "help-label" : u"Hilfe", "reset-label" : u"Standardwerte zurücksetzen", @@ -323,6 +324,7 @@ de = { "unpause-ifalreadyready-tooltip" : u"Wenn du nicht bereit bist und Play drückst wirst du als bereit gesetzt - zum Starten der Wiedergabe nochmal drücken.", "unpause-ifothersready-tooltip" : u"Wenn du Play drückst und nicht bereit bist, wird nur gestartet, wenn alle anderen bereit sind.", "unpause-ifminusersready-tooltip" : u"Wenn du Play drückst und nicht bereit bist, wird nur gestartet, wenn die minimale Anzahl anderer Benutzer bereit ist.", + "trusteddomains-arguments-tooltip" : u"Domains that it is okay for Syncplay to automatically switch to when shared playlists is enabled.", # TODO: Translate into German "help-tooltip" : u"Öffnet Hilfe auf syncplay.pl [Englisch]", "reset-tooltip" : u"Alle Einstellungen auf Standardwerte zurücksetzen.", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 3ae0448..b568e25 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -222,6 +222,7 @@ en = { "unpause-ifothersready-option" : u"Unpause if already ready or others in room are ready (default)", "unpause-ifminusersready-option" : u"Unpause if already ready or if all others ready and min users ready", "unpause-always" : u"Always unpause", + "syncplay-trusteddomains-title": u"Trusted domains (for streaming services and hosted content)", "help-label" : "Help", "reset-label" : "Restore defaults", @@ -323,6 +324,7 @@ en = { "unpause-ifalreadyready-tooltip" : u"If you press unpause when not ready it will set you as ready - press unpause again to unpause.", "unpause-ifothersready-tooltip" : u"If you press unpause when not ready, it will only upause if others are ready.", "unpause-ifminusersready-tooltip" : u"If you press unpause when not ready, it will only upause if others are ready and minimum users threshold is met.", + "trusteddomains-arguments-tooltip" : u"Domains that it is okay for Syncplay to automatically switch to when shared playlists is enabled.", "help-tooltip" : "Opens the Syncplay.pl user guide.", "reset-tooltip" : "Reset all settings to the default configuration.", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 5cdca6d..bf969e9 100644 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -222,6 +222,7 @@ ru = { "unpause-ifothersready-option" : u"Unpause if already ready or others in room are ready (default)", # TODO: Translate into Russian "unpause-ifminusersready-option" : u"Unpause if already ready or if all others ready and min users ready", # TODO: Translate into Russian "unpause-always" : u"Always unpause", # TODO: Translate into Russian + "syncplay-trusteddomains-title": u"Trusted domains (for streaming services and hosted content)", # TODO: Translate into Russian "help-label" : u"Помощь", "reset-label" : u"Сброс настроек", @@ -323,6 +324,7 @@ ru = { "unpause-ifalreadyready-tooltip" : u"If you press unpause when not ready it will set you as ready - press unpause again to unpause.", # TODO: Translate into Russian "unpause-ifothersready-tooltip" : u"If you press unpause when not ready, it will only upause if others are ready.", # TODO: Translate into Russian "unpause-ifminusersready-tooltip" : u"If you press unpause when not ready, it will only upause if others are ready and minimum users threshold is met.", # TODO: Translate into Russian + "trusteddomains-arguments-tooltip" : u"Domains that it is okay for Syncplay to automatically switch to when shared playlists is enabled.", # TODO: Translate into Russian "help-tooltip" : u"Открыть Руководство Пользователя на Syncplay.pl.", "reset-tooltip" : u"Сбрасывает все настройки Syncplay в начальное состояние.", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index ebe3da9..5447679 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -37,8 +37,8 @@ class ConfigurationGetter(object): "sharedPlaylistEnabled": True, "loopAtEndOfPlaylist": False, "loopSingleFiles" : False, - "onlySwitchToTrustedURIs": False, - "trustedURIs": None, + "onlySwitchToTrustedDomains": True, + "trustedDomains": constants.DEFAULT_TRUSTED_DOMAINS, "file": None, "playerArgs": [], "playerClass": None, @@ -111,7 +111,7 @@ class ConfigurationGetter(object): "sharedPlaylistEnabled", "loopAtEndOfPlaylist", "loopSingleFiles", - "onlySwitchToTrustedURIs" + "onlySwitchToTrustedDomains" ] self._tristate = [ "checkForUpdatesAutomatically", @@ -121,7 +121,7 @@ class ConfigurationGetter(object): self._serialised = [ "perPlayerArguments", "mediaSearchDirectories", - "trustedURIs", + "trustedDomains", ] self._numeric = [ @@ -144,7 +144,7 @@ class ConfigurationGetter(object): "autoplayInitialState", "mediaSearchDirectories", "sharedPlaylistEnabled", "loopAtEndOfPlaylist", "loopSingleFiles", - "onlySwitchToTrustedURIs", "trustedURIs"], + "onlySwitchToTrustedDomains", "trustedDomains"], "gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showNonControllerOSD", "showDurationNotification"], diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index efc57f4..ecb0234 100644 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -370,6 +370,7 @@ class ConfigDialog(QtGui.QDialog): self.config["perPlayerArguments"] = self.perPlayerArgs self.config["mediaSearchDirectories"] = utils.convertMultilineStringToList(self.mediasearchTextEdit.toPlainText()) + self.config["trustedDomains"] = utils.convertMultilineStringToList(self.trusteddomainsTextEdit.toPlainText()) self.processWidget(self, lambda w: self.saveValues(w)) if self.hostCombobox.currentText(): @@ -504,6 +505,7 @@ class ConfigDialog(QtGui.QDialog): self.perPlayerArgs = self.config["perPlayerArguments"] self.mediaSearchDirectories = self.config["mediaSearchDirectories"] + self.trustedDomains = self.config["trustedDomains"] self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title")) self.loadSavedPublicServerList() @@ -794,10 +796,24 @@ class ConfigDialog(QtGui.QDialog): self.othersyncSettingsLayout.setAlignment(Qt.AlignLeft) self.othersyncSettingsLayout.addWidget(self.fastforwardCheckbox, 3, 0,1,2, Qt.AlignLeft) + + ## Trusted domains + + self.trusteddomainsSettingsGroup = QtGui.QGroupBox(getMessage("syncplay-trusteddomains-title")) + self.trusteddomainsSettingsLayout = QtGui.QVBoxLayout() + self.trusteddomainsSettingsGroup.setLayout(self.trusteddomainsSettingsLayout) + + self.trusteddomainsTextEdit = QPlainTextEdit(utils.getListAsMultilineString(self.trustedDomains)) + self.trusteddomainsTextEdit.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "trusteddomains-arguments") + self.trusteddomainsTextEdit.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) + self.trusteddomainsSettingsLayout.addWidget(self.trusteddomainsTextEdit) + self.trusteddomainsSettingsGroup.setMaximumHeight(self.trusteddomainsSettingsGroup.minimumSizeHint().height()) + self.othersyncSettingsGroup.setLayout(self.othersyncSettingsLayout) self.othersyncSettingsGroup.setMaximumHeight(self.othersyncSettingsGroup.minimumSizeHint().height()) self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup) self.syncSettingsLayout.addWidget(self.desyncSettingsGroup) + self.syncSettingsLayout.addWidget(self.trusteddomainsSettingsGroup) self.syncSettingsFrame.setLayout(self.syncSettingsLayout) self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height()) self.syncSettingsLayout.setAlignment(Qt.AlignTop)