Shared playlist auto-switch to URIs by default, but only to user-specified 'trustedURIs' if 'onlySwitchToTrustedURIs' is True

This commit is contained in:
Et0h 2016-05-07 09:25:32 +01:00
parent 7b75a04b46
commit 5d28692996
6 changed files with 25 additions and 12 deletions

View File

@ -435,6 +435,16 @@ class SyncplayClient(object):
self.sendFile() self.sendFile()
self.playlist.changeToPlaylistIndexFromFilename(filename) 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): def openFile(self, filePath, resetPosition=False):
self._player.openFile(filePath, resetPosition) self._player.openFile(filePath, resetPosition)
@ -1361,11 +1371,10 @@ class SyncplayPlaylist():
try: try:
filename = self._playlist[index] filename = self._playlist[index]
if utils.isURL(filename): if utils.isURL(filename):
for URI in constants.SAFE_URIS: if self._client.isURITrusted(filename):
if filename.startswith(URI): self._client.openFile(filename, resetPosition=resetPosition)
self._client.openFile(filename, resetPosition=resetPosition) else:
return self._ui.showErrorMessage(getMessage("cannot-add-unsafe-path-error").format(filename))
self._ui.showErrorMessage(getMessage("cannot-add-unsafe-path-error").format(filename))
return return
else: else:
path = self._client.fileSwitch.findFilepath(filename, highPriority=True) path = self._client.fileSwitch.findFilepath(filename, highPriority=True)

View File

@ -187,5 +187,4 @@ 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
PRIVATE_FILE_FIELDS = ["path"] 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

View File

@ -375,7 +375,7 @@ de = {
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "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-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-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", "sharedplaylistenabled-label" : u"Enable shared playlists",
"removefromplaylist-menu-label" : u"Remove from playlist", "removefromplaylist-menu-label" : u"Remove from playlist",
"shuffleplaylist-menuu-label" : u"Shuffle playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist",

View File

@ -376,7 +376,7 @@ en = {
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "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-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-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", "sharedplaylistenabled-label" : u"Enable shared playlists",
"removefromplaylist-menu-label" : u"Remove from playlist", "removefromplaylist-menu-label" : u"Remove from playlist",
"shuffleplaylist-menuu-label" : u"Shuffle playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist",

View File

@ -375,7 +375,7 @@ ru = {
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "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-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-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", "sharedplaylistenabled-label" : u"Enable shared playlists",
"removefromplaylist-menu-label" : u"Remove from playlist", "removefromplaylist-menu-label" : u"Remove from playlist",
"shuffleplaylist-menuu-label" : u"Shuffle playlist", "shuffleplaylist-menuu-label" : u"Shuffle playlist",

View File

@ -36,6 +36,8 @@ class ConfigurationGetter(object):
"mediaSearchDirectories": None, "mediaSearchDirectories": None,
"sharedPlaylistEnabled": True, "sharedPlaylistEnabled": True,
"loopAtEndOfPlaylist": False, "loopAtEndOfPlaylist": False,
"onlySwitchToTrustedURIs": False,
"trustedURIs": None,
"file": None, "file": None,
"playerArgs": [], "playerArgs": [],
"playerClass": None, "playerClass": None,
@ -106,7 +108,8 @@ class ConfigurationGetter(object):
"showNonControllerOSD", "showNonControllerOSD",
"showDurationNotification", "showDurationNotification",
"sharedPlaylistEnabled", "sharedPlaylistEnabled",
"loopAtEndOfPlaylist" "loopAtEndOfPlaylist",
"onlySwitchToTrustedURIs"
] ]
self._tristate = [ self._tristate = [
"checkForUpdatesAutomatically", "checkForUpdatesAutomatically",
@ -116,6 +119,7 @@ class ConfigurationGetter(object):
self._serialised = [ self._serialised = [
"perPlayerArguments", "perPlayerArguments",
"mediaSearchDirectories", "mediaSearchDirectories",
"trustedURIs",
] ]
self._numeric = [ self._numeric = [
@ -136,7 +140,8 @@ class ConfigurationGetter(object):
"filesizePrivacyMode", "unpauseAction", "filesizePrivacyMode", "unpauseAction",
"pauseOnLeave", "readyAtStart", "autoplayMinUsers", "pauseOnLeave", "readyAtStart", "autoplayMinUsers",
"autoplayInitialState", "mediaSearchDirectories", "autoplayInitialState", "mediaSearchDirectories",
"sharedPlaylistEnabled", "loopAtEndOfPlaylist"], "sharedPlaylistEnabled", "loopAtEndOfPlaylist",
"onlySwitchToTrustedURIs", "trustedURIs"],
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD",
"showDifferentRoomOSD", "showSameRoomOSD", "showDifferentRoomOSD", "showSameRoomOSD",
"showNonControllerOSD", "showDurationNotification"], "showNonControllerOSD", "showDurationNotification"],