Add check of URI schema to OpenUri
This commit is contained in:
parent
537bb1a879
commit
93f00ce7f2
@ -339,7 +339,10 @@ class MprisObject(dbus.service.Object):
|
||||
# the other methods doesn't help much if OpenUri is open for use.
|
||||
logger.debug(u'%s.Play not allowed', PLAYER_IFACE)
|
||||
return
|
||||
# TODO Check if URI is known scheme and has known MIME type.
|
||||
# TODO Check if URI has known MIME type.
|
||||
uri_schemes = self.backend.uri_schemes.get()
|
||||
if not any([uri.startswith(uri_scheme) for uri_scheme in uri_schemes]):
|
||||
return
|
||||
track = self.backend.library.lookup(uri).get()
|
||||
if track is not None:
|
||||
cp_track = self.backend.current_playlist.add(track).get()
|
||||
|
||||
@ -763,6 +763,14 @@ class PlayerInterfaceTest(unittest.TestCase):
|
||||
self.mpris.OpenUri('dummy:/test/uri')
|
||||
self.assertEquals(len(self.backend.current_playlist.tracks.get()), 0)
|
||||
|
||||
def test_open_uri_ignores_uris_with_unknown_uri_scheme(self):
|
||||
self.assertListEqual(self.backend.uri_schemes.get(), ['dummy'])
|
||||
self.mpris.get_CanPlay = lambda *_: True
|
||||
self.backend.library.provider.dummy_library = [
|
||||
Track(uri='notdummy:/test/uri')]
|
||||
self.mpris.OpenUri('notdummy:/test/uri')
|
||||
self.assertEquals(len(self.backend.current_playlist.tracks.get()), 0)
|
||||
|
||||
def test_open_uri_adds_uri_to_current_playlist(self):
|
||||
self.mpris.get_CanPlay = lambda *_: True
|
||||
self.backend.library.provider.dummy_library = [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user