From 9fe112c2226b14922dd471c44aff3203c8ac8df7 Mon Sep 17 00:00:00 2001 From: gillouche Date: Wed, 2 Mar 2016 22:38:55 +0100 Subject: [PATCH] prevents wrong matching results because of trailing spaces for the match-filter options --- test/test_utils.py | 4 +++- youtube_dl/utils.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 33b496573..5e0754fe1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -712,7 +712,9 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') self.assertTrue(match_str( 'playlist_title != some-playlist_name & playlist_title != some_playlist-name', {'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): self.assertEqual(parse_dfxp_time_expr(None), None) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index fd32d904d..128248a52 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2011,7 +2011,7 @@ def match_str(filter_str, dct): """ Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """ 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):