diff --git a/syncplay/client.py b/syncplay/client.py index 23f58a0..9e72aa8 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -435,6 +435,16 @@ class SyncplayClient(object): self.sendFile() 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 + def openFile(self, filePath, resetPosition=False): self._player.openFile(filePath, resetPosition) @@ -1361,11 +1371,10 @@ class SyncplayPlaylist(): try: filename = self._playlist[index] if utils.isURL(filename): - for URI in constants.SAFE_URIS: - if filename.startswith(URI): - self._client.openFile(filename, resetPosition=resetPosition) - return - self._ui.showErrorMessage(getMessage("cannot-add-unsafe-path-error").format(filename)) + if self._client.isURITrusted(filename): + self._client.openFile(filename, resetPosition=resetPosition) + else: + self._ui.showErrorMessage(getMessage("cannot-add-unsafe-path-error").format(filename)) return else: path = self._client.fileSwitch.findFilepath(filename, highPriority=True) diff --git a/syncplay/constants.py b/syncplay/constants.py index a348874..107b538 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -187,5 +187,4 @@ 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 -PRIVATE_FILE_FIELDS = ["path"] -SAFE_URIS = [u"http://www.youtube.com/", u"https://www.youtube.com/", u"http://www.vimeo.com/", u"https://www.vimeo.com/",u"http://player.vimeo.com",u"https://player.vimeo.com",u"http://www.youtu.be/", u"https://www.youtu.be/",u"http://youtu.be/", u"https://youtu.be/"] # TODO: Move into config \ No newline at end of file +PRIVATE_FILE_FIELDS = ["path"] \ No newline at end of file diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 2dc25ce..56ba962 100644 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -375,7 +375,7 @@ de = { "playlist-contents-changed-notification" : u"{} updated the playlist", # Username "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename - "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a safe path.", # Filename + "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "sharedplaylistenabled-label" : u"Enable shared playlists", "removefromplaylist-menu-label" : u"Remove from playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index ab92c1f..3ae0448 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -376,7 +376,7 @@ en = { "playlist-contents-changed-notification" : u"{} updated the playlist", # Username "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename - "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a safe path.", # Filename + "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "sharedplaylistenabled-label" : u"Enable shared playlists", "removefromplaylist-menu-label" : u"Remove from playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index ba7cba6..5cdca6d 100644 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -375,7 +375,7 @@ ru = { "playlist-contents-changed-notification" : u"{} updated the playlist", # Username "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename - "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a safe path.", # Filename + "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "sharedplaylistenabled-label" : u"Enable shared playlists", "removefromplaylist-menu-label" : u"Remove from playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 0165a34..a8d2446 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -36,6 +36,8 @@ class ConfigurationGetter(object): "mediaSearchDirectories": None, "sharedPlaylistEnabled": True, "loopAtEndOfPlaylist": False, + "onlySwitchToTrustedURIs": False, + "trustedURIs": None, "file": None, "playerArgs": [], "playerClass": None, @@ -106,7 +108,8 @@ class ConfigurationGetter(object): "showNonControllerOSD", "showDurationNotification", "sharedPlaylistEnabled", - "loopAtEndOfPlaylist" + "loopAtEndOfPlaylist", + "onlySwitchToTrustedURIs" ] self._tristate = [ "checkForUpdatesAutomatically", @@ -116,6 +119,7 @@ class ConfigurationGetter(object): self._serialised = [ "perPlayerArguments", "mediaSearchDirectories", + "trustedURIs", ] self._numeric = [ @@ -136,7 +140,8 @@ class ConfigurationGetter(object): "filesizePrivacyMode", "unpauseAction", "pauseOnLeave", "readyAtStart", "autoplayMinUsers", "autoplayInitialState", "mediaSearchDirectories", - "sharedPlaylistEnabled", "loopAtEndOfPlaylist"], + "sharedPlaylistEnabled", "loopAtEndOfPlaylist", + "onlySwitchToTrustedURIs", "trustedURIs"], "gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showNonControllerOSD", "showDurationNotification"],