From b08fe09e296524daf4de7ed16e0bed224f5008a2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 7 Dec 2015 09:50:26 +0000 Subject: tracklist: support limiting maximum tracklist size This defaults to 16384? This is what mpd uses by default as well. Of course folks interacting with dtas-player directly can override this: dtas-tl max INTEGER dtas-tl max This is NOT meant to be a hard security measure for local users talking to dtas-player directly. It is only to prevent accidentally stupid things like flooding the playlist with a broken script and to prevent remote users from DoS-ing us via the to-be-written mpd proxy/emulation layer. Remember: dtas-player itself will ALWAYS remain capable of executing arbitrary code :) --- test/test_tracklist.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/test_tracklist.rb b/test/test_tracklist.rb index a3c89f6..4d00227 100644 --- a/test/test_tracklist.rb +++ b/test/test_tracklist.rb @@ -106,4 +106,16 @@ class TestTracklist < Testcase tl.remove_track(1 << 128) assert_equal %w(b c e f), list_to_path(tl), "no change" end + + def test_max + tl = DTAS::Tracklist.new + assert_kind_of Integer, tl.add_track('z') + assert_kind_of Integer, tl.max + tl.max = 1 + assert_equal false, tl.add_track('y') + assert_equal 1, tl.instance_variable_get(:@list).size + tl.max = 2 + assert_kind_of Integer, tl.add_track('y') + assert_equal 2, tl.instance_variable_get(:@list).size + end end -- cgit v1.2.3-24-ge0c7