From 6db4b818e679d24f46c1222ddf732ae60117cb18 Mon Sep 17 00:00:00 2001 From: "Linux-Fan, Ma_Sys.ma" Date: Fri, 23 Aug 2024 21:28:24 +0200 Subject: [PATCH] song/Filter: Fix spacing error on nested AND Previously, `AND` expressions were the only filters which used `++s` instead of `s = StripLeft(s + 1)` making them sensitive to spacing issues. This caused nested AND expressions (like e.g. `(((A) AND (B)) AND (C))`) to needlessly be rejected with the following error message: `{find} Word expected` due to the fact that the inner AND expression would leave the cursor `s` at a space rather than the beginning of the next word (remainder was ` AND (C))` rather than `AND (C)`). This commit fixes this by consistently using `s = StripLeft(s + 1)` instead of `++s` when parsing AND expressions. Although it is not strictly necessary to resolve the AND nesting bug, the case of trivial AND expressions (consisting basically of only superfluous parentheses) is also changed to the new handling. This should be more robust although I expect that case to be even less common than the direct nesting of AND expressions. see MusicPlayerDaemon/MPD#2100 --- src/song/Filter.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/song/Filter.cxx b/src/song/Filter.cxx index 6cef1f8b0d..566a501099 100644 --- a/src/song/Filter.cxx +++ b/src/song/Filter.cxx @@ -326,7 +326,7 @@ SongFilter::ParseExpression(const char *&s, bool fold_case) if (*s == '(') { auto first = ParseExpression(s, fold_case); if (*s == ')') { - ++s; + s = StripLeft(s + 1); return first; } @@ -340,7 +340,7 @@ SongFilter::ParseExpression(const char *&s, bool fold_case) and_filter->AddItem(ParseExpression(s, fold_case)); if (*s == ')') { - ++s; + s = StripLeft(s + 1); return and_filter; }