prevents wrong matching results because of trailing spaces for the match-filter options

This commit is contained in:
gillouche 2016-03-02 22:38:55 +01:00
parent c99f4bd3d3
commit 9fe112c222
2 changed files with 4 additions and 2 deletions

View File

@ -712,7 +712,9 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4')
self.assertTrue(match_str( self.assertTrue(match_str(
'playlist_title != some-playlist_name & playlist_title != some_playlist-name', 'playlist_title != some-playlist_name & playlist_title != some_playlist-name',
{'playlist_title': 'some_playlist'})) {'playlist_title': 'some_playlist'}))
self.assertFalse(match_str(
'playlist_title != some playlist with space & playlist_title != foobar',
{'playlist_title': 'some playlist with space'}))
def test_parse_dfxp_time_expr(self): def test_parse_dfxp_time_expr(self):
self.assertEqual(parse_dfxp_time_expr(None), None) self.assertEqual(parse_dfxp_time_expr(None), None)

View File

@ -2011,7 +2011,7 @@ def match_str(filter_str, dct):
""" Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """ """ Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """
return all( return all(
_match_one(filter_part, dct) for filter_part in filter_str.split('&')) _match_one(filter_part.strip(), dct) for filter_part in filter_str.split('&'))
def match_filter_func(filter_str): def match_filter_func(filter_str):