Only auto-switch to trusted domains by default

This commit is contained in:
Et0h 2016-05-08 13:48:42 +01:00
parent 176b2f65dc
commit 1de40303bd
7 changed files with 42 additions and 13 deletions

View File

@ -453,14 +453,18 @@ class SyncplayClient(object):
self.playlist.changeToPlaylistIndexFromFilename(filename) self.playlist.changeToPlaylistIndexFromFilename(filename)
def isURITrusted(self, URIToTest): def isURITrusted(self, URIToTest):
if self._config['onlySwitchToTrustedURIs']: for trustedProtocol in constants.TRUSTABLE_WEB_PROTOCOLS:
if self._config['trustedURIs']: if URIToTest.startswith(trustedProtocol):
for URI in self._config['trustedURIs']: if self._config['onlySwitchToTrustedDomains']:
if URIToTest.startswith(URI): if self._config['trustedDomains']:
return True for trustedDomain in self._config['trustedDomains']:
return False trustableURI = ''.join([trustedProtocol,trustedDomain,u"/"])
else: if URIToTest.startswith(trustableURI):
return True return True
return False
else:
return True
return False
def openFile(self, filePath, resetPosition=False): def openFile(self, filePath, resetPosition=False):
self._player.openFile(filePath, resetPosition) self._player.openFile(filePath, resetPosition)

View File

@ -187,4 +187,7 @@ SYNCPLAY_UPDATE_URL = u"http://syncplay.pl/checkforupdate?{}" # Params
SYNCPLAY_DOWNLOAD_URL = "http://syncplay.pl/download/" SYNCPLAY_DOWNLOAD_URL = "http://syncplay.pl/download/"
SYNCPLAY_PUBLIC_SERVER_LIST_URL = u"http://syncplay.pl/listpublicservers?{}" # Params 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"] PRIVATE_FILE_FIELDS = ["path"]

View File

@ -220,6 +220,7 @@ de = {
"unpause-ifothersready-option" : u"Wiedergeben wenn bereits als Bereit gesetzt oder alle anderen bereit sind (Standard)", "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-ifminusersready-option" : u"Wiedergeben wenn bereits als Bereit gesetzt oder die minimale Anzahl anderer Nutzer bereit ist",
"unpause-always" : u"Immer wiedergeben", "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", "help-label" : u"Hilfe",
"reset-label" : u"Standardwerte zurücksetzen", "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-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-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.", "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]", "help-tooltip" : u"Öffnet Hilfe auf syncplay.pl [Englisch]",
"reset-tooltip" : u"Alle Einstellungen auf Standardwerte zurücksetzen.", "reset-tooltip" : u"Alle Einstellungen auf Standardwerte zurücksetzen.",

View File

@ -222,6 +222,7 @@ en = {
"unpause-ifothersready-option" : u"Unpause if already ready or others in room are ready (default)", "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-ifminusersready-option" : u"Unpause if already ready or if all others ready and min users ready",
"unpause-always" : u"Always unpause", "unpause-always" : u"Always unpause",
"syncplay-trusteddomains-title": u"Trusted domains (for streaming services and hosted content)",
"help-label" : "Help", "help-label" : "Help",
"reset-label" : "Restore defaults", "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-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-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.", "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.", "help-tooltip" : "Opens the Syncplay.pl user guide.",
"reset-tooltip" : "Reset all settings to the default configuration.", "reset-tooltip" : "Reset all settings to the default configuration.",

View File

@ -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-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-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 "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"Помощь", "help-label" : u"Помощь",
"reset-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-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-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 "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.", "help-tooltip" : u"Открыть Руководство Пользователя на Syncplay.pl.",
"reset-tooltip" : u"Сбрасывает все настройки Syncplay в начальное состояние.", "reset-tooltip" : u"Сбрасывает все настройки Syncplay в начальное состояние.",

View File

@ -37,8 +37,8 @@ class ConfigurationGetter(object):
"sharedPlaylistEnabled": True, "sharedPlaylistEnabled": True,
"loopAtEndOfPlaylist": False, "loopAtEndOfPlaylist": False,
"loopSingleFiles" : False, "loopSingleFiles" : False,
"onlySwitchToTrustedURIs": False, "onlySwitchToTrustedDomains": True,
"trustedURIs": None, "trustedDomains": constants.DEFAULT_TRUSTED_DOMAINS,
"file": None, "file": None,
"playerArgs": [], "playerArgs": [],
"playerClass": None, "playerClass": None,
@ -111,7 +111,7 @@ class ConfigurationGetter(object):
"sharedPlaylistEnabled", "sharedPlaylistEnabled",
"loopAtEndOfPlaylist", "loopAtEndOfPlaylist",
"loopSingleFiles", "loopSingleFiles",
"onlySwitchToTrustedURIs" "onlySwitchToTrustedDomains"
] ]
self._tristate = [ self._tristate = [
"checkForUpdatesAutomatically", "checkForUpdatesAutomatically",
@ -121,7 +121,7 @@ class ConfigurationGetter(object):
self._serialised = [ self._serialised = [
"perPlayerArguments", "perPlayerArguments",
"mediaSearchDirectories", "mediaSearchDirectories",
"trustedURIs", "trustedDomains",
] ]
self._numeric = [ self._numeric = [
@ -144,7 +144,7 @@ class ConfigurationGetter(object):
"autoplayInitialState", "mediaSearchDirectories", "autoplayInitialState", "mediaSearchDirectories",
"sharedPlaylistEnabled", "loopAtEndOfPlaylist", "sharedPlaylistEnabled", "loopAtEndOfPlaylist",
"loopSingleFiles", "loopSingleFiles",
"onlySwitchToTrustedURIs", "trustedURIs"], "onlySwitchToTrustedDomains", "trustedDomains"],
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD",
"showDifferentRoomOSD", "showSameRoomOSD", "showDifferentRoomOSD", "showSameRoomOSD",
"showNonControllerOSD", "showDurationNotification"], "showNonControllerOSD", "showDurationNotification"],

View File

@ -370,6 +370,7 @@ class ConfigDialog(QtGui.QDialog):
self.config["perPlayerArguments"] = self.perPlayerArgs self.config["perPlayerArguments"] = self.perPlayerArgs
self.config["mediaSearchDirectories"] = utils.convertMultilineStringToList(self.mediasearchTextEdit.toPlainText()) self.config["mediaSearchDirectories"] = utils.convertMultilineStringToList(self.mediasearchTextEdit.toPlainText())
self.config["trustedDomains"] = utils.convertMultilineStringToList(self.trusteddomainsTextEdit.toPlainText())
self.processWidget(self, lambda w: self.saveValues(w)) self.processWidget(self, lambda w: self.saveValues(w))
if self.hostCombobox.currentText(): if self.hostCombobox.currentText():
@ -504,6 +505,7 @@ class ConfigDialog(QtGui.QDialog):
self.perPlayerArgs = self.config["perPlayerArguments"] self.perPlayerArgs = self.config["perPlayerArguments"]
self.mediaSearchDirectories = self.config["mediaSearchDirectories"] self.mediaSearchDirectories = self.config["mediaSearchDirectories"]
self.trustedDomains = self.config["trustedDomains"]
self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title")) self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title"))
self.loadSavedPublicServerList() self.loadSavedPublicServerList()
@ -794,10 +796,24 @@ class ConfigDialog(QtGui.QDialog):
self.othersyncSettingsLayout.setAlignment(Qt.AlignLeft) self.othersyncSettingsLayout.setAlignment(Qt.AlignLeft)
self.othersyncSettingsLayout.addWidget(self.fastforwardCheckbox, 3, 0,1,2, 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.setLayout(self.othersyncSettingsLayout)
self.othersyncSettingsGroup.setMaximumHeight(self.othersyncSettingsGroup.minimumSizeHint().height()) self.othersyncSettingsGroup.setMaximumHeight(self.othersyncSettingsGroup.minimumSizeHint().height())
self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup) self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup)
self.syncSettingsLayout.addWidget(self.desyncSettingsGroup) self.syncSettingsLayout.addWidget(self.desyncSettingsGroup)
self.syncSettingsLayout.addWidget(self.trusteddomainsSettingsGroup)
self.syncSettingsFrame.setLayout(self.syncSettingsLayout) self.syncSettingsFrame.setLayout(self.syncSettingsLayout)
self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height()) self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height())
self.syncSettingsLayout.setAlignment(Qt.AlignTop) self.syncSettingsLayout.setAlignment(Qt.AlignTop)