From e18969ef75474cfc6d73d7720f11c220014c0126 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 7 Jun 2021 20:22:36 +0200 Subject: [PATCH] [rsp] Interpret artist in queries as album_artist (fixes #1263) --- src/httpd_rsp.c | 20 ++++++++++++++++++-- src/rsp_query.c | 1 - 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/httpd_rsp.c b/src/httpd_rsp.c index f295997e..ac126835 100644 --- a/src/httpd_rsp.c +++ b/src/httpd_rsp.c @@ -210,6 +210,7 @@ static int query_params_set(struct query_params *qp, struct httpd_request *hreq) { const char *param; + char query[1024]; char *filter; int ret; @@ -245,9 +246,24 @@ query_params_set(struct query_params *qp, struct httpd_request *hreq) param = evhttp_find_header(hreq->query, "query"); if (param) { - DPRINTF(E_DBG, L_RSP, "RSP browse query filter: %s\n", param); + ret = snprintf(query, sizeof(query), "%s", param); + if (ret < 0 || ret >= sizeof(query)) + { + DPRINTF(E_LOG, L_RSP, "RSP query is too large for buffer: %s\n", param); + return -1; + } - qp->filter = rsp_query_parse_sql(param); + // This is hack to work around the fact that we return album artists in + // the artist lists, but the query from the speaker will just be artist. + // It would probably be better to do this in the RSP lexer/parser. + ret = safe_snreplace(query, sizeof(query), "artist=\"", "album_artist=\""); + if (ret < 0) + { + DPRINTF(E_LOG, L_RSP, "RSP query is too large for buffer: %s\n", param); + return -1; + } + + qp->filter = rsp_query_parse_sql(query); if (!qp->filter) DPRINTF(E_LOG, L_RSP, "Ignoring improper RSP query\n"); } diff --git a/src/rsp_query.c b/src/rsp_query.c index 84e942c7..82db6910 100644 --- a/src/rsp_query.c +++ b/src/rsp_query.c @@ -125,7 +125,6 @@ rsp_query_parse_sql(const char *rsp_query) if (sql) { - DPRINTF(E_DBG, L_RSP, "RSP SQL query: -%s-\n", sql->chars); ret = strdup((char *)sql->chars); } else