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

View File

@ -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
PRIVATE_FILE_FIELDS = ["path"]

View File

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

View File

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

View File

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

View File

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