From f3ebb574ba72cef327d7c9bc389ee95f43dc3b96 Mon Sep 17 00:00:00 2001 From: Will Saxon Date: Sat, 16 Nov 2019 06:27:43 -0500 Subject: [PATCH] Recognize '@' as an operator identical to ':' (#841) * Recognize '@' as an operator identical to ':' * Add comments * Add shortened example query --- src/DAAP2SQL.g | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/DAAP2SQL.g b/src/DAAP2SQL.g index 50a1776b..ec4d1938 100644 --- a/src/DAAP2SQL.g +++ b/src/DAAP2SQL.g @@ -215,7 +215,7 @@ expr returns [ pANTLR3_STRING result, int valid ] } /* No need to exclude empty artist and album, as forked-daapd makes sure there always exists an artist/album. */ - if (neg_op && op == ':' + if (neg_op && (op == ':' || op == '@') && (strcmp((char *)field, "daap.songalbumartist") == 0 || strcmp((char *)field, "daap.songartist") == 0 || strcmp((char *)field, "daap.songalbum") == 0)) @@ -226,7 +226,7 @@ expr returns [ pANTLR3_STRING result, int valid ] } /* Need to check against NULL too */ - if (op == ':') + if (op == ':' || op == '@') $result->append8($result, "("); } @@ -273,7 +273,9 @@ expr returns [ pANTLR3_STRING result, int valid ] /* String field: escape string, check for '*' */ else { - if (op != ':') + /* With Apple Music 1.0.1.37, we observed some ':' queries using '@' instead, resulting in 'Unknown operator' errors */ + /* Ex: '/databases/1/containers?query=('com.apple.itunes.extended-media-kind@1', ...) */ + if (op != ':' && op != '@') { DPRINTF(E_LOG, L_DAAP, "Operation '\%c' not valid for string values\n", op); $valid = 0; @@ -307,6 +309,7 @@ expr returns [ pANTLR3_STRING result, int valid ] switch(op) { + case '@': case ':': if (neg_op) $result->append8($result, " <> "); @@ -351,7 +354,7 @@ expr returns [ pANTLR3_STRING result, int valid ] $result->append8($result, "'"); /* For empty string value, we need to check against NULL too */ - if ((*val == '\0') && (op == ':')) + if ((*val == '\0') && (op == ':' || op == '@')) { if (neg_op) $result->append8($result, " AND ");